PDA

View Full Version : How to follow a link in QWebKit?



piotr.dobrogost
2nd August 2009, 22:21
Having a DOM of the following html;


<a href="?op=order">
<img class="img_button" src="picture.gif"
onMouseOver="this.src='some.gif';"
onMouseOut="this.src='some_other.gif';"
alt="" border="0">
</a>

how to follow a link (href) in QWebKit (specifically QWebPage).

Please notice that it's an image that is linked.
I can't do it (and I don't want to even if I could) by simulating a mouse click as I don't use QWebView thus I don't have the page rendered.

numbat
3rd August 2009, 10:30
My javascript is a little rusty but something like:


// 0 is the index number of the anchor you want to follow.
// You could also use a name.
window.document.location.href = window.document.anchors(0).href;

should do the trick. Alternatively, you can try:


window.document.anchors(0).click();

Use the evaluateJavaScript function.

maddog_fr
3rd August 2009, 14:05
Sorry but what do you mean by follow a link ?