4

Is anyone know how to do this setting?

How can I make a jQuery countdown

I read the post and i tried the code by myself.

But no matter how I change my location. Its finally still go to redirect.php and I want to change the time from 10s to 130s.

I had changed the value as well. But no effect at all.

Any idea?

Thanks.

Community
  • 1
  • 1
user1343112
  • 41
  • 1
  • 1
  • 2

3 Answers3

16
  var count = 130;
  var countdown = setInterval(function(){
    $("p.countdown").html(count + " seconds remaining!");
    if (count == 0) {
      clearInterval(countdown);
      window.open('http://google.com', "_self");

    }
    count--;
  }, 1000);
gabitzish
  • 9,535
  • 7
  • 44
  • 65
0

Check out below lines of code:

<p>Counting down to 30 January <span id="year">2010</span>.</p>
<div id="ClsCountdown"></div>

<script type="text/javascript">
$(function () {
    var newDay= new Date();
    newDay= new Date(newDay.getFullYear() + 1, 1 - 1, 30);
    $('#ClsCountdown').countdown({until: newDay});
    $('#year').text(newDay.getFullYear());
});

</script>

You can also refer below link:

http://chandreshmaheshwari.wordpress.com/2011/06/20/jquery-countdown-code/

UPDATED: jquery redirect on click or after 10 seconds

This will make helpful for you.

Thanks.

Community
  • 1
  • 1
Chandresh M
  • 3,808
  • 1
  • 24
  • 48
  • Hi Chandresh, I am actually looking for the time base countdown timer. Yrs coding seem like count down base on date, year... Do you have any idea how to do this http://demos.coolajax.net/php/redirect? – user1343112 Apr 19 '12 at 07:41
  • I have added one another link for that..please check that. thanks – Chandresh M Apr 19 '12 at 08:12
0

Use a jQuery countdown plugin such as jCounter that supports custom countdown values and use their fallback setting to do a redirect.

For example, most plugins have a fallback setting which you can make it run

function() {  window.open('http://website.com', '_self'); }

Usually used as:

$('.countdownClass').jCounter({
//settings here and the fallback:
fallback: function { window.open('http://website.com', '_self'); }
});
SirCommy
  • 260
  • 3
  • 3