Click to See Complete Forum and Search --> : onClick play music


itheperson
09-26-2003, 06:22 PM
I have an image i would like to link so that when it is clicked a music file is played.

any ideas how i can go about this without opening a new window?

Jona
09-26-2003, 06:29 PM
Something like this? (Untested code.)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
</head>
<body>
<p><img src="image.gif" alt="Image description - Play music" onclick="document.getElementById('embMusic').src='music.mp3';"></p>
<p><embed src="" autostart="true"></embed></p>
</body></html>


[J]ona

itheperson
09-26-2003, 07:06 PM
does "<embed src="" autostart="true"></embed>" need to be named embMusic?

Jona
09-26-2003, 07:08 PM
Oh man, I am tired. lol. Okay, you're right. id="embMusic" should be added to it. If it doesn't work, turn EMBED into BGSOUND. Take a look at this script (http://geocities.com/god_loves_07/next_mid.html) that I made a while ago--it should help you.

[J]ona