Rio*_*ams 109
你可以使用这个setTimeout()功能:
// Your delay in milliseconds
var delay = 1000;
setTimeout(function(){ window.location = URL; }, delay);
Run Code Online (Sandbox Code Playgroud)
Dar*_*rov 53
你真的不需要jQuery.你可以使用setTimeout方法使用普通的javascript来完成它:
// redirect to google after 5 seconds
window.setTimeout(function() {
window.location.href = 'http://www.google.com';
}, 5000);
Run Code Online (Sandbox Code Playgroud)
Vic*_*cky 14
$(document).ready(function() {
window.setInterval(function() {
var timeLeft = $("#timeLeft").html();
if(eval(timeLeft) == 0) {
window.location= ("http://www.technicalkeeda.com");
} else {
$("#timeLeft").html(eval(timeLeft)- eval(1));
}
}, 1000);
});
Run Code Online (Sandbox Code Playgroud)
小智 9
您可以使用
$(document).ready(function(){
setTimeout(function() {
window.location.href = "http://test.example.com/;"
}, 5000);
});
Run Code Online (Sandbox Code Playgroud)
小智 6
只需使用:
setTimeout("window.location.href='yoururl';",4000);
Run Code Online (Sandbox Code Playgroud)
..其中“ 4000”是毫秒
是的,解决方案是使用setTimeout,如下所示:
var delay = 10000;
var url = "https://stackoverflow.com";
var timeoutID = setTimeout(function() {
window.location.href = url;
}, delay);
Run Code Online (Sandbox Code Playgroud)
请注意,结果已存储到中timeoutID。如果出于任何原因需要取消订单,只需致电
clearTimeout(timeoutID);
Run Code Online (Sandbox Code Playgroud)