Issue
In a WebView
in my app I cannot run JavaScript
. I tried many ways and searched many Stackoverflow pages to find the answer. It cannot even show me a simple alert message.
Here's my code :
WebView webView = (WebView) findViewById(R.id.wv_webviewac);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.loadUrl(url);
Eeverything is fine in the browser but in a WebView
it doesn't work.
Solution
this will solve the problem
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("https://syllabkerala.in");
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
//hide loading image
findViewById(R.id.progressBar1).setVisibility(View.GONE);
//show webview
findViewById(R.id.activity_main_webview).setVisibility(View.VISIBLE);
}
});
Answered By - Sebin Sunny
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.