You are here: irt.org | FAQ | JavaScript | Sound | Q353 [ previous next ]
The following might detect why:
<HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript"><!-- function playSound() { if (navigator.appName == 'Netscape') { if (parseInt(navigator.appVersion) >= 3) { if (navigator.javaEnabled()) { if (navigator.mimeTypes['audio/midi'] != null) { if (navigator.mimeTypes['audio/midi'].enabledPlugin != null) { document.firstSound.play(false); // play sound in Netscape } else alert('Your browser does not have a plug-in to play audio/midi mime types!'); } else alert('Your browser does not support the audio/midi mime type!'); } else alert('Requires Java enabled to be enabled'); } else alert('Only works in Netscape Navigator 3 or greater'); } else { if (document.embeds) { document.embeds[0].run(); // play sound in Explorer } else alert('Your browser does not support the embeds array'); } } function pauseSound() { document.firstSound.pause(); } function stopSound() { document.firstSound.stop(); } //--></SCRIPT> </HEAD> <BODY> <EMBED SRC="sound.mid" HIDDEN="TRUE" AUTOSTART="FALSE" LOOP="FALSE" NAME="firstSound" MASTERSOUND> <A HREF="javascript:playSound()">Play the sound now!</A> - <A HREF="javascript:pauseSound()">Pause/Restart the sound</A> - <A HREF="javascript:stopSound()">Stop the sound</A> </BODY> </HTML>