0

Google Docs, Gmail etc have this feature where if you try to leave a page that hasn't been saved it pops a dialog box with "confirm, Are you sure you want to navigate away from this page?"

Is there a JQUERY plugin that will allow me to implement this kind of functionality?

Thanks

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
  • StackOverflow also does this when you navigate away from an unsaved answer. – DOK Dec 22 '09 at 21:44
  • 1
    http://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own – Sampson Dec 22 '09 at 21:52

3 Answers3

2

You need to look at the window.onbeforeunload event, which is not supported in all browser, so don't count on it.

Here's the MS documentation for it - it was originally an IE only event.

jball
  • 24,791
  • 9
  • 70
  • 92
1

window.onbeforeunload; it does appear that there are efforts to Standardize the event between browsers too: http://kenbrowning.blogspot.com/2009/01/using-jquery-to-standardize.html

Sampson
  • 265,109
  • 74
  • 539
  • 565
0

I just found this which seems to be an elegant solution too: http://www.jonstjohn.com/node/23

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012