2019-02-14 06:16:12 +00:00
|
|
|
<div>beforeunload demo.</div>
|
2018-05-02 22:51:45 +00:00
|
|
|
<script>
|
|
|
|
window.addEventListener('beforeunload', event => {
|
2019-02-14 06:16:12 +00:00
|
|
|
// Chrome way.
|
2018-05-02 22:51:45 +00:00
|
|
|
event.returnValue = 'Leave?';
|
2019-02-14 06:16:12 +00:00
|
|
|
// Firefox way.
|
|
|
|
event.preventDefault();
|
2018-05-02 22:51:45 +00:00
|
|
|
});
|
|
|
|
</script>
|
2019-02-14 06:16:12 +00:00
|
|
|
|