[webkit-qt] JavaScript window.onbeforeunload event not appearing
Stan Pensak
Stan.Pensak at mathworks.com
Thu Mar 28 07:11:13 PDT 2013
No custom patches that would affect JavaScript as far as I know, but perhaps I can use the pre-built binaries of Qt 4.8.4 from the customer portal to make sure.
By the way, how do you verify that onbeforeunload handlers actually get called? I have found this to be difficult because of the limited number of things one can do from an onbeforeunload handler. Writing to the console doesn't help even if you have the inspector open, because the console gets cleared on every navigation event (Chrome has an option to prevent this that QtWebKit apparently doesn't). Alert doesn't work from what I have read. I have resorted to setting breakpoints in my handlers, and I don't see those breakpoints getting hit, except for ONE case: if I use the reload context menu instead of loading a new URL with setUrl(). Then the handler breakpoint DOES get hit.
In the real application, we need our unload handlers to perform clean shutdown operations by sending messages to the server side. We need this to work not just on page navigation, but anytime a QWebView is destroyed. If there is something we can -do- to the QWebView (or page or frame etc.) before deleting it to cause the unload handler to be called, that would be fine as well. I have already tried kludges like 'setHtml ("")' but that didn't work.
Thanks,
Stan
-----Original Message-----
From: webkit-qt-bounces at lists.webkit.org [mailto:webkit-qt-bounces at lists.webkit.org] On Behalf Of Bruning Michael
Sent: Thursday, March 28, 2013 6:08 AM
To: webkit-qt at lists.webkit.org
Subject: Re: [webkit-qt] JavaScript window.onbeforeunload event not appearing
Hi Stan,
On Wednesday, 27th March 2013 04:55 PM, Stan Pensak wrote:
>
> Sorry, to correct what I said about debugging earlier: it is
> FrameLoader::fireBeforeUnloadEvent() that is being successfully called, but still, nobody is listening to the event (by the time this gets to EventTarget::fireEventListeners() I see there that the listener map is empty.
>
I just tried with a couple of example pages (with qt4.8.4 / fancybrowser demo) and the onbeforunload event worked when navigating to another page. Are you using custom patches on top of 4.8.4 WebKit maybe?
I was however able to reproduce it not working when closing the window.
>
>Stan
Cheers,
Michael
_______________________________________________
webkit-qt mailing list
webkit-qt at lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-qt
More information about the webkit-qt
mailing list