浏览器关闭 弹出提示

<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>

 

你可能感兴趣的:(浏览器)