![](/img/trans.png)
[英]How do I relocate the user to contents of another page without page refresh when navigating?
[英]How to relocate to another page when the user refreshes the browser?
我希望具有以下功能。 当用户刷新页面时,我希望它转到某个页面,例如:
$(window).bind('beforeunload',function(){
window.location.href = "#splash";
});
现在.bind()起作用了,因为如果我说return 'Really?';
它打开一个对话框,说真的吗? 但我希望更改页面。 我该怎么做?
我找到了下一个技巧(经过最新的chrome测试):
var flag = true;
function confirmExit()
{
if (flag)
setTimeout(function(){flag=false;location = '/index.html';});
}
window.onbeforeunload = confirmExit;
试试这个。
$(window).bind('beforeunload',function(e){
e.preventDefault();
window.location.href = "#splash";
});
采用:
function confirmExit()
{
alert("exiting");
window.location.href='index.html';
return true;
}
window.onbeforeunload = confirmExit;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.