B4J Question How to get the html code of a webview object ?


Licensed User

How to get the HTML code of a web page loaded in a webview ?

The code bellow don't work because joWV is an object and html_txtarea.text wait a String value.

It's just trying to explain the expected result. But the code is bad.

Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Public zoneweb As WebView
Public html_txtarea As TextArea
End Sub

Sub zoneweb_PageFinished (Url As String)
Dim joWV As JavaObject = zoneweb
html_txtarea.Text = joWV.RunMethodJO("getEngine", Null).RunMethod("getDocument", _
Array As String("var element = document.getElementsByTagName('html')[0].innerHTML.toString();"))
End Sub

Can someone help me?
Last edited:


Licensed User
Hi Erel,

Everything is perfect.
Thank you for taking the time for me.

Where can I find documentation on JavaObject library Version 1.25 ?
Upvote 0


Licensed User
Hello Erel,

Thank you for the link. But I find this page last week on your website. And I did not find the information I need.

RunMethod (MethodName As String, Params() As Object) As Object
Runs the given method and returns the method return value.
MethodName - The case-sensitive method name.
Params - Method paramters (or Null).

RunMethodJO (MethodName As String, Params() As Object) As JavaObject
Similar to RunMethod. Returns a JavaObject instead of Object.

There are only a few lines.
How to find the name of other method?

Only: getDocument for RunMethod and getEngine for RunMethodJO

Are there other methods names?
Perhaps there is only that ?

Upvote 0