PDA

View Full Version : Possible to retrieve generated html from webview?



HankFay
2013-09-15, 00:17
I'd like to "grab" the generated HTML from an .rsp webview. It is possible, and how?

thanks,

Hank

barrymavin
2013-09-15, 03:29
Currently not. The "html" property on the WebView is currently write-only. Reading it is problematic if it contains html that is generated internally by javascript which is the case with JQM, JQuery, knockout.js and other frameworks which manipulate the DOM injecting HTML based on async callbacks completing.

There is no standard way of doing this as the DOM may be ready but javascript frameworks may not have completed their work.

barrymavin
2013-09-15, 03:36
If you just want to print it or generate a pdf there are methods on the WebView for that.

barrymavin
2013-09-15, 03:41
Oh and also there is a evaluate() method on the WebView that will execute some JavaScript inside the WebView, so you could put some code in that returned the document.

myhtml = Lianja.GetElementByID("mywebview").webview.evaluate("my_javascript_function();")

HankFay
2013-09-15, 08:24
Oh and also there is a evaluate() method on the WebView that will execute some JavaScript inside the WebView, so you could put some code in that returned the document.

myhtml = Lianja.GetElementByID("mywebview").webview.evaluate("my_javascript_function();")

Great: that should work. There is no js working in the dom here.

thanks,

Hank