|
|
|
#1 |
|
Member
Join Date: Jun 2006
Location: Croatia
Posts: 84
|
Detecting browser window close event?
Is it possible to detect in Flex application browser window close event so that an action can be started when user closes Flex application, does anyone know how to do that if it's possible in the first place? The reason why i am asking this is because i have a multiuser Flex application where every user has it's own directory on a server side. Application has logout button which triggers cleanup of user's directory but what if the user just closes the window? I would like to be able to lunch that same cleanup upon browser close window.
thanks in advance Last edited by blu3; 10-23-2007 at 12:58 PM. |
|
|
|
|
|
#2 |
|
Member
Join Date: Jun 2006
Location: Croatia
Posts: 84
|
I managed to pull this off and and here comes the solution. First i declared cleanUp() function in Flex which does the dirty work and cleans user's leftovers. Then i use ExternalInterface for registering my cleanUp() function so that i can access it using JavaScript from .html wrapper:
Code:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("myFlexFunction",cleanUp);
public function cleanUp():void{
//do the dirty work
........................
.........................
}
Code:
<SCRIPT LANGUAGE="JavaScript">
window.onbeforeunload = clean_up;
function clean_up()
{
var flex = document.${application} || window.${application};
flex.myFlexFunction();
}
</SCRIPT>
Last edited by blu3; 10-24-2007 at 11:47 AM. |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|