when the user leaves the page I want to give message do you want to leave. I am handling this in function pageUnload() event in javascript.But I don't want to call this in the page postback I want to call when they navigate to different page
1 Answer
Look into window.onbeforeunload.
Note that Firefox 4 and up will not present the custom message to the user (but they do present a dialog asking if the user wants to leave). Safari, Chrome, and IE will.
3 Comments
user933316
Hi,Thx.but this too will fire when I submit my page.I want this to fire when the user moves to different page.But If i post back the page for some search it will fire that time too.I want to fire only if the user moves to different page not in postback.
ceejayoz
You can add logic to disable it when they click certain elements.
Pankaj
This event will fire when you close window / tab or navigating to another page.