Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后不在锚上单击_Javascript_Jquery_Asp.net Mvc_Internet Explorer_Dom Events - Fatal编程技术网

Javascript window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后不在锚上单击

Javascript window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后不在锚上单击,javascript,jquery,asp.net-mvc,internet-explorer,dom-events,Javascript,Jquery,Asp.net Mvc,Internet Explorer,Dom Events,window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后单击定位点时不起作用。请尝试创建新网页以测试以下代码: <body onbeforeunload="return myFunction()"> <p>This example demonstrates how to assign an "onbeforeunload" event to a body element.</p> <p>Cl

window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后单击定位点时不起作用。

请尝试创建新网页以测试以下代码:

<body onbeforeunload="return myFunction()">

    <p>This example demonstrates how to assign an "onbeforeunload" event to a body element.</p>

    <p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>

    <a href="https://www.w3schools.com">Click here to go to w3schools.com</a>

    <script>
        function myFunction() {
            return "Write something clever here...";
        }
    </script>

</body>
它使用IE9和IE11在我的机器上运行良好,当刷新页面或单击锚定时,它将显示出现在确认框中的提示消息

如果仍不工作,请尝试清除浏览器缓存和浏览器数据,或修复IE浏览器

此外,还可以在beforeunload函数和中添加调试器