2

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.

1 Answer 1

1

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);
                }
            });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.