0

I would like to show a custom popup on page reload/refresh. I am using jQuery beforeunload event for this and its working. The issue is, it always showing default Page reload confirm popup before triggering my custom popup. Is there any way to disable browser default confirm popup ? I am using the following code.

jQuery(window).bind('beforeunload', function(e) {
    e.preventDefault();
    showPageloadPopup();
    return false; 
});

Any help and suggestions will be highly appreciable. Thanks.

LX7
  • 609
  • 1
  • 6
  • 22
  • 4
    I think its default behavior for the browser to show a pop up with that event... – Jay Harris Aug 01 '13 at 07:09
  • 3
    the answer is no. So set the returnValue to the text you want to show and have the browser handle it. Also use .on instead of .bind – mplungjan Aug 01 '13 at 07:15
  • 1
    Possible duplicate of http://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own – Andy Fleming Aug 01 '13 at 07:22
  • @mplungjan : Thank you for the suggestion.. I tried with a return string for beforeunload event and its working good in chrome. But in firefox it always showing its default message 'This page is asking you to confirm that you want to leave - data you have entered may not be saved.'. – LX7 Aug 01 '13 at 08:39

0 Answers0