Exit browser confirmation in javascript - HOW TO ?
I have a flex application. In the wrapper jsp of the flex application, an html page开发者_StackOverflow中文版, 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 !
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.
In javascript you have the onBeforeUnload event, hook on to that. You only cannot alter its appearance.
精彩评论