Is there a way to use JQuery to redirect to a specific URL after a give time period?
Yes, the solution is to use setTimeout, like this:
var delay = 10000;
var url = "https://stackoverflow.com";
var timeoutID = setTimeout(function() {
window.location.href = url;
}, delay);
note that the result was stored into timeoutID
. If, for whatever reason you need to cancel the order, you just need to call
clearTimeout(timeoutID);
Use setTimeout function with either of the following
// simulates similar behavior as an HTTP redirect
window.location.replace("http://www.google.com");
// simulates similar behavior as clicking on a link
window.location.href = "http://www.google.com";
setTimeout(function(){
window.location.replace("http://www.google.com");
}, 1000)
source: https://www.sitepoint.com/jquery-redirect-web-page/
just use:
setTimeout("window.location.href='yoururl';",4000);
..where the '4000' is m.second