Android Question Webview on html popup

tcgoh

Active Member
Licensed User
Longtime User
Hi,

I had a webview working nicely on a website except this selection/click which hung the webview and the overrideUrl didn't log anything. Part of the html code as show below

The Click to this html is Working

B4X:
<script type="text/javascript">
function doSubmitToopen1()
{
    var form=document.xxx1;
    var a = DanaGetHref(window.location);

    if(a.indexOf("https://") >= 0)
    {
        DanaPutAction(form,'https://www.xxx.com/http://xxx1.com:7401/xxx1/loginHandler.do',0);
    }
    else
    {
        DanaPutAction(form,'http://xx1.com:7401/xxx1/loginHandler.do',0);
    }
    DanaMethodSubmit("submit",form);
}

This click NOT working
B4X:
function doSubmitToopen2()
{
    if(confirm("IMPORTANT MESSAGE\n\nWarning.\n\nBy clicking OK, I confirm .")) {
        var form=document.xxx1;
        var a = DanaGetHref(window.location);
        form.open2.value = true;

        if(a.indexOf("https://") >= 0)
        {
            DanaPutAction(form,'https://www.xxx.com/http://xxx2.com.sg:7401/xxx2/contactlessloginHandler.do?userId=0005',0);
        }
        else
        {
            DanaPutAction(form,'http://www.xxx.com:7401/xxx2/contactlessloginHandler.do?userId=0005',0);
        }
       
        DanaMethodSubmit("submit",form);
    }
}

The above warning "IMPORTANT MESSAGE" can not be displayed. I don't know much about html, any help will be great.
Thanks
 

tcgoh

Active Member
Licensed User
Longtime User
Check WebViewExtras library: https://www.b4x.com/android/forum/threads/webviewextras.12453/#content
It should allow you to handle the confirmation dialog.
Hi Erel,
Thanks for the above reply. But I had gone through 13 pages of the above threads and still can not find any example on Alert, confirmation, prompt dialog.

I find something with the codes below to produce a alert message box which I can not see the message box on release mode(webviewextras ver1.42)
B4X:
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
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    webview1.SetLayout(50,50,80%x,80%y)
    webview1.LoadUrl("http://www.google.com")   
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub WebView1_PageFinished (Url As String)
   webviewextras1.executeJavascript(webview1, "alert('Hello World')")
   Dim Javascript As String = "B4A.CallSub('processHTML', true, document.documentElement.outerHTML)"
  
   Log("PageFinished: "&Javascript)
   webviewextras1.executeJavascript(webview1, Javascript)
End Sub

Sub processHTML(html As String)
   Log(html)
   Log("done")
End Sub

Any idea ? I'm using B4a 3.0

Thanks
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
OK I get it to work with

webviewextras1.addWebChromeClient(webview1,"webviewextras1")

but I'm getting this error and B4a stop
B4X:
-----END BREAKPAD MICRODUMP-----
Fatal signal 6 (SIGABRT), code -6 in tid 18769 (b4a.example)

Any help? Thanks
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Adding a WebChromeClient to a WebView simply enables android's default WebView dialogs.
WebViewExtras does no more than enabling these default dialogs.

Could this be another one of those WebView problems that has appeared since KitKat?

@tcgoh What version of android are you testing your code on?
Can you test it on a version prior to KitKat - JellyBean for example.
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Hi Erel and Warwound,

I am testing on Android 5 lollipop.
BTW if I changed the url to https://www.b4x.com the error is gone. The app stop only on www.google.com

Thank you all for helping, my App is running now with Adding of a WebChromeClient.
 
Last edited:
Upvote 0
Top