Section 25
JAVASCRIPT AND MUSIC/SOUNDS
I've been trying to use JavaScript to check (and match) to what web
browser the user has. Although quite a bit more complicated, it does seem
to be more logical. In the examples below for JavaScript, it checks if the
user has JavaScript enabled, if it is Internet Explorer, or if it is
Netscape. Then, depending on the users web browser, it uses appropriate
commands for playing the music/sound file or gives a notice that they do
not have JavaScript enabled. I don't know if this really works out any
better than the above idea, but it does seem more logical to me. Here is
an example of using JavaScript for playing a sound file:
<SCRIPT LANGUAGE="JavaScript">
if (navigator.appName=="Microsoft Internet Explorer")
document.write("<BGSOUND SRC=file.ext>")
if (navigator.appName=="Netscape")
document.write("<EMBED SRC=file.ext hidden=true autostart=true loop=false>")
</SCRIPT>
<NOSCRIPT>
You do not appear to have JavaScript enabled and may not hear the
background sound. Sorry.
</NOSCRIPT>
Be sure to change the 'file.ext' part in BOTH places to the name of
the sound/music file you want used.
I won't run (play) an example music file on this web page because
too many of my other web pages are already cluttered with music/sounds.
[Previous Section]
[Table of Contents]
[Addendum]
[Milt's Micro Digest Home Page]
[Next Section]
The names Microsoft, Internet Explorer, Netscape, and others used in this document
are Trademarks, or Registered Trademarks of the companies represented.
E-mail questions, comments, or suggestions to: miltst@hotmail.com
© 1999 miltst@hotmail.com

(This page was last modified on: Monday, February 08, 1999)