Script compatibility with browsers

U

Uli666

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>
 
C

cwdjrxyz

Uli666 said:
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.
 
U

Uli666

cwdjrxyz said:
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.

Thanks for your answer.
Yes, you are right. I also noticed that this scrip it's quite old. I agree
that would be better to write a new one, but I'm don't know JavaScrip enough
to do it. Could you help me in writing a new script?
I've managed to change the document.all with getElementById, but still
doesn't work on Firefox because of the bgsound (I guess).
The wav sound is very brief (less than 3 seconds) and it's just 29KB.

Thanks for helping.

Uli666
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top