Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Post Countdown JavaScript... Then redirect!

    Welcome. I am here to tell you all about this redirect script I've been working on, and it has a delay. It tells you the time left, and it's pretty compact.
    Note: This code is designed to be copy-paste'd into a part of your site, the script will move itself to <head>.
    Code:
    <script type="text/javascript">
    // Thanks for using the javascript redirect timer, by LoganDark
    // DO NOT EDIT THE BELOW
    function countdown(num){
        if (num > 0) {
            setTimeout("countdown("+(num-1)+")",1000);
            document.getElementById("countdown").innerHTML = num + " seconds";
        }
        if (num < 2) {
            document.getElementById("countdown").innerHTML = num + " second";
        }
        if (num < 1) {
    // DO NOT EDIT THE ABOVE
            window.location.href="{$url}"; // Replace {$url} with what you want to redirect to (don't forget the http://!)
    // DO NOT EDIT THE BELOW
            document.getElementById("countdown").innerHTML = num + " seconds";
        }
    }
    // Note: htmledit.squarefree.com is recommended for testing and expirementing with this code
    // Edit whatever you like below here :3
    
    countdown(10); // Set seconds to redirection
    </script>
    <p><span id="countdown">10 seconds</span> left until redirection.</p>
    Thanks for dropping by, it was fun creating this script for you guys. Bye!

  2. Users who have thanked LoganDark for this post:

    Bitzu (12-21-2013)


 

Tags for this Thread

Posting Permissions

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