Hi,
I need disable alert message in Webview, it´s possible?
Thanks,
I need disable alert message in Webview, it´s possible?
Thanks,
wve.executeJavascript(wv, Javascript)
also, don't forget: a webview is a subset of a browser. not everything supported in a browser is supported in a webview.
wve.addWebChromeClient(wv,"WVE")
WebViewExtras1.ExecuteJavascript("window.alert = """";")
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim webview As WebView
Dim wvx As WebViewExtras
Dim btn As Button
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("Layout1")
webview.Initialize("wv")
Activity.AddView(webview, 0%x,0%y,100%x,100%y)
wvx.addJavascriptInterface(webview, "jsi")
' wvx.addWebChromeClient(webview, "cc")
btn.Initialize("btn")
Activity.AddView(btn, 80%x, 80%y, 15%x, 10%y)
btn.Text = "tap me"
webview.LoadHtml( File.ReadString( File.DirAssets, "alert.html"))
btn.BringToFront
End Sub
Sub btn_Click
wvx.executeJavascript( webview, "window.alert=''" )
End Sub
' wvx.addWebChromeClient(webview, "cc")
wvx.executeJavascript( webview, "window.alert=function(e){};" )
Dim jo As JavaObject
wvx.SetWebChromeClient(jo.InitializeContext.RunMethod("createChromeClient",Null))
#if java
import android.webkit.WebView;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
public WebChromeClient createChromeClient(){
WebChromeClient wbc = new WebChromeClient(){
public boolean onJsAlert(WebView view, final String url, String message, JsResult result) {
result.cancel();
return true;
}
};
return wbc;
}
#End If