close-beforeunload-empty-string.html 428 B

1234567891011121314151617181920
  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 '';
  13. }
  14. }
  15. window.close();
  16. </script>
  17. </body>
  18. </html>