IE关闭判断及AJAX注销

<script language="javascript">
        window.onbeforeunload = function () {
            var n = window.event.screenX - window.screenLeft;
            var b = n > document.documentElement.scrollWidth - 20;
            if (b && window.event.clientY < 0 || window.event.altKey) {
               
                        try {
                            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                            xmlhttp.open("POST", "LogOut.aspx", false);
                            xmlhttp.send();
                            //return true;
                        }
                        catch (e) {
                            alert('delete user account error message:' + e.message);
                        }
                  
                //return "你确定要退出系统吗?退出请按'离开此页'";
            } else {
                //alert("是刷新而非关闭");  
            }
        }
  
</script>

posted @ 2012-09-22 18:03  叮/当  阅读(290)  评论(0编辑  收藏  举报