Android Question Inject javascript through webview

Mattiaf

Active Member
Licensed User
Hi Guys,

is there a way to inject this javascript
B4X:
$("button[aria-label='fullscreen']").click();

through webview?

i'm trying different ways
B4X:
Dim no As NativeObject = WebView1
no.RunMethod("stringByEvaluatingJavaScriptFromString:", Array("$("button[aria-label='fullscreen']").click();"))
but it seems missing a lib

or

B4X:
    WebView1.LoadUrl("$("button[aria-label='fullscreen']").click();")

using webview extra lib

or also

in process global
dim webview1 as webviewextra
and inside a button

B4X:
    Javascript = $"$("button[aria-label='fullscreen']").click();"$
    WebView1.executeJavascript(Javascript)

but none of these ways is working...
what am i doing wrong? :\
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Just responding because it is a quiet time on the Forum, and I want to help keep the question alive.

The form of your statement is using the jQuery library that is missing.
You should either convert it to plain JavaScript, or also inject the JavasSript code to load the jQuery library.

It has been a while since I used Javascript and jQuery, but I am sure there is someone who knows.
 
Upvote 0
Top