[英]HTML/JQuery redirect after user reloads the page
用戶重新加載頁面后,如何重定向到另一個HTML頁面? 我不想自動執行此操作,因此不能使用http-equiv =“ refresh”。 有任何想法嗎? 謝謝
下面的功能將確保,如果您的頁面是第一次加載或頁面刷新。 然后,您可以相應地添加代碼。
<form name="refreshForm">
<input type="hidden" name="visited" value="" />
// above Hidden field to store value of your page load status
</form>
function checkRefresh()
{
if( document.refreshForm.visited.value == "" )
{
// This is a fresh page load
document.refreshForm.visited.value = "1";
}
else
{
// This is a page refresh
window.location.replace("http://google.com");
// Or , Use either of them
window.location.href = "http://google.com";
}
}
<meta http-equiv="refresh" content="30; ,URL=http://www.metatags.info/login">
content = 30 // 30秒后您的頁面將重定向到該URL = http://www.metatags.info/login “ url
您可以在按下F5鍵時觸發事件:-
document.onkeydown = fkey;
document.onkeypress = fkey
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
window.location = "http://www.yoururl.com";;
wasPressed = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.