[webkit-qt] how to auto closing javascript alert box in webkit

Andrew Webster apwebster at gmail.com
Thu Apr 28 06:56:43 PDT 2011


2011/4/28 周鹏 <zhoupeng19 at 126.com>:
> Hi all!
>
> How to auto closing a alert dialog in qt webkit,such as this page:
> <html>
>     <head><title>test</title></head>
>     <body>
>         <script>alert("alert")</script>
>         <p>test<p>
>     </body>
> </html>
> http://lists.trolltech.com/qt-interest/2003-01/msg00706.html   said
> "
>
> Maybe you can set a timer in the dialogs class, that after 5 seconds emits a
> signal which is connected to a slot that closes the dialog.
>
>
> Example :
>
> connect(timer, SLOT(timeout(), this, SLOT(accept()));
> timer->start(5000, TRUE);
>
>
> "
> but how to reimplementation qdialog calss in qtwebkit program?Is it possible
> to forbid display dialog?
>

Take a look at QWebPage::javaScriptAlert  (and javaScriptPrompt,
javaScriptConfirm).  You can override these in your derived class and
show your own QDialog (or do nothing at all).  Does that help?

Andrew


More information about the webkit-qt mailing list