SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast MeGa's Avatar
    Join Date
    Jul 2003
    Location
    Miami, FL
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS count down script over mozilla

    Hello,

    I have this script (which i didn't program) which is suppose to count down an amount of time, and then redirect the page to another place. It works fine on IE/Opera but it doesn't on Netscape/Mozilla. I was wondering if any one could tell me the couse or another script that will work on most browsers.
    Thanks a lot


    Code:
    time_in_sec = 300;
    
    function nextSec()
    {
    
      m = Math.floor(time_in_sec / 60);
      s = time_in_sec % 60;
    
      if (s < 10) { s = "0" + s; }
    
      if ((m == 0)&&(s == 0))
      {
        location.replace("SOME_URL");
      } else {
        document.all.counter.innerHTML = '<font style="font-size: 13pt" color="#999999">' + m + ":" + s + "</font>";
        window.setTimeout('nextSec()',1000);
      }
      time_in_sec--;
    }
    MeGa
    Be the Best, but don't Believe it.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    time_in_sec = 300;
    
    function nextSec()
    {
    
    	m = Math.floor(time_in_sec / 60);
    	s = time_in_sec % 60;
    
    	if (s < 10) {
    		s = "0" + s;
    	}
    
    	if ((m == 0)&&(s == 0)){
    		location.replace("SOME_URL");
    	} else {
    		var e = getElement("counter");
    		if (e) {
    			e.innerHTML = '<font style="font-size: 13pt" color="#999999">' + m + ":" + s + "</font>";
    			window.setTimeout('nextSec()',1000);
    		}
    	}
    	time_in_sec--;
    }
    function getElement(name){
    	if (document.all) return document.all[name];
    	else if (document.getElementById) return document.getElementById(name);
    	else return null;
    }
    travis

  3. #3
    SitePoint Enthusiast MeGa's Avatar
    Join Date
    Jul 2003
    Location
    Miami, FL
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uh, thanks a lot podlob, the getElement solved my problem!
    MeGa
    Be the Best, but don't Believe it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •