监听IE关闭
<script language=”JavaScript” type=”text/javascript”> //------------------------------------------------------- // Specifies a function for the window's onbeforeunload event // Call back to the getUnsavedDataWarning in our Flex app when the browser is about to unload //------------------------------------------------------- //window.onbeforeunload = function() window.onbeforeunload = onbeforeunload_handler; function onbeforeunload_handler() { var warning=""; var fxControl = document.${application} || window.${application}; if ( fxControl ) if ( typeof fxControl.getUnsavedDataWarning=="function") warning = fxControl.getUnsavedDataWarning(); // This calls a function in our Flex app if ( warning != '' ) return warning; else return void(0); } //------------------------------------------------------- // Specifies a function for the window's onunload event // Call back to the javascriptOnUnload in our Flex app when the browser unloads //------------------------------------------------------- window.onunload = function() { var fxControl = document.${application} || window.${application}; if ( fxControl ) if ( typeof fxControl.javascriptOnUnload=="function") fxControl.javascriptOnUnload(); // This calls a function in our Flex app } </script>private const UNSAVED_DATA_WARNING:String = 'You have unsaved changes. You will lose them if you continue.'; private function onCreationComplete():void { ExternalInterface.addCallback("getUnsavedDataWarning", function():String { return UNSAVED_DATA_WARNING; } ); }