PDA

View Full Version : QtWebKit access HTML manipulated by javascript



rbp
17th September 2009, 07:05
hi there,

I want to build a WebKit app that loads a webpage, allows the user to interact with the webpage, and then saves the current HTML of the webpage.

If the webpage HTML is manipulated with JavaScript, is there a way to access the updated HTML? Or only the original HTML source?

thanks,
Richard

tpf80
19th September 2009, 02:29
For example if I have a QWebView:


QString webhtml = webView->page()->currentFrame()->toHtml();

if this is executed after the javascript modifies the page, then the modified html will be in the string.

You can also use javascript in the page like this:


javascript = QString("javasciptfunctiontoexecute()");
QVariant javascriptreturnvalue = webView->page()->currentFrame()->evaluateJavaScript(javascript);
dosomethinginQt(javascriptreturnvalue.toString());