jump to navigation

Create a Simple Countdown Timer with Url-Redirection with JQuery October 23, 2011

Posted by Tournas Dimitrios in JQuery.

So, you want to set things to happen after a certain amount of time? Well, the setTimeout function can help you create some nice scripts that will use time delays to make things happen  .This is a simple script  that counts down a customized time and at the end redirects he browser . The value of the timer is displayed on the browser window , so that the visitor get’s notified for this functionality . An example where this script could be used is when submitted  contact-form content where successfully transmitted (validated and emailed ) ,  the visitor get’s notified with a message and that a redirection will occur in xx seconds . The script depends on JQuery’s “setTimeout”  function , so it can be used   if the library is already embedded into the web-page . See a demo of this script .

<script type="text/javascript"></script>
$(document).ready(function() {
var delay = 10 ;
var url = "http://google.com";
function countdown() {
setTimeout(countdown, 1000) ;
$('#countmesg').html("Redirecting in "  + delay  + " seconds.");
delay --;
if (delay < 0 ) {
window.location = url ;
delay = 0 ;
countdown() ;


1. Katkrv - November 7, 2011

am pleased with this great report , I am glad I found this weblog on yahoo.

As a final point , permit me thank you for your understanding with my English as (I’m persuaded you have become aware this at this moment ,), English is not my first tongue therefore I am using Google Translate to shape out how to write what I genuinely have in mind to write down .

tournasdimitrios1 - November 7, 2011

Welcome and thanks for commenting on this blog .

2. jjozsi - November 29, 2012

Thanks, it wokred fine!

3. mauroferro9 - November 15, 2013

thanks! It works fine!

tournasdimitrios1 - November 15, 2013

You are welcome

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s