Javascript window.onbeforeunload函数仅在页面刷新时起作用,但在IE9到IE11迁移后不在锚上单击
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
<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函数和中添加调试器