onbeforeunload event on iframe is not triggered in google chrome, works in IE, firefox
I found an ungentle method to fix it.In my parentPage which holds the domain "a.b.com":
<html><iframe id="OBU" name="OBU" src="c.d.com"></iframe><script> window.onbeforeunload = function() { window.frames["OBUI"].frames["SubOBUI"].location = "a.b.com/demo.jpg?t="+(new Date()).getTime(); }</script></html>
In my "c.d.com":
<iframe id="SubOBUI" name="SubOBUI" src="a.b.com/demo.jpg" onload="someMethodThatShouldBeExecutedWhileUnload"></iframe><script> var someMethodThatShouldBeExecutedWhileUnload : function() { alert(1); }</script>
Have a try!
Seems it is an open issue in webkit (and not about to be fixed soon):
https://bugs.webkit.org/show_bug.cgi?id=19418
If anyone knows of workarounds, let me know.