handling the cancel of window.onbeforeunload prompt

25 views Asked by At

Is there any way I can handle the cancel and reload action of the window.onbeforeunload event of javascript something like this ...

window.onbeforeunload = function (e) {
       
       if( e.cancelled ) {
           
           console.log('user has not agreed to reload');
            
       } else {
          console.log('user agrees to reload');
        }

     return '';
   }

I have searched for it on Docs but there is no mention about this

0

There are 0 answers