lundi 23 février 2015

Images in js rotator showing in Chrome and IE but not in Firefox

I run a site that generates donations for charity and we have just recently launched a new homepage using a js image rotator for our hero image. We use three images rotating. It works fine in IE and Chrome but not in Firefox. It is old code but it works in the others


I have gone through a lot of research but my skills are limited. I am sure this is something simple that I have overlooked but your assistance would be appreciated.


My code is



<div>
<script type="text/javascript">
function initArray() {

this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}

link = new initArray(
"#",
"http://ift.tt/1LxLdRZ",
"#"
);

image = new initArray(
"http://ift.tt/1EpRLCe",
"http://ift.tt/1LxLdS3",
"http://ift.tt/1EpRLCg"
);

text = new initArray(
"Rainbow Initiative",
"Rainbow Initiative",
"Rainbow Initiative"
);

function getRandom(){
var core = Math.floor(Math.random()*3); // amount of items in array
displayBanner(core)
}

function displayBanner(theNum){
var ranlink = link[theNum];
var ranimage = image[theNum];
var rantext = text[theNum];

//document.write('<a href=/"' +ranlink+ '/" target=/"_blank/"><img src=/"'+ranimage+'/" border="0"

alt=/"'+rantext+'/"></a>');
document.getElementById('theImg').alt=rantext;
document.getElementById('theImg').src=ranimage;
document.getElementById('theLink').href=ranlink;
}
</script>

<a href="#" target="_blank" id="theLink"><img src="" border="0" alt="" id="theImg"></a>

<script type="text/javascript">
getRandom();
setInterval("getRandom()", 7000);
</script>

Aucun commentaire:

Enregistrer un commentaire