如何在用户重新加载页面后重定向到另一个 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";
}
}
关于javascript - 用户重新加载页面后 HTML/JQuery 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39911947/