只能实现按取消转去另个页面,我认为。 window.onbeforeunload = function(e){
location.href="http://www.baidu.com"
e = e || window.event;
e.returnValue = "really go?"; }
location.href="http://www.baidu.com"
e = e || window.event;
e.returnValue = "really go?"; }
调试欢乐多
e = e || window.event;
e.returnValue = "really go?";
location.href="http://www.baidu.com"
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script>
function hhh(e){
e = e || event;
if(e.keyCode == 116){
e.keyCode = 13;
if(confirm("转向www.baidu.com?")){
window.location.href = "http://www.baidu.com";
};
return false;
}
}
document.onkeydown = hhh;
</script>
<body>
<input type="text" />
</body>
</html>
window.onbeforeunload = function(){
if(confirm("确定退出??")){
window.open("http://www.sina.com.cn");
}
} </script>
window.open("http://www.sina.com.cn");
引用 3 楼 chinmo 的回复:
window.onbeforeunload = function(e){
e = e || window.event;
e.returnValue = "really go?";
location.href="http://www.baidu.com"
}