js监测关闭当前页面、关闭浏览器和取消监测

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33008701/article/details/63254135
<p>非正常退出考试页面:关闭浏览器、关闭页面提示</p>
<p>js监测关闭当前页面、关闭浏览器和取消监测</p>
<button onclick="unbindunload()">取消提示</button>
<!--非正常退出考试页面-->
<script>
    window.onbeforeunload = function () {
        return "退出?";
        //return null;
    };
    //取消监测调用下面的方法
    function unbindunload() {
        window.onbeforeunload=null;//取消事件绑定
    }

</script>

猜你喜欢

转载自blog.csdn.net/qq_33008701/article/details/63254135