Android Question B4X v9.90 Javascript fails

Rusty

Well-Known Member
Licensed User
Longtime User
After installing the version 9.90, my app has stopped working.
The demo app of Webviewextras doesn't work any longer as well...
WebviewExtras:
#Region  Project Attributes
    #ApplicationLabel: WebView Focus
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
    #DebuggerForceStandardAssets: True
    #DebuggerForceFullDeployment: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim TMR As Timer
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim WebView1 As WebView

    Dim WebViewExtras1 As WebViewExtras
    Dim WebViewSetting1 As WebViewSettings
    Dim IMEX As IME

End Sub

Sub Activity_Create(FirstTime As Boolean)
    IMEX.Initialize("IMEX")
'    TMR.Initialize("TMR", 5000)
       
    WebView1.Initialize("WWW")
 
    WebView1.JavaScriptEnabled=True
    WebViewExtras1.addJavascriptInterface(WebView1, "B4A") ' NOT ESSENTIAL
    WebViewExtras1.addWebChromeClient(WebView1,"Chrome")
    WebViewSetting1.setDatabaseEnabled(WebView1, True)
    '   WebViewSetting1.setDOMStorageEnabled(WebView1, True)
 
    Log("DefaultWebViewDatabasePath: "&WebViewSetting1.getDatabasePath(WebView1))
    '   the WebView will fail to create any databases if the database path is NOT set
    WebViewSetting1.setDatabasePath(WebView1, "")
    Log("NewWebViewDatabasePath: "&WebViewSetting1.getDatabasePath(WebView1))
 
 
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
    WebView1.LoadUrl("file:///android_asset/tspatienthistory.html")
End Sub

Sub WWW_OverrideUrl (Url As String) As Boolean
    Msgbox("HERE", "Made it")
End Sub

Sub ButtonClick(Message As String)
    Log("ShowToast")
    ToastMessageShow(Message, True)
End Sub

Sub set_focus()
    Log("Set Focus")
    Dim Javascript As String
    Javascript=$"document.getElementById("RESULT_TextField-3").focus();"$
    WebViewExtras1.executeJavascript(WebView1, Javascript)
   
End Sub

Sub WWW_PageFinished (Url As String)
    Log($"WWW_PageFinished(${Url})"$)
    CallSubDelayed(Me,"set_focus")
    IMEX.ShowKeyboard(WebView1)
'    TMR.Enabled = True
End Sub

Sub TMR_Tick
    Log("Webview1 " & WebView1)
End Sub

Sub WWW_UserAndPasswordRequired (Host As String, Realm As String) As String()
   
End Sub

Sub Chrome_GeolocationPermissionsRequest As Int
   
End Sub

Sub Chrome_ProgressChanged(NewProgress As Int)
   
End Sub

Sub Chrome_ProgressChanged2(wv As WebView, NewProgress As Int)
   
End Sub

Sub IMEX_HandleAction As Boolean
    Log("IMEX handle")
End Sub

Sub IMEX_HeightChanged (NewHeight As Int, OldHeight As Int)
    Log("Imex change")
End Sub

Sub Activity_Resume
    WebView1.RequestFocus
    set_focus
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

When I say it doesn't work, the ButtonClick event doesn't fire...
I'm sure it is something I've done during the upgrade to 9.90, but can't seem to figure it out.
Any thoughts?
Thanks
Rusty
 
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime User
Sorry I posted this... it was an HTML problem...
The onclick="B4A.CallSub... within the html was misspelled...argh!
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
I'm sure it is something I've done during the upgrade to 9.90, but can't seem to figure it out.
So you figured it out :)

We all pass through this stage every now and then, even after 40 years of programming, I find myself debugging the 'very obvious' code !

Regards,

Anand
 
Upvote 0
Top