beforeunload 的问题无法阻止 refresh/closing

Issues with beforeunload not preventing refresh/closing

尝试使用 beforeunload 和嵌入式类型来阻止 closing/refreshing,但它似乎没有显示警告消息。有什么我想念的吗?

<html>
  <body>
    <script>
      window.addEventListener("beforeunload", function(event) {
        event.returnValue = "";
      });
    </script>
    <div class="relative pt-16 m-auto overflow-hidden" style="height: 700px">
      <iframe
        id="typeform-full"
        width="100%"
        height="100%"
        frameborder="0"
        allow="camera; microphone; autoplay; encrypted-media;"
        src="https://form.typeform.com/to/AQlHXdch?typeform-medium=embed-snippet"
      ></iframe>
      <script>
          type="text/javascript"
          src="https://embed.typeform.com/embed.js"
      </script>
    </div>
  </body>
</html>

也许您正在使用 Chrome?

在 Chrome 51 中删除了页面指定 onbeforeunload 字符串的功能。(从 Safari 9.1 和 Firefox 4 开始,Safari 也删除了它。) https://www.chromestatus.com/feature/5349061406228480

已通过过度滚动行为解决