This example shows how to enable JavaScript in WebView on Android using Java WebSettings class setJavaScriptEnabled method.
By Default JavaScript is disabled in a WebView. You can enable it through the WebSettings attached to your WebView. You can retrieve WebSettings with getSettings(), then enable JavaScript with setJavaScriptEnabled() method.
1 2 3 |
WebView webView = (WebView) findViewById(R.id.webview); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); |