本文介绍了捕获浏览器关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要在用户单击浏览器关闭按钮但关闭/关闭浏览器时调用一个函数,我已经尝试了很多类似
的方法1)在正文标签OnUnload()中,但每次回发时都运行,并且不起作用
我还尝试抓住浏览器关闭按钮
2)

Hi guys i needed to call a function when user clicks on browser close buton/closing of browser, i have tried many things like
1)In body tag OnUnload() but it runs every time when post back and its not working
i also tried to catch Browser close button
2)

function doUnload()
{
 if (window.event.clientX < 0 && window.event.clientY < 0)
 {
   alert("Window is closing...");
 }
}  its also not working
...
<body  önunload="doUnload()">






因此,任何技巧或逻辑都会受到高度重视

谢谢






so any trick or logic will be highly apreciated

Thanks

推荐答案

<body onbeforeunload="javascript:alert(''window is closing...'');">




这篇关于捕获浏览器关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 20:56