electron/spec-main/fixtures/api/close-beforeunload-false.html
2020-04-16 15:22:39 -07:00

24 lines
628 B
HTML

<html>
<body>
<script type="text/javascript" charset="utf-8">
function run() {
// Only prevent unload on the first window close
var unloadPrevented = false;
window.onbeforeunload = function() {
setTimeout(function() {
require('electron').ipcRenderer.sendSync('onbeforeunload');
}, 0);
if (!unloadPrevented) {
unloadPrevented = true;
return false;
}
}
// unload events don't get run unless load events have run.
if (document.readyState === 'complete')
window.close()
else
window.onload = () => window.close()
}
</script>
</body>
</html>