I couldn't bind 'beforeunload' to the window. document, or body tag successfully.
I had to revert to a manual 'window.beforeunload'. I know I should be doing something like evt = window.attachEvent ? window.attachEvent('onbeforeunload', fn) : window.addEventListener('beforeunload', fn, false) but quick and dirty worked for me. If anyone knows how to do it the jQuery "bind" way, I'm all ears. :D