Need Help

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
BWind's picture

I have this Javascript that I am using on our companies webpage. It works fine in Firefox but will not work in IE. Can anyone help me please?

Only local images are allowed.

var interval = 5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad1.jpg", "http://google.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad2.jpg", "http://yahoo.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad3.jpg", "http://msn.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad4.jpg", "http://sccah.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad5.jpg", "https://online.sccah.org");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad6.jpg", "http://msn.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad7.jpg", "http://msn.com");
image_list[image_index++] = new imageItem("/resource/resmgr/Ad_Banner/ad8.jpg", "http://www.sccah.com/?page=SCFestival");

var number_of_image = image_list.length;

function imageItem(image_location, link) {
this.image_item = new Image();
this.image_item.src = image_location;
this.image_item.link = link;
}

function getNextImage() {
if (random_display) {
image_index = Math.floor(Math.random() * image_list.length);
}
else {
image_index = (image_index+1) % number_of_image;
}

var new_image = image_list[image_index];
return(new_image);
}

function rotateImage(rImage, link) {
var new_image = getNextImage();
document.getElementById('rImage').src = new_image.image_item.src;
document.getElementById('rLink').href = new_image.image_item.link;

setTimeout("rotateImage()", interval);
}

Comments

Your function rotate image

thomas4019's picture

Your function rotate image has two parameters that are unused. You should either eliminate them or add values for them in you setTimeout() call. I would take a look at Firefox's Error Console and see if there are any errors.

Thomas Hansen
www.ThomasHansen.me

It works in Firefox. It isn't

BWind's picture

It works in Firefox. It isn't working in IE.