I have a flex application. In the wrapper jsp of the flex application, an html page, i have to capture the browser close event with an alert "DO you wish to close?", if the user clicks "yes", i have to call a flex function to handle the event. Can any one help !
            Asked
            
        
        
            Active
            
        
            Viewed 677 times
        
    0
            
            
        - 
                    There is already a question answered on capturing browser close event http://stackoverflow.com/questions/1631959/browser-window-close-event. – Manish Singh Sep 11 '11 at 06:16
 - 
                    1Please don't do this. It is really annoying to users. – Michael Aaron Safyan Sep 11 '11 at 07:15
 
2 Answers
2
            
            
        On your body tag, add onunload event:
<body onunload="doStuffHere();">
...
</body>
and in your JS function (doStuffHere) call Flex to handle the event.
If, eventually, doStuffHere returns false, it cancels the close event.
You can also use onbeforedownload. See this Q&A for more details. You can use both of them, see why.
        Community
        
- 1
 - 1
 
        Ofer Zelig
        
- 17,068
 - 9
 - 59
 - 93
 
0
            
            
        In javascript you have the onBeforeUnload event, hook on to that. You only cannot alter its appearance.
        Gideon
        
- 18,251
 - 5
 - 45
 - 64