emaston Posted March 22, 2006 Share Posted March 22, 2006 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 More sharing options...
Webworldx Posted March 22, 2006 Share Posted March 22, 2006 <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 More sharing options...
emaston Posted March 23, 2006 Author Share Posted March 23, 2006 Thanks a lot!It works perfectly in all browsers. Why couldn't Mozilla recognize the original code?(Trying to learn!)em Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now