Web Analytics Made Easy -
StatCounter JS countdown Error! - CodingForum

Announcement

Collapse
No announcement yet.

JS countdown Error!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JS countdown Error!

    Code:
    <html><head><script type="text/javascript">
      function display(count,str) {
        document.getElementById(count).innerHTML = str;
      }
      function toMinuteAndSecond(x) {
        return Math.floor(AddZero(x/60)) + ":" + AddZero(x%60);
      }
      function setTimer(cont,remain,actions) {
        (function countdown() {
           display(cont, toMinuteAndSecond(remain));		
           actions[remain] && actions[remain]();
           (remain -= 1) >= 0 && setTimeout(arguments.callee, 1000);
        })();
      }
      function AddZero(num) {
    	return ((num >= 0)&&(num < 10))?"0"+num:num+"";
    }
    </script></head><body>
    <div id="Timer"></div><script type="text/javascript">setTimer(Timer,85, { 0: function () { location.reload(true); }});	</script></body></html>
    Error:

    Code:
     getElementById(...) is null or not an object

  • #2
    try putting Timer in quotes when you first make your call

    Code:
    setTimer("Timer",85,
    otherwise it thinks it is looking for a variable, and guess what... it's undefined :P

    Comment

    Working...
    X