Hi all, I know there have been other questions on getting JavaScript / Flex ExternalInterface to play nicely, but I've what I think is a weird one. It works perfectly in every browser except Safari (on a Mac). Chrome, IE, Firefox - all ok, but Safari, nope it just wont fire. I've copied my code below, can anyone see why it doesn't work in Safari pls ?
(the 'are you sure' dialog window appears in Safari but the method in the Flex app just doesn't get called)
Cheers Alex
Flex code :
if(ExternalInterface.available){
ExternalInterface.addCallback("flexShutdownHandler",flexShutdownHandler);
fnMyLogger("External interface available - setting shutdownhook");
}else{
fnMyLogger("External interface *NOT* available");
}
private function flexShutdownHandler():void{
fnMyLogger("*****************");
fnMyLogger("** Logging out **");
fnMyLogger("*****************");
// other code as well here where I
// can tell doesn't get called ....
}
JavaScript code :
<script language="JavaScript" type="text/javascript">
function thisFlexApp(flexName) {
if (navigator.appName.indexOf("Microsoft") != -1 || navigator.appName.indexOf("MSIE") != -1) {
return window[flexName];
} else {
return document.getElementById(flexName);
}
}
function shutdownHook(){
window.alert ("are you sure ?");
thisFlexApp("MyFlexApp").flexShutdownHandler();
}
//Set up notification for flex app when page unloads
window.onbeforeunload = shutdownHook;
</script>