beforeunload-false.html 412 B

123456789101112131415161718
  1. <html>
  2. <body>
  3. <script type="text/javascript" charset="utf-8">
  4. // Only prevent unload on the first window close
  5. var unloadPrevented = false;
  6. window.onbeforeunload = function() {
  7. setTimeout(function() {
  8. require('electron').remote.getCurrentWindow().emit('onbeforeunload');
  9. }, 0);
  10. if (!unloadPrevented) {
  11. unloadPrevented = true;
  12. return false;
  13. }
  14. }
  15. </script>
  16. </body>
  17. </html>