javascriptphpnode.jsonbeforeunloadtypeform

Issues with beforeunload not preventing refresh/closing


Trying to prevent closing/refreshing with beforeunload and an embedded typeform but it doesn't seem to display the warning message. Is there something I'm missing?

<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>

Solution

  • resolved with overscroll-behaviour