按下关闭按钮,是否发生卸载事件 [英] Close button pressed , does unload event occurs

查看:76
本文介绍了按下关闭按钮,是否发生卸载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

如果按浏览器关闭按钮,page_Unload事件会触发吗?
原因或解释


非常感谢
Shahnawaz



If I press browser close button, does page_Unload Event fire ?
Reason or Explanation


Many Thanks
Shahnawaz

推荐答案

否.

说明:页面完全呈现,发送到客户端并准备丢弃后,将引发Unload事件.
http://msdn.microsoft.com/en-us/library/ms178472.aspx [ ^ ]
No.

Explanation: The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded.
http://msdn.microsoft.com/en-us/library/ms178472.aspx[^]


您也可以使用Java脚本来实现,如

You can do it by using java script also like

<script type="text/javascript">

window.onunload = unloadPage;

function unloadPage()
{
alert("unload event detected!");

//call logout button click here.
}
</script>



并且下面的链接可能会对您有所帮助..
浏览器的窗口关闭事件



and also following link might help you..
Window Close Event of Browser


这篇关于按下关闭按钮,是否发生卸载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆