mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Only prevent unload the first time it is attempted
This commit is contained in:
7
spec/fixtures/api/beforeunload-false.html
vendored
7
spec/fixtures/api/beforeunload-false.html
vendored
@@ -1,11 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Only prevent unload on the first window close
|
||||
var unloadPrevented = false;
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
if (!unloadPrevented) {
|
||||
unloadPrevented = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Only prevent unload on the first window close
|
||||
var unloadPrevented = false;
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return '';
|
||||
|
||||
if (!unloadPrevented) {
|
||||
unloadPrevented = true;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
window.close();
|
||||
</script>
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Only prevent unload on the first window close
|
||||
var unloadPrevented = false;
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
return false;
|
||||
if (!unloadPrevented) {
|
||||
unloadPrevented = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
window.close();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user