Jump to content

crossbrowser code


emaston

Recommended Posts

I'm new to Javascript and wrote the following function to allow for rotating images on my site. The script work in IE, Opera, and Safari but not in Mozilla. What part of the code is Mozilla having trouble with? Thanks!The following is in the head:

<script type="text/javascript"><!--var homePageImage = new Array();homePageImage[0] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage1.jpg"; homePageImage[1] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage2.jpg";homePageImage[2] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage3.jpg";var rotate=2100; var count=0;function rotateImg(peds){peds.src=homePageImage[count];if(count==2)  {  count=0;  }else  {  count++  }setTimeout("rotateImg(peds)",rotate);} //--></script>

In the Body:

<body onload="rotateImg(peds)"><img name="peds" class="peds" src="" width="430" height="165" alt="UCI School of Medicine, Department of Pediatrics" />

Link to comment
Share on other sites

<script type="text/javascript"><!--var homePageImage = new Array();homePageImage[0] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage1.jpg"; homePageImage[1] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage2.jpg";homePageImage[2] = "http://www.ucihs.uci.edu/com/pediatrics/newsite/images/homepageimage3.jpg";var rotate=2100; var count=0;function rotateImg(imgId){document.getElementById(imgId).src=homePageImage[count];if(count==2) { count=0; }else { count++ }} var winInt = setInterval("rotateImg('peds')",rotate);//--></script> <body onload="rotateImg('peds')"><img id="peds" class="peds" src="" width="430" height="165" alt="UCI School of Medicine, Department of Pediatrics" />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...