I wanted to prevent people from inadvertently leaving our app, so I
used this:
handler = Window.addWindowClosingHandler(new ClosingHandler() {
@Override
public void onWindowClosing(ClosingEvent event) {
event.setMessage("Are you sure?");
}
});
Worked like a charm. However, there are some times when this is
unhelpful, and at these times I'd like to be able to selectively allow
users to leave without being prompted.
I tried handler.removeHandler(). No detectable effect.
I tried event.setMessage(""), event.setMessage(null), and
event.setMessage("New msg"). Only fixed FF.
I tried changing over to the old Listeners and calling
removeWindowCloseListener(). No detectable effect.
I tried adding a native $wnd.onunload = null. No detectable effect.
I tried adding $wnd.document.body.onbeforeunload = null. Only fixed
IE.
There doesn't seem to be a preventDefault() on the onWindowClosing
event class, and that's probably a good thing (but it might have
worked).
I don't see any GWT bugs open against this, and I'm running out of
ideas.
I'm running GWT 1.7 if that matters (putting off the 2.0 upgrade until
we get the current version out to some customers).
An acceptable workaround for my two current cases would be to be able
to mailto and download actions without the WindowCloseHandler
triggering, and without leaving a dangling blank window if the default
mail app is not the browser. Opera does both, Safari does mailto, but
which I can't get IE, Chrome or FF to behave. Any hints on this front
would also be appreciated.
The fact that I could get more or less acceptable results with FF,
Safari, and Opera leads me to think of this as a browser bug, rather
than a GWT bug, but it doesn't help my users to hear this...
Thanks,
Geoff
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.