Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i am developing an application where when a user clicks on a browser close button or other button of a webpage, a message must be shown of warning "All entered data will be lost. are you sure??".. on google, it is suggested to use window.onbeforeunload event of javascript... but window. doesnot shows onbeforeunloadthod on my IDE. i am using visual studio 2010 .net framework 4.0 and script type="text/javascript". any help?? any alternative way to accomplish this..
Posted
Comments
Dinesh.V.Kumar 29-Jan-14 1:07am    
For javascript you will not get intellisense..just try adding the code to the window.onbeforeunload() event...it should work..
Codes DeCodes 29-Jan-14 1:10am    
when i type window. ,it does not show onbeforeunload on list of dropdown.. it is that this method is to be created forcefully??

1 solution

This functionality just works and is not related to Visual Studio whatsoever. In your question, you are mixing somethings up, I don't know why.

Also, it is not apparent that you really need onebeforeunload, maybe you can use onunload instead. Please see:
http://msdn.microsoft.com/en-us/library/ie/ms536907%28v=vs.85%29.aspx[^].

You only needs if you need to stop the user from navigating from your page (which is usually not very nice, by the way, but you can ask users confirmation and still allow to leave the page if the confirmation is given). See also this discussion: http://stackoverflow.com/questions/3775566/javascript-question-onbeforeunload-or-onunload[^].

—SA
 
Share this answer
 

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