I am trying to send a window.postMessage to an iframe on "onBeforeUnload" event. This is to send some session data to the iframe at the end of the session. The iframe is able to successfully receive the message in its message handler. This works for all kinds of onBeforeUnload event such as reloading a page, closing a page, navigating to a diff page by clicking a link.
The issue is when a user is typing a different url in the address bar and navigating to a diff page, the "onBeforeUnload" event is triggered, but the postMessage method is not sending the message. It is really weird to me. I tried the same scenario in other browsers (safari, firefox, opera) and it works as expected (sending postMessage when user types a url in address bar)
If the issue is not clear, i am happy to include a demo fiddle or screenshots.
Thanks