Keyser wrote:
On most my pages, I use Javascript to play a sound. It works fine in
Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as
the operating system. However, using WindowsXP as the operating system,
the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when
I try to use the Back button on these pages. Is there some setting in
Windows XP that is causing this or is there something I can add to the
Javascript to prevent this from happening?
Here's a sample page - http://keyserfan.home.mindspring.com/millers.htm
That page doesn't use JavaScript "to play a sound", it simply does a
document.write for an <embed src="somefile.wav"> so that the browser
loads a plugin to play the sound if a plugin is available.
I have tried that page with Windows XP, Firefox 1.0 and the Quicktime
plugin 6.0 set up to play audio/wav files and I have no problems going
to another page and then back to the page.
You haven't told us which plugin you are using.
As for the script in that page it looks as follows (:
<SCRIPT language=JavaScript>
<!-- Original: Kipp W. Shinabarger ([snipped email here]) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!!
http://javascript.internet.com -->
<!-- Begin
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=sounds/rumpus2.wav >");
} else {
document.write("<EMBED SRC=sounds/rumpus2.wav AUTOSTART=TRUE ");
document.write("HIDDEN=true VOLUME=100");
}
// End -->
</SCRIPT>
so you should clean that up, the closing > for the embed is missing e.g.
you need
document.write('<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE" ');
document.write('HIDDEN="true" VOLUME="100">');
though you might better use a single document.write call e.g.
document.write('<EMBED SRC="sounds/rumpus2.wav" AUTOSTART="TRUE" ' +
'HIDDEN="true" VOLUME="100">');
And all those HTML comments <-- --> have in my view no place inside of a
script element, beside one such comment wrapper around the whole script
code for historical reasons if you want, so you should throw the
comments out respectively use JavaScript comment syntax if you need to
cite where the script comes from e.g.
// This script and many more are available free online at ...
--
Martin Honnen
http://JavaScript.FAQTs.com/