View Full Version : embedding sound when link is clicked
i have a sound file "linking.wav"
i want it to play only when the image "mystlinkingbook.jpg" is selected. what is the exact code for this, in HTML?
Jason
12-30-2001, 10:50 PM
Assuming that the wav file is in the same directory as the html file:
<a href="linking.wav"><img src="mystlinkingboog.jpg"></a>
I tried your suggestion and here is the code:
<a href=doorbell.wav><img src="whatever.gif"></a>
When I click on the image, it bring up the 'file download' box. Can you please tell me what I'm doing wrong?
Mosh
fredricknish
01-25-2002, 10:45 AM
Originally posted by Kev
i have a sound file "linking.wav"
i want it to play only when the image "mystlinkingbook.jpg" is selected. what is the exact code for this, in HTML?
You can do that with javascript.
I guess this is what you want http://www.bravenet.com/reviews/archives/tips.php?view=67
Not to be ungrateful but are you telling me I need all this:
+++++
<SCRIPT LANGUAGE="JavaScript">
var agt=navigator.userAgent.toLowerCase();
var is_major=parseInt(navigator.appVersion);
var is_minor=parseFloat(navigator.appVersion);
var
is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.ind
exOf('compatible')==-1) &&
(agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1));
var is_ie=(agt.indexOf('msie')!=-1);
if(is_ie){var agt_ie=agt.substring(agt.indexOf('msie')+5);
is_major=parseInt(agt_ie); is_minor=parseFloat(agt_ie);}
var is_dom2=(document.getElementById);
function jsStop( o ) { if(is_ie&&is_major>=4&&eval('document.'+o)){var
e=eval('document.'+o);if(e.src&&e.src!=''&&e.ReadyState&&e.ReadyState>=4){e.
stop();}}else{if(is_nav&&is_major>=3&&(is_major<4||eval('document.'+o))){eva
l('document.'+o+'.stop()');}} }
function jsPlay( o ) { if(is_ie&&is_major>=4&&eval('document.'+o)){var
e=eval('document.'+o);if(e.src&&e.src!=''&&e.ReadyState&&e.ReadyState>=4){if
(is_major>=5){e.play();}else{e.run();}}}else{if(is_nav&&is_major>=3&&(is_maj
or<4||eval('document.'+o))){eval('document.'+o+'.play(false)');}} }
</SCRIPT>
<A HREF="http://www.bravenet.com"
onMouseOver="javascript:jsPlay('thewav');return true"
onMouseOut="javascript:jsStop('thewav');return true"><IMG SRC="image.gif"
ALT="" WIDTH=200 HEIGHT=200 BORDER=0></A>
<EMBED name="thewav" src="welcome.wav" autostart="false" mastersound
hidden="true" volume=100 width=0 height=0></EMBED>
+++++
just to play a sound???
Is there no easier way?
Thanks again,
Mosh
fredricknish
01-25-2002, 11:14 AM
Yes you need all those.It can be done only with javascript.You could finish it up in a single line of codeing if you wanted to play a backround sound or music but this is more complex.You need all those codes.
kdstyles
04-18-2003, 09:54 AM
is there code for onclick sound for links. i've been searching everywhere for that
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.