在浏览器上获取确认框关闭 [英] Getting confirmation box on browser close
本文介绍了在浏览器上获取确认框关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
出于上述目的,我尝试了以下代码,但这在mozila中不起作用,并且在确认框中也出现了一些额外的行.
I have tried below code for mentioned purpose but this is not working in mozila and also i am getting some extra line in confirmation box.
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>Coordinates!</title>
<script type="text/javascript">
var myclose = false;
function ConfirmClose()
{
if (event.clientY < 0)
{
event.returnValue = 'Any message you want';
setTimeout('myclose=false',100);
myclose=true;
}
}
function HandleOnClose()
{
if (myclose==true)
alert("Window is closed");
}
</script>
</head> <body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()" ><a href="#">test</a> </body></html>
您能给莫兹拉提些建议吗?
could you please suggest something for mozila.
推荐答案
您可以使用jQuery实现相同的目的.
You can achieve the same using jQuery.
检查此示例.在文本框关闭窗口中输入一些内容.
Check this example. Type something in textbox close window.
这篇关于在浏览器上获取确认框关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文