Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want code that allows me to evaluate if a web page should be allowed to close, when the user tries to close it. I know about the onunload event, but I want to do this without refreshing the page.
Posted
Updated 10-Jan-10 9:24am
v2

If you read this[^], you'll see that using the unload event is unreliable. If you're able to get it to fire at all, then you can use conditional logic to reload your page if you don't want to let the user leave it. This is, however, horrible UI. If your user decides to close your page, you should let them, and work out a different way to deal with the fact that they have. From what I can see, the unload event doesn't allow you to stop the page loading, which is why you have to reload the page if you want to stop them. Of course, if they close the browser, there's nothing you can do.
 
Share this answer
 
nooo
just i want to know that he left the page
do we can record a cookie and use it for diagnosis the refresh?
plz help me its very imoprtant
how we can find difference between close and refresh
 
Share this answer
 
f11111111111111 f111111111111111 f111111111111111111111 :(( :((
 
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