View Single Post
Old 01-08-2013, 05:48 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,993 Times in 3,962 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And WHERE are you calling that code FROM?

If it is from window.onbeforeunload it will never work.

And quite frankly, window.onbeforeunload is the only reliable place to put a "now leaving the page" trap. But the most you can do there is allow the user to cancel his request to leave the page.

(I have wondered if you could make a synchronous HTTP request at that point. I think you could, but that's beginning to get pretty complex.)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote