Skip to content Skip to sidebar Skip to footer

Onbeforeunload Seamless Behavior In All Browsers

well guys before i tried to write this post, please be assured that i tried onbeforeunload event in all chrome / firefox and IE, it is working fine in both IE and Firefox but faili

Solution 1:

The thing with the onbeforeunload event is that it's too late to post anything back to the server in the current window. The action that caused the event, i.e. that the browser is about to load a new page, has already decided what page to load next.

The exact behaviour of the browser when handling this event may vary, as it wasn't even in any standard until HTML5.

If you want to send anything to the server from the event, you have to open a new window and post from that, or make an AJAX call. It's a fire-and-forget though, as you can't wait for any response.

I would say that you should not rely on the onbeforeunload to work reliably, so you shouldn't build your architecture around it.

Post a Comment for "Onbeforeunload Seamless Behavior In All Browsers"