Lim Wen Peng

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromLim Wen Peng
ToMe
Subjectabout javascript onbeforeunload events, thanks
Date3 May 2006 04:02
Hi Mark,
I found your site when trying to solve a window.onbeforeunload event. My
problem is as below:

If I don't want to use the dialogbox provided by the window.onbeforeunload
event, I call my own window.openDialog(); when it return a value where user
click cancel, how do I cancel watever operation that user choose? (back,
next page, stop, or refresh)?

I try to use window.getBrowser().stop() in firefox, the event will stop, but
the mouse cursor remain busy. I try to use
var httpChannel =
aRequest.QueryInterface(Components.interfaces.nsIHttpChannel);
httpChannel.cancel(2152398850);
But this function won't work for "back" button.

Thanks so much in advance.

Best Regards,
Lim Wen Peng
FromMe
ToLim Wen Peng
SubjectRe: about javascript onbeforeunload events, thanks
Date3 May 2006 09:00
> If I don't want to use the dialogbox provided by the
> window.onbeforeunload event, I call my own window.openDialog(); when
> it return a value where user click cancel, how do I cancel watever
> operation that user choose? (back, next page, stop, or refresh)?

Supposedly window.stop() should stop the page loading. Some browsers simply
will not allow you to cancel unloading of a page. To be honest, why should
they? The user tried to close the page, and that is their choice, not yours,
since it is their browser.

However, onbeforeunload is a non-standard event, and cannot be used on many
browsers, making it essentially useless for any of my purposes (since I only
use scripts that work properly cross-browser, or are in a proper standard).
I have not investigated how it works.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromLim Wen Peng
ToMe
SubjectRe: about javascript onbeforeunload events, thanks
Date3 May 2006 02:22
Hi Mark,

     Really thanks for your reply. I will try to keep looking for a better
way of doing that. :)

Best Regards,
Lim Wen Peng
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.