drisate Posted August 25, 2009 Share Posted August 25, 2009 Hey guys. i have a web page that needs to rotate 8 banner images with each it's own link. I managed to create a working code but i am facing a very weird problem. sometimes the images return an undifined error. Heres the HTML Output <script type="text/javascript"> var imgs1 = new Array("http://proprio-media.com/administrator/uploads/860749150x250-02.jpg", "http://proprio-media.com/administrator/uploads/636470laval3.jpg"); var lnks1 = new Array("http://", "http://"); var alt1 = new Array("860749150x250-02.jpg", "636470laval3.jpg"); var currentAd1 = 0; var imgCt1 = 3; function cycle1() { if (currentAd1 == imgCt1) { currentAd1 = 0; } var banner1 = document.getElementById('adBanner1'); var link1 = document.getElementById('adLink1'); banner1.src=imgs1[currentAd1] banner1.alt=alt1[currentAd1] document.getElementById('adLink1').href=lnks1[currentAd1] currentAd1++; } window.setInterval("cycle1()",10000); var imgs2 = new Array("http://proprio-media.com/administrator/uploads/835152Rive-Sud4.jpg", "http://proprio-media.com/administrator/uploads/519177Rive-Sud4.jpg", "http://proprio-media.com/administrator/uploads/869400laurentide4.jpg"); var lnks2 = new Array("http://", "http://", "http://"); var alt2 = new Array("835152Rive-Sud4.jpg", "519177Rive-Sud4.jpg", "869400laurentide4.jpg"); var currentAd2 = 0; var imgCt2 = 3; function cycle2() { if (currentAd2 == imgCt2) { currentAd2 = 0; } var banner2 = document.getElementById('adBanner2'); var link2 = document.getElementById('adLink2'); banner2.src=imgs2[currentAd2] banner2.alt=alt2[currentAd2] document.getElementById('adLink2').href=lnks2[currentAd2] currentAd2++; } window.setInterval("cycle2()",10000); var imgs3 = new Array("http://proprio-media.com/administrator/uploads/317794Rive-Sud2.jpg", "http://proprio-media.com/administrator/uploads/214150laval3.jpg"); var lnks3 = new Array("http://", "http://"); var alt3 = new Array("317794Rive-Sud2.jpg", "214150laval3.jpg"); var currentAd3 = 0; var imgCt3 = 3; function cycle3() { if (currentAd3 == imgCt3) { currentAd3 = 0; } var banner3 = document.getElementById('adBanner3'); var link3 = document.getElementById('adLink3'); banner3.src=imgs3[currentAd3] banner3.alt=alt3[currentAd3] document.getElementById('adLink3').href=lnks3[currentAd3] currentAd3++; } window.setInterval("cycle3()",10000); var imgs4 = new Array("http://proprio-media.com/administrator/uploads/386411Rive-Sud2.jpg"); var lnks4 = new Array("http://"); var alt4 = new Array("386411Rive-Sud2.jpg"); var currentAd4 = 0; var imgCt4 = 3; function cycle4() { if (currentAd4 == imgCt4) { currentAd4 = 0; } var banner4 = document.getElementById('adBanner4'); var link4 = document.getElementById('adLink4'); banner4.src=imgs4[currentAd4] banner4.alt=alt4[currentAd4] document.getElementById('adLink4').href=lnks4[currentAd4] currentAd4++; } window.setInterval("cycle4()",10000); var imgs5 = new Array(); var lnks5 = new Array(); var alt5 = new Array(); var currentAd5 = 0; var imgCt5 = 3; function cycle5() { if (currentAd5 == imgCt5) { currentAd5 = 0; } var banner5 = document.getElementById('adBanner5'); var link5 = document.getElementById('adLink5'); banner5.src=imgs5[currentAd5] banner5.alt=alt5[currentAd5] document.getElementById('adLink5').href=lnks5[currentAd5] currentAd5++; } window.setInterval("cycle5()",10000); var imgs6 = new Array("http://proprio-media.com/administrator/uploads/693145laval1.jpg"); var lnks6 = new Array("http://"); var alt6 = new Array("693145laval1.jpg"); var currentAd6 = 0; var imgCt6 = 3; function cycle6() { if (currentAd6 == imgCt6) { currentAd6 = 0; } var banner6 = document.getElementById('adBanner6'); var link6 = document.getElementById('adLink6'); banner6.src=imgs6[currentAd6] banner6.alt=alt6[currentAd6] document.getElementById('adLink6').href=lnks6[currentAd6] currentAd6++; } window.setInterval("cycle6()",10000); var imgs7 = new Array("http://proprio-media.com/administrator/uploads/304925laurentide3.jpg"); var lnks7 = new Array("http://"); var alt7 = new Array("304925laurentide3.jpg"); var currentAd7 = 0; var imgCt7 = 3; function cycle7() { if (currentAd7 == imgCt7) { currentAd7 = 0; } var banner7 = document.getElementById('adBanner7'); var link7 = document.getElementById('adLink7'); banner7.src=imgs7[currentAd7] banner7.alt=alt7[currentAd7] document.getElementById('adLink7').href=lnks7[currentAd7] currentAd7++; } window.setInterval("cycle7()",10000); var imgs8 = new Array("http://proprio-media.com/administrator/uploads/228557montreal3.jpg"); var lnks8 = new Array("http://"); var alt8 = new Array("228557montreal3.jpg"); var currentAd8 = 0; var imgCt8 = 3; function cycle8() { if (currentAd8 == imgCt8) { currentAd8 = 0; } var banner8 = document.getElementById('adBanner8'); var link8 = document.getElementById('adLink8'); banner8.src=imgs8[currentAd8] banner8.alt=alt8[currentAd8] document.getElementById('adLink8').href=lnks8[currentAd8] currentAd8++; } window.setInterval("cycle8()",10000); </script> <a href="http://www." id="adLink1" target="_top"> <img src="http://proprio-media.com/administrator/uploads/860749150x250-02.jpg" id="adBanner1" border="0"></a> <br><br> <a href="http://www." id="adLink2" target="_top"> <img src="http://proprio-media.com/administrator/uploads/835152Rive-Sud4.jpg" id="adBanner2" border="0"></a> <br><br> <a href="http://www." id="adLink3" target="_top"> <img src="http://proprio-media.com/administrator/uploads/317794Rive-Sud2.jpg" id="adBanner3" border="0"></a> <br><br> <a href="http://www." id="adLink4" target="_top"> <img src="http://proprio-media.com/administrator/uploads/386411Rive-Sud2.jpg" id="adBanner4" border="0"></a> <br><br> <a href="http://www." id="adLink6" target="_top"> <img src="http://proprio-media.com/administrator/uploads/693145laval1.jpg" id="adBanner6" border="0"></a> <br><br> <a href="http://www." id="adLink7" target="_top"> <img src="http://proprio-media.com/administrator/uploads/304925laurentide3.jpg" id="adBanner7" border="0"></a> <br><br> <a href="http://www." id="adLink8" target="_top"> <img src="http://proprio-media.com/administrator/uploads/228557montreal3.jpg" id="adBanner8" border="0"></a> Copy the code to an html page and try it under IE and you should ee the problem after a few image switch. Quote Link to comment Share on other sites More sharing options...
drisate Posted August 25, 2009 Author Share Posted August 25, 2009 aaaaa lol it was the imgCt var ... doh !!! thx anuway lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.