我想要使用jQuery創建重定向。jQuery在頁面加載設定時間後重定向
我想要做的是,如果頁面加載讓我說5秒我希望它重定向到另一個頁面。
function Redirect() {
window.location="http://example.com/search.jsp; <-- Page being redirected from
}
document.write("This page is unavailable at this time, You will be redirected to the home page in 5 seconds");
setTimeout('Redirect()', 5000);
但比加載不同的頁面5秒鐘後讓說,這將被重定向到NewSearch.jsp
你忘了你的window.location ...也window.location接近報價d等於您要重定向到的頁面,而不是當前頁面。當然,這隻有在用戶啓用了JS的情況下才有效。不知道這與jQuery有什麼關係,這些都是香草JS功能。 – 2015-01-20 20:51:42
setTimeout的第一個參數應該是一個函數,而不是一個字符串。像'setTimeout(function(){Redirect();},5000);' – 2015-01-20 20:53:06