Sound Across Browsers

Ever plug a sound into a web page, and not have it play on half the browsers? That little problem is solved here.
All variables are in bold. If hidden is set to 'false', then controls will show in or near the browser window.


<Script Language="JavaScript">
var MSIE=navigator.userAgent.indexOf("MSIE");
var NETS=navigator.userAgent.indexOf("Netscape");
var OPER=navigator.userAgent.indexOf("Opera");
if((MSIE>-1) || (OPER>-1)) {
document.write("<BGSOUND SRC=sound.file LOOP=INFINITE>");
} else {
document.write("<EMBED SRC=sound.file AUTOSTART=TRUE");
document.write("HIDDEN=TRUE VOLUME=100 LOOP=TRUE>");
}
</SCRIPT>

Back