cucucool
cucucool

Reputation: 3887

Exit browser confirmation in javascript - HOW TO ?

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 !

Upvotes: 0

Views: 681

Answers (2)

Ofer Zelig
Ofer Zelig

Reputation: 17508

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.

Upvotes: 2

Gideon
Gideon

Reputation: 18501

In javascript you have the onBeforeUnload event, hook on to that. You only cannot alter its appearance.

Upvotes: 0

Related Questions