message on navigating to another page
If a use makes some changes on a web page and tries to navigates away from the that web page, I want to give a message in dialog box - "you have unsaved changes." cancel to stay and continue to loose changes and go to new page.
How to detect a) user is navigating away from the page
b) There are unsaved changes
and c) Give dialog with stay or continue