ballhogjoni Posted March 6, 2008 Share Posted March 6, 2008 I decided to post one error at a time. I can probably explain it better. This is my code for a countdown function. My problem is that it works for IE but not mozilla. Can someone point me in the right direction? var sec = 01; // set the seconds var min = 15; // set the minutes function countDown() { sec--; if (sec == -01) { sec = 59; min = min - 1; } else { min = min; } if (sec<=9) { sec = "0" + sec; } time = (min<=9 ? "0" + min : min) + ":" + sec; if (document.getElementById) { theTime.innerHTML = time; } SD=window.setTimeout("countDown();", 1000); if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); alert("Your Time Has Expired, Order Now or Forever Wonder If You Could be eBay's next Millionaire!."); } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { countDown(); }); Link to comment https://forums.phpfreaks.com/topic/94776-countdown-function-problems-in-mozilla/ Share on other sites More sharing options...
jacksonmj Posted March 7, 2008 Share Posted March 7, 2008 Have you remembered to set the variable theTime? e.g. <div id="timeElem"></div> <script type="text/javascript"> var theTime = document.getElementById("timeElem"); var sec = 01; // set the seconds var min = 15; // set the minutes . . . NB: You're probably better off using setInterval(), and then clearInterval() when the countdown has finished, if you're calling a function repeatedly at uniform intervals. Link to comment https://forums.phpfreaks.com/topic/94776-countdown-function-problems-in-mozilla/#findComment-486297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.