|
Posted by cwdjrxyz on 12/04/06 18:33
Uli666 wrote:
> Hi all!
> I found this script that's very useful to me. The only problem is that it
> only works in IE. Can you please help me to make it compatible with others
> browsers (at lest Firefox)? I read that the problem is about the
> document.all, but I don't know how to change it.
>
> Thank you very much.
>
> Ui666
>
>
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <bgsound src="#" loop="0" autostart="true" id="soundFile">
> <script type="text/javascript">
>
> function gotoNextPage(page) {
>
> window.location='link.html';
> }
>
> function playSound(sound) {
>
> document.all.soundFile.src="sound.wav";
> window.setTimeout("gotoNextPage('" + sound + "');",3000);
> }
>
> </script>
> </head>
> <body>
> <p><a href="link.html" onclick="playSound('sound'); return false;">
> Page 2</a></p>
> </body>
> </html>
This script apppears quite old and out of date. It appears to be from
the browser war era when IE4 and Netscape 4 were the most recent
browsers. It likely would be better to write a new, modern script than
to try to update this senior citizen. Even in the browser war era, this
script would work only for IE. Problem 1: BG sound works only on IE
browsers and a very few others. Netscape was using embed for sound back
then. Then IE also would support embed for sound. Problem 2. The
document.all would work only on IE and close relatives, while Netscape
used document.layers. Now modern browsers use document.getElementById.
Layers is now gone for modern browsers. Modern IE, Mozilla
family(Firefox,Netscape, Mozilla, Seamonkey) and Opera all support
getElementById. IE6 will also still support document.all as will Opera,
at least for some things. Also using a .wav is fine if you only use a
very brief sound. However a .wma, .rm, and several other compressed
audio formats have much less file size than a .wav, if your sound is
longer - say a short song.
Navigation:
[Reply to this message]
|