码迷,mamicode.com
首页 > 其他好文 > 详细

浏览器关闭 弹出提示

时间:2014-07-01 16:27:02      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:style   blog   java   color   width   javascript   

<script type="text/javascript">
    window.a = 0;
    var rv = "确定要关闭吗?";
    window.onbeforeunload = function () {
        var isIE = document.all ? true : false;
        if (isIE) {
            var n = window.event.screenX - window.screenLeft;
            var b = n > document.documentElement.scrollWidth - 20;
            if (b && window.event.clientY < 0 || window.event.altKey) {
                //是关闭而非刷新
                window.event.returnValue = rv;
            }
        } else {
            if (document.documentElement.scrollWidth != 0) {
                if (window.a != 1) {
                    window.a = 0;
                    return rv;
                } else {
                    window.a = 0;
                }
            }
            else {
                window.a = 0;
                return rv;
            }
        }
    }
</script>

 

浏览器关闭 弹出提示,布布扣,bubuko.com

浏览器关闭 弹出提示

标签:style   blog   java   color   width   javascript   

原文地址:http://www.cnblogs.com/ranlin/p/3817933.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!