How can I do a redirect to another HTML page after a user reloads the page? I don't want to do it automatically, therefore can't use http-equiv="refresh". Any ideas? Thanks
Below function will make sure, If your page is loaded for first time or its a page refresh. Then you may add your code accordingly.
<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
You could trigger an event on when the F5 key is pressed:-
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.