Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    1
    Member #
    39333

    header countdown to click then forward

    hi guys working on a new site need some help i got a countdown to submit that i would like to be in a header

    code looks like this

    <script type="text/javascript">
    seconds = 60;

    function decreaseTime(){
    document.frm.submit.value=seconds;
    seconds--;
    if(seconds<0){
    document.frm.submit.value='Submit';
    document.frm.submit.disabled=false;
    return true;
    }
    setTimeout('decreaseTime()',1000);
    }

    window.onload = function() {
    document.frm.submit.value=seconds;
    setTimeout('decreaseTime()',1000);
    }
    </script>
    </head>
    <form name="frm" action="">
    <input type="submit" name="submit" disabled />
    </form>

    i want the counter to stop when not view page
    Last edited by ltcminer; Jun 04th, 2014 at 08:57 AM.

  2.  

  3. #2
    Member DerrickE's Avatar
    Join Date
    Jul 2007
    Location
    Houston, TX
    Posts
    58
    Member #
    15580
    Liked
    10 times
    There's a few ways. This method is the easiest I have found. As there is a lot of supporting information, I'm just posting the link as the code by itself won't help as much. Put your start/stop timer in the onchange() event of the function below.

    Read the chosen answer as it has all the information you need.
    javascript - Is there a way to detect if a browser window is not currently active? - Stack Overflow


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:13 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com