I have a Flash movie embeded with swfobject in a html container. Through ExternalInterface I have registered a javascript function to fire callback to my flash app.
ExternalInterface.addCallback("notifyClose", notifyOnClose );
The javascript function is added as an event listerner to fire onbeforeunload.
<script language="JavaScript">
function getSWF(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1){
return window[movieName];
}else { return document[movieName];}
}
var bye = function() {
getSWF('flashContainer').notifyClose('> WE ARE CLOSING APP!');
//alert('WE ARE CLOSING APP!.');
};
var hola = function(){
getSWF('flashContainer').notifyClose('> WE ARE opening APP!');
alert('WE ARE opening APP!.');
};
if(window.addEventListener) {
window.addEventListener('load', hola,false);
window.addEventListener('beforeunload', bye, false);
} else if (window.attachEvent) {
window.attachEvent('onload', hola);
window.attachEvent('onbeforeunload', bye);
}
</script>
I have tested in FF and IE. Firefox works as expected but not in IE. In IE I get notified in Flash with the onload message, but not onbeforeunload.
Is it some king of sandbox restriction? Just bad code?