Standards-compliant background music

liunx

Guest
Hi everyone<br />
<br />
I'm designing a few pages in HTML 4.01 Transitional and I have to include background music on one. (a MID file). If at all possible, I want to make the code fully standards-compliant, but I can't find how to include music correctly.<br />
<br />
I've tried <bgsound> and <embed>, both of which work but do not validate as correct HTML.<br />
<br />
Does anyone know how I can include music that meets the HTML 4.01 standards?<br />
<br />
Adam<br />
<br />
P.S. I don't actually think music should be included in pages, as a general rule, but the syllabus says it must be included. :mad:<!--content-->The way it is technically supposed to be done is with object (<!-- m --><a class="postlink" href="http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT">http://www.w3.org/TR/html401/struct/obj ... def-OBJECT</a><!-- m -->). However, support for this element is scratchy where it is supported at all. This is a case where you will have to use proprietary elements for it to work in as many browsers as possible.<!--content-->Here is a javascript snippet that will play a background sound and be compatible with a number of browsers.<br />
<br />
<SCRIPT LANGUAGE="JavaScript"><br />
<!--<br />
var MSIE=navigator.userAgent.indexOf("MSIE");<br />
var NETS=navigator.userAgent.indexOf("Netscape");<br />
var OPER=navigator.userAgent.indexOf("Opera");<br />
if((MSIE>-1) || (OPER>-1)) {<br />
document.write("<BGSOUND SRC=http://www.webdeveloper.com/forum/archive/index.php/mysong.mid LOOP=INFINITE>");<br />
} else {<br />
document.write("<EMBED SRC=http://www.webdeveloper.com/forum/archive/index.php/mysong.mid AUTOSTART=TRUE ");<br />
document.write("HIDDEN=true VOLUME=100 LOOP=TRUE>");<br />
}<br />
//--><br />
</SCRIPT><!--content-->Thanks, jeffmott. I thought it might be object, but I couldn't figure out how to do it properly. I'll just have to use embed/bgsound, then point out in my evaluation it is invalid code.<br />
<br />
Oh, the joys of school ICT coursework. :rolleyes: <br />
<br />
Adam<!--content-->
 
Back
Top