Need Help

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by BWind on July 2, 2010 at 4:16pm

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

Posted by thomas4019 on July 2, 2010 at 5:35pm

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

Posted by BWind on July 2, 2010 at 5:47pm

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

Javascript

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /