How can I get reason of page unloading in javascript's onunload event, in IE?

Posted by DM on Stack Overflow See other posts from Stack Overflow or by DM
Published on 2010-04-27T04:32:02Z Indexed on 2010/04/27 4:33 UTC
Read the original article Hit count: 206

Filed under:
|
|
|

There may be different reasons of page unloading:
1 User closes the current window.
2 User navigates to another location.
3 Clicks the Back, Forward, Refresh, or Home button.
4 User submits a form, and then browser starts to unload current page and load page with results of form submitting. (Assuming that the current window is the form's target).
5 and so on...

Can I somehow know in onunload handler that the reason of unloading is p.4, i.e. moving to page with results of form submitting?
I could define some flag when submiting form, but this does not solve the problem. Because response (on form submit) from web server takes some time, browser doesn't unload the current page immediately and waits response from server. And during this waiting user may close window or navigate anywhere. And I need to know whether was it indeed moving to results page or something else...?

© Stack Overflow or respective owner

Related posts about html

Related posts about dom