Click here to Skip to main content
15,885,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

In one of my current projects, I am using window.onbeforeunload event to check some values. I need to reset the values (if any value changed) to original values during this operation if I select "Stay on this page", but I am not getting how to do this. Is there any way to find a return value of "Leave this page" and "Stay on this page" dialog box?

For example: There is a dropdown which is having values A,B,C. Its initial value is A, during the work, I changed it to B and closed the window without saving that value. If I select stay on this page, then I want to reset the value of dropdown to A. How is this possible?

Any help will be appreciated.

Kind Regards,
Jagjot
Posted

With confirm you can simply set your custom text:
http://www.pageresource.com/jscript/jconfirm.htm[^]

Or use jQuery:
http://theinfiniteloopblog.com/tag/change-javascript-confirm-button-text/[^]

Good luck!
 
Share this answer
 
 
Share this answer
 
Comments
Jagjot Singh 21-Apr-11 8:26am    
Reset is not the solution
Chris Maunder 21-Apr-11 8:50am    
But maybe Google is...
Ankur\m/ 21-Apr-11 8:52am    
And why?
Jagjot Singh 21-Apr-11 9:07am    
I am sorry but I need something to know that user has opted for stay on this page. How can I know that user has opted for this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900