If you set an unbeforeunload event inside an iframe, this is not triggered when you for instance click through to a link in the iframe. It works in IE and Firefox (not Opera, but Opera does not support onbeforeunload in general AFAIK).
Just wondering, am I doing something wrong? Should this behaviour not be possible? Or is it a bug in Google Chrome/webkit? Any workarounds?
Code example:
test.html:
<html>
<body>
<p>Main page content</p>
<script type="text/javascript">
window.onbeforeunload = function() {alert('unloadevent in main window');};
</script>
<iframe id="tpa" src="..test2.html"></iframe>
</body>
</html>
test2.html:
<html>
<body>
<script type="text/javascript">
self.onbeforeunload = function() {alert('unloadevent in frame window');};
</script>
<a href="http://www.google.com/">Link to for instance google</a>
</body>
</html>