You are here: irt.org | FAQ | JavaScript | Sound | Q485 [ previous next ]
Try this:
<script language="JavaScript"><!-- var can_play = false; var mimetype = 'audio/midi'; if (navigator.mimeTypes) { if (navigator.mimeTypes[mimetype] != null) { if (navigator.mimeTypes[mimetype].enabledPlugin != null) { can_play = true; document.write('<embed src="sound.mid" hidden=true loop=false autostart=false>'); } } } if (document.all) { can_play = true; document.write('<embed src="sound.mid" hidden=true loop=false autostart=false>'); } function playSound() { if (document.embeds && can_play) { if (navigator.appName == 'Netscape') document.embeds[0].play(); else document.embeds[0].run(); } } function stopSound() { if (document.embeds && can_play) document.embeds[0].stop(); } //--></script> <a href="#" onMouseover="playSound()" onMouseOut="stopSound()"><img src="image.gif" width="100" height="100" border="0"></a>