JQuery Redirect to URL after specified time

55

Is there a way to use JQuery to redirect to a specific URL after a give time period?

This question is tagged with javascript jquery redirect

~ Asked on 2011-09-01 21:19:20

The Best Answer is


117

You could use the setTimeout() function:

// Your delay in milliseconds
var delay = 1000; 
setTimeout(function(){ window.location = URL; }, delay);

~ Answered on 2011-09-01 21:20:51


56

You don't really need jQuery for this. You could do it with plain javascript using the setTimeout method:

// redirect to google after 5 seconds
window.setTimeout(function() {
    window.location.href = 'http://www.google.com';
}, 5000);

~ Answered on 2011-09-01 21:21:29


Most Viewed Questions: