Unanswered: window.onbeforeunload should be fired only in some scenarios
I have the following scenario:
I have a page and an edit button after clicking of which the same page opens in a separate window for the user to edit.
The user should be prompted before he navigates away only from the edit mode of that page.It is 'Are you sure you want to navigate blah blah blah..?" the usual message.This message is not required when the user tries to navigate from any other page of the application.Though I have tried to constrain the firing of the event using an 'if' condition to check if the user is in that page or not , it doesn't work.I get the message every time I try to close a window or navigate away from any page of the application.
Do you think onbeforeunload is the proper event to be handled in this scenario?