如何检测母版页中的浏览器关闭按钮 [英] How to detect browser close button in master page

查看:59
本文介绍了如何检测母版页中的浏览器关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



在我的项目中,我正在使用母版页,如果用户关闭浏览器,那么我想在注销页面上导航用户。



请帮我解决。



谢谢

Hello All,

In my project, i am using master page and if user close the browser then i want to navigate user on logout page.

Please help me to solve it.

Thanks

推荐答案

如果用户已关闭浏览器,您如何导航它们?无法知道浏览器或选项卡何时关闭,因为没有引发任何事件。如果你做了一些基础研究并用Google搜索了这个问题,你就会发现这个问题。
If the user has closed the browser how can you then navigate them? There is no way of knowing when the browser or tab has been closed as no event is raised for it. If you had done some basic research and googled this question you would have discovered that for yourself.


这是不可能完成的,至少不是完美的。大多数浏览器只允许您在用户尝试关闭窗口时弹出消息。但你不能阻止窗口关闭。



您可以使用javascript代码汇总活动:

This cannot be done, at least not perfectly. Most browsers only allow you to popup a message when the user is trying to close the window. But you can't prevent the window from closing.

You can use javascript code to wireup an event:


document )。ready( function (){
window .onbeforeunload = WindowClosing;
});

function WindowClosing()
{
return 再见;
}
(document).ready(function () { window.onbeforeunload = WindowClosing; }); function WindowClosing() { return "Bye bye"; }


这篇关于如何检测母版页中的浏览器关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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