Music and sounds : Editing and inserting a MIDI file
Eric Chautrand
Identifying the Visitor's Browser
If you are used to our workshops, you are probably also familiar with the irritating incompatibility problem (unfortunately
recurrent) that exists between Netscape and Internet Explorer.
Here again, the HTML code which enables a midifile to be played back needs to be different for each of the two browsers. To
solve this problem, we will first lead the visitor through a browser detection page, then automatically redirect him to the
appropriate page. For this, we need just a few lines of JavaScript.
Here is the code for the browser detection page:
<HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--
if ("Netscape" == navigator.appName) location.replace ("son-a02-netsc.htm")
else
location.replace ("son-a02-ie.htm");
//-->
</SCRIPT>
</HTML>
This page will automatically display the
son-a02-netsc.htm page, if the visitor uses Netscape, or the
son-a02-ie.htm page, if he uses another browser.
Save this page under any name you want. The next step will be to create the pages devoted to our two browsers.
Adding a link. A MIDI file can be directly embedded in a Web page or be referred to by a simple HTML link. In the latter case, activating
the link will launch the default visitor's player. The last option has the advantage of being accepted by Netscape Navigator
and Internet Explorer.