javascript - 无法识别功能 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 时
解决方案
推荐阅读
- android - 如何从 Java 源代码中获取 UAnnotation 的限定名称?
- javascript - 在构造函数中创建具有属性的类时出错
- javascript - 无法使用 openlayer 6 显示矢量图层
- html - 如何从我的 Font Awesome 复选框中删除此白色背景或边框?
- retrofit2 - 无法在 androidx 项目中转换工件“retrofit.jar”
- c# - .net 核心无法通过嵌套对象的绑定阶段
- redis - 用于两个节点 Redis 复制的 Redis Sentinel 架构
- c# - 使用 COMReference 创建一个自包含的 exe
- snowflake-cloud-data-platform - 雪花语法中具有 2 个以上不同数字和一些可选字符的正则表达式字符串
- ios - 如何在 iOS AVPlayerViewController 上禁用搜索?