|
|||
|
|
This is a really cool and fun JavaScript project you can customize for your own website. The effect we're going to create is to play a sound when a
visitor passes the mouse over a particular image link. This could be a phone-ring for a telephone icon linking to a contact page, or whatever you
want. Here's how it works. First, copy the main script below and place on your page.
<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>
Now use the code below for the actual link location, image and sound files you are going to use. Of course, you'll have to alter the code for your own
image (image.gif) and sound files (welcome.wav), as well as the link URL. Now when a mouse goes over your image, the sound will play!
<A HREF="http://www.artspace2000.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>
By the way, if you're looking for terrific free sound clips, try this site: http://www.freeaudioclips.com/