• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Javascript Works in Firefox but not in IE

Hi I havea banner rotator script which is working perfectly in Firefox but for some reason, it is not working in IE (v 6). All I get is a blank page with no error message. What could the problem be?
My code isas follows:
====================

<script TYPE="text/javascript" LANGUAGE="JavaScript"><!--
function Href(dest,image,text) {
this.dest = dest; this.image = image; this.text = text; }

function setHref(dest,image,text) {
myHref[hrefItems++] = new Href(dest,image,text); }

function replace() {
var now = new Date();
random = now.getSeconds()%hrefItems;
if (random == lastrandom) {
if (random == hrefItems-1) random--; else random++; }
document.banner.src = myHref[random].image;
document.links[0].href = myHref[random].dest;
setTimeout('replace()',3000);
lastrandom = random; }
function Test() {
if (navigator.appName == "Netscape") {
var now = new Date();
random = now.getSeconds()%hrefItems; lastrandom = random;
document.write('<A HREF="' + myHref[random].dest + '">');
document.write('<IMG NAME="banner" WIDTH=468 HEIGHT=60 ');
document.write('BORDER=0 ALT="Caption for image here" ');
document.write('SRC="' + myHref[random].image + '">');}
if (navigator.appName == "Netscape"
&& parseInt(navigator.appVersion) >= 3) {
setTimeout('replace()',3000);}}
//--></script>


<script TYPE="text/javascript" LANGUAGE="JavaScript"><!--
var random = 0;
var lastrandom = -1;
var hrefItems = 0;
var myHref = new Array();
setHref('http://www.website1.com','banner1.gif','alttag1');
setHref('http://www.website2.com','banner2.gif','alttag2');
setHref('http://www.website3.com','banner3.gif','alttag3');
Test();
//--></script>
<noscript>Please enable JavaScript if you wish to see this image and link.</noscript>

=================
Thanks in advance.
M.
0
mmofya
Asked:
mmofya
  • 3
1 Solution
 
TimYatesCommented:
In your Test() function, you seem to have:

    if (navigator.appName == "Netscape") {

Which surely will stop Netscape working?
0
 
TimYatesCommented:
>> Which surely will stop Netscape working?

I meant:

Which surely will stop IE from doing anything?
0
 
mmofyaAuthor Commented:
Wow...I wonder how I missed that.
Thanks
0
 
TimYatesCommented:
Glad I could help!  Sometimes a second pair of eyes is all you need :-)

Good luck with it!

Tim
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now