B4J Question (Solved) WebView background color. Can I change it?


Staff member
Licensed User

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    Wait For WebView1_PageFinished (Url As String)
    ExecuteJavaScript(WebView1, $"document.body.style.backgroundColor = '#F00'"$)
End Sub

Sub ExecuteJavaScript (wv As WebView, script As String) As Object
    Dim jo As JavaObject = wv
    Return jo.RunMethodJO("getEngine", Null).RunMethod("executeScript", Array(script))
End Sub


Active Member
Licensed User
it is hard explain it in english

I load an URL in a webview. The URL is a Picture. When I load it, I Show the webview in a black background and I see a litle white flash until the url is loaded.

I see your code and the line "Wait For WebView1_PageFinished (Url As String)" solved the problem!! I am very stupid:rolleyes:. Sorry.:(

Thx for teach me again Erel. :)

Edit: A good thing is that now I know how to inject javascript code in a webview
Last edited: