0
0
mirror of https://github.com/puppeteer/puppeteer synced 2024-06-14 14:02:48 +00:00
puppeteer/test/assets/beforeunload.html
Andrey Lushnikov a310d57d84
feat(Page): add option to run 'beforeunload' when closing the page ()
Today, `page.close()` method doesn't run page's beforeunload listeners.
This way users can be sure that `page.close()` actually closes the
page.

This patch adds an optional `runBeforeUnload` option to the
`page.close()` method that would run beforeunload listeners. Note:
running beforeunload handlers might cancel page closing.

Fixes .
2018-05-03 01:51:45 +03:00

6 lines
106 B
HTML

<script>
window.addEventListener('beforeunload', event => {
event.returnValue = 'Leave?';
});
</script>