<HTML> <HEAD> <SCRIPT> function closeIt() { event.returnValue = "Any string value here forces a dialog box to appear before closing the window."; } </SCRIPT> </HEAD> <BODY onbeforeunload="closeIt()"> <a href="http://www.163.com">Click here to navigate to www.163.com</a> </BODY> </HTML>
点确定的时候会调用window.onunload()
所以不用获取确定的标志,只要在window.onunload()中加入你要的代码就可以了!
<script language=javascript>
function window.onbeforeunload()
{
if (event.clientX>document.body.clientWidth && event.clientY<0 ¦ ¦event.altKey){
window.event.returnValue="确定要退出本页吗?";
new ActiveXObject("WScript.Shell").sendKeys("{ESC}")}
}
</script>
<input type=button value=关闭 onclick="window.opener=null;window.close()">
<!-- IE5.5以上不会有弹出提示 -->
---------------------------------------------------------------
//判断是刷新还是关闭
function CloseOpen() {
if(event.clientX<=0 && event.clientY<0) {
if(!confirm("关闭窗口?"))window.open(document.URL);
}
else {
//alert("notnew");
}
}
</script>
<body onunload="CloseOpen()">
<HEAD>
<SCRIPT>
function closeIt()
{
event.returnValue = "Any string value here forces a dialog box to appear before closing the window.";
}
</SCRIPT>
</HEAD>
<BODY onbeforeunload="closeIt()">
<a href="http://www.163.com">Click here to navigate to
www.163.com</a>
</BODY>
</HTML>