![]() |
This page is obsolete and retained for archival purposes only.
Please refer to Playing Sound from JavaScript.
Question: What browsers can execute scripts that play sound?
Answer: The techniques described in Playing Sound work in Microsoft Internet Explorer 4.0 and newer as well as Netscape Navigator 3.0 and newer. In order to play sound from JavaScript in Internet Explorer, it's enough to test that the browser version is 4.0 or newer. In Netscape Navigator, you'll have to make sure that
For example, if you want to play the sound file
mySound.mid
specified in the following EMBED tag
<EMBED NAME="mySound" SRC="mySound.mid" LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>then the necessary tests can be performed using this code:
ver = parseInt(navigator.appVersion); if (ver>2 && navigator.appName=="Netscape" && navigator.mimeTypes['audio/x-midi'] && navigator.javaEnabled() && document.mySound.IsReady() ) { // put Netscape-specific code here } if (ver>3 && navigator.appName.indexOf("Microsoft")!=-1) { // put Explorer-specific code here }
Copyright © 1999-2008, JavaScripter.net.