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

Erel

B4X founder
Staff member
Licensed User
Longtime User
java_FClAH22qTy.png


B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    WebView1.LoadUrl("https://www.google.com")
    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
 
Upvote 0

Dadaista

Active Member
Licensed User
Longtime 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:
Upvote 0
Top