Geoff wrote:
I have a javascript function that runs when onunload is triggerd. So
this runs when someone navigates away from the page or closes the
window. I only want the code to run when the window is closed. Anyone
got any ideas?
It cannot be done. Scripts can be written to be aware of page
transitions resulting from navigating using links within a page and drag
and drop operations using URL links/shortcuts (on some browsers), but
navigation resulting form favourites/bookmarks (using the menu or
otherwise), the back button, the history or users typing URLs into the
location bar (or selecting from its the drop-down of recent URLs) cannot
be detected in any way, so they cannot be discriminated from window
closing.
Not all browsers will execute the onunload event when the browser is
closed (there is not much point as there isn't a great deal that a scrip
can do in that context (except maybe attempt to open another window
(which would be near universally unwelcome))).
Richard.