Show DevBest jQuery fade-in, countdown & redirect

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,459
With help from (thanks), a little piece of Javascript. Title is explanation enough. Might be helpfull for you guys to use.

Javascript:
Code:
function redirect() {
$('#DIVID').fadeOut(1000, function() {
location.href = 'http://YOURWEBSITE.com/';
});
}
 
function countDown() {
countdown--;
 
if (countdown == -1) {
redirect();
 
return;
}
 
$('#countdown-holder').html(countdown);
 
setTimeout(countDown, 1000);
}
 
var countdown = 10;
 
$(function() {
$('#DIVID').hide();
 
$('#DIVID').fadeIn(1000, function() {
countDown();
});
 
$('#DIVID').click(redirect);
});

Countdown from 10-0:
Code:
<span id="countdown-holder">10</span>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Some people might think, "why isn't this working?" That's because you need the jQuery library included AS WELL as the jQuery UI library.

Here:

Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
 

Users who are viewing this thread

Top