Update:
This article was written at a time when Netscape 4 and Internet
Explorer 4 were the browsers used by the majority of people. ("What is
Netscape?" you say. My point precisely.) As such, the rest of this page
is obsolete. It even talks about a type of music file (midi) that you
rarely see on the Internet any more. If your site uses HTML5, you should
use the <audio> tag instead. You can find more information about
the use of this tag in the audio section of the official web standards
site.
The problem with embedding background music is that
the different browsers out there have their own methods of implementing
embedded music files.For all versions of Netscape, as well as Internet Explorer ("IE") 3.0 and above, you can use the following code:
<embed src="yourmusicfile.mid" autostart="true" loop="true"
width="2" height="0">
</embed>
The
width and height attribute given above causes the player to be
invisible. If you do not want it to be invisible, you can specify your
own dimensions to suit your site decor.width="2" height="0">
</embed>
For Opera and all IE versions, the following code works:
<bgsound src="yourmusicfile.mid" loop="infinite">
As
you probably have noticed, IE 3.0 and above support both methods, so
you cannot simply put both those tags into your web document in the hope
of supporting all browsers. It will work on Netscape and early versions
of IE, but the newer versions of IE will recognize both tags, leading
to problems when IE tries to load the music file twice.The workaround that I've seen on some sites, that seems to work for me, is to enclose the BGSOUND tag inside NOEMBED tags, thus preventing IE from interpreting the second tag.
<embed src="yourmusicfile.mid" autostart="true" loop="true"
width="2" height="0">
</embed>
<noembed>
<bgsound src="yourmusicfile.mid" loop="infinite">
</noembed>
This code appears to be compatible with all versions of IE, Netscape and Opera.width="2" height="0">
</embed>
<noembed>
<bgsound src="yourmusicfile.mid" loop="infinite">
</noembed>







No comments:
Post a Comment