nmretd
Jul 27th, 2000, 03:30 AM
I am using the following Javascript to display a banner. It works ok in IE 5 but not in Netscape ( I am using version 4.06).
How can I get it to work in NS. OR can someone show me some code that will work in both browsers ?
<HTML>
<HEAD>
<TITLE>Javascript to Rotate the Banners</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2">
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
onload = start;
var ar = new Array();
ar[0] = "<A><IMG src='img1.jpg' width=400 height=40</A>";
ar[1] = "<A><IMG src='img2.jpg' width=400 height=40></A>";
var num = 0;
function start() {
setInterval("update()", 1500);
}
function update() {
display("banner", ar[num]);
num++;
if (num == ar.length) num = 0;
}
function display(id, str) {
if (NS4) {
with (document[id].document) {
open();
write(str);
close();
} } else {
document.all[id].innerHTML = str;
}
}// -->
</SCRIPT>
</HEAD>
<BODY>
<SPAN ID="banner" STYLE="position: center;"></SPAN>
</BODY>
</HTML>
How can I get it to work in NS. OR can someone show me some code that will work in both browsers ?
<HTML>
<HEAD>
<TITLE>Javascript to Rotate the Banners</TITLE>
<SCRIPT LANGUAGE="JavaScript1.2">
var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
onload = start;
var ar = new Array();
ar[0] = "<A><IMG src='img1.jpg' width=400 height=40</A>";
ar[1] = "<A><IMG src='img2.jpg' width=400 height=40></A>";
var num = 0;
function start() {
setInterval("update()", 1500);
}
function update() {
display("banner", ar[num]);
num++;
if (num == ar.length) num = 0;
}
function display(id, str) {
if (NS4) {
with (document[id].document) {
open();
write(str);
close();
} } else {
document.all[id].innerHTML = str;
}
}// -->
</SCRIPT>
</HEAD>
<BODY>
<SPAN ID="banner" STYLE="position: center;"></SPAN>
</BODY>
</HTML>