日期:2014-05-17 浏览次数:20624 次
jQuery(function(){           
            jQuery(window).bind("beforeunload", function(e) {
                if (!e) e = window.event;
                    returnValue = "是否离开";
                e.returnValue = returnValue;
                return returnValue;
            });
        })
<body onunload="alert('页面即将关闭')";>
------解决方案--------------------
类似这样的问题没有万无一失的办法,无法完全区分关闭与刷新,而关闭浏览器的办法又是那么多种.
------解决方案--------------------
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
    <script language="javascript" type="text/javascript">
        function closeWindow() {
            window.event.returnValue = "是否关闭";
        }
    </script>
</head>
<body onbeforeunload = "closeWindow();">
</body>
</html>