Android Question [SOLVED] JavaScript B4A.CallSub broken in WebViewExtra2 ?

semar

Active Member
Licensed User
Longtime User
Dear all,
the CallSub function works by WebViewExtra, but I can't get it working with WebViewExtra2. Is this functionality in someway broken ? Or am I missing something obvious here ?

In the attachment is a test project. Clicking on the button should change the text in the label. The function in the jstest.js is successfully called - you can see that the JavaScript "alert" is fired. But the function does not call the counterpart function "fromJavascript" in the B4A program.

It would be nice if someone could share a bit of light on how to get it working with WebViewExtra2.

Best regards
Sergio
 

Attachments

  • javascriptTest.zip
    10.3 KB · Views: 333
Last edited:

josejad

Expert
Licensed User
Longtime User
Hi:

Add this code to your project, and it works:

B4X:
    Dim JavascriptInterface1 As DefaultJavascriptInterface 'Add this line
    JavascriptInterface1.Initialize 'Add this line
    
    wbx.AddJavascriptInterface(JavascriptInterface1, "B4A") 'Change in this line wbx for JavascriptInterface1
 
Upvote 0

semar

Active Member
Licensed User
Longtime User
Hi:

Add this code to your project, and it works:

B4X:
    Dim JavascriptInterface1 As DefaultJavascriptInterface 'Add this line
    JavascriptInterface1.Initialize 'Add this line
   
    wbx.AddJavascriptInterface(JavascriptInterface1, "B4A") 'Change in this line wbx for JavascriptInterface1
And, indeed, it works !

Many thanks José for your kind support ! ?
 
Upvote 0
Top