Reputation: 3583
I was reading this post and noticed that when I am closing browser or tab the message is showing as well. I need to disable the Refresh button or give some warning but problem with solution in that post is that it shows message when I close browser.
Is there any way to show message only on refresh?
I know that there are some posts like this on stackoverflow.com, but none of them work for me. So this is not a duplicate question unless there is a working solution.
Upvotes: 2
Views: 1644
Reputation: 5419
Isn't it possible to catch a key down event on F5? If not with silverlight you can probably with a keyboard hook.
Upvotes: 0
Reputation: 3116
window.onbeforeunload
from JavaScript (as noted in the post you link to) really is the only way this can be done in a cross-browser, cross-platform way, that I know of.
But that does end up getting triggered for F5. That's just the way browsers work - they unload a page before reloading it, even in the refresh case.
Do you really find users hit F5 often enough for such a prompt to be a problem?
Upvotes: 1