[webkit-qt] Emulate click event with QWebElement::evaluateJavaScript

Benjamin Poulain benjamin.poulain at nokia.com
Tue Jan 4 16:05:29 PST 2011


Hi,

On 01/05/2011 12:42 AM, ext Tr3wory wrote:
> I tried to emulate a click event on an<a>  tag with
> evaluateJavaScript(), but nothing happens...
>
> First, I load the page with QWebPage::load, and after the loadFinished
> signal, I search for the<a>  tag with
> mainFrame()->documentElement()->findFirst().
> The resulting QWebElement is good, I can check it with the
> toOuterXml() function.
> But if I call the button.evaluateJavaScript("click()"), like i saw in
> one of the examples
> (http://doc.trolltech.com/latest/qwebelement.html), nothing happens.
>
> If I create a QWebView, and attach the previous QWebPage to it, I can
> see the content, and I can click on the link with the mouse...
>
> Do you have any idea?

The example is on an input element. Those elements have a click() 
method, not link elements (see the DOM specification).

I do not know if there is a simple way to activate a link 
programmatically. You could execute the event handler, and load href by 
default, or send a syntethic mouse event.

cheers,
Benjamin


More information about the webkit-qt mailing list