File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 < head >
77 < meta charset ="UTF-8 ">
88 < script type ="application/javascript "> <!--
9- window . addEventListener ( 'beforeunload' , function ( event ) {
9+ function onBeforeUnload ( event ) {
1010 console . log ( 'beforeunload' ) ;
1111 event . preventDefault ( ) ;
1212 event . returnValue = '' ;
13- } ) ;
13+ }
14+ window . addEventListener ( 'beforeunload' , onBeforeUnload ) ;
1415 console . log ( 'beforeunload listener is registered.' ) ;
1516
1617 function openTabs ( url , count ) {
2324 </ head >
2425 < body >
2526 < p > This page should show a confirmation before closed or reloaded.</ p >
27+ < p > < button onclick ="window.removeEventListener('beforeunload', onBeforeUnload) "
28+ onkeypress ="if (event.key == 'Enter') window.removeEventListener('beforeunload', onBeforeUnload); "
29+ > Clear unload listener</ button > </ p >
30+ < hr >
2631 < p > < button data-count ="5 "
2732 data-url ="about:blank "
2833 onclick ="openTabs(this.dataset.url, this.dataset.count) "
You can’t perform that action at this time.
0 commit comments