首页 > 解决方案 > 无法识别功能 onbeforeunload

问题描述

如果我直接进入按钮关闭窗口,则无法识别该功能

功能被正确激活,如果链接到发送到 GOOGLE 的链接,但如果加载是页面和文档在关闭浏览器标记或关闭按钮不起作用

<body onbeforeunload="return myFunction()">

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

<a href="https://www.google.com">Click here to go to google </a>
  
<script>
function myFunction() {
  return "Write something clever here...";
}
</script>

</body>

我希望一旦您在页面上找到我,而无需单击出售的商品并且在关闭选项卡或浏览器识别 obeforeunload 时

标签: javascript

解决方案


推荐阅读