关闭移动浏览器窗口时如何显示警报消息? [英] How do show alert message when closing a Mobile Browser window?

查看:77
本文介绍了关闭移动浏览器窗口时如何显示警报消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关闭移动浏览器窗口时如何显示警告消息?

How to show alert message when closing a Mobile Browser window?

推荐答案

您好,





JQuery: http://jquery.com/ [ ^ ]



Jquery检测卸载或关闭:http://api.jquery.com/unload/ [ ^ ]





Hi,


JQuery :http://jquery.com/[^]

Jquery Detect unload or close : http://api.jquery.com/unload/[^]


Quote:

unload事件的确切处理因浏览器的版本而异。例如,某些版本的Firefox会在跟踪链接时触发事件,但不会在窗口关闭时触发。在实际使用中,应该在所有支持的浏览器上测试行为,并与专有的beforeunload事件进行对比。

The exact handling of the unload event has varied from version to version of browsers. For example, some versions of Firefox trigger the event when a link is followed, but not when the window is closed. In practical usage, behavior should be tested on all supported browsers, and contrasted with the proprietary beforeunload event.


<script>
window.onbeforeunload = function (e) {
    e = e || window.event;

    // For IE and Firefox prior to version 4
    if (e) {
        e.returnValue = 'Sure?';
    }

    // For Safari
    return 'Sure?';
};
</script>


这篇关于关闭移动浏览器窗口时如何显示警报消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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