Skip to content Skip to sidebar Skip to footer

Android: Can't Get Javascript To Work On Webview Even With Setjavascriptenabled(true)

I'm a complete noob to Android and this is just a simple test. Based it on this tutorial. Here goes the HelloWebApp.java package com.company.something; import android.app.Activity

Solution 1:

You missed the part in the tutorial where he adds

webView.setWebChromeClient(newWebChromeClient());

right after adding

webView.getSettings().setJavaScriptEnabled(true);

The JavaDoc for this method says:

Sets the chrome handler. This is an implementation of WebChromeClient for use in handling Javascript dialogs, favicons, titles, and the progress. This will replace the current handler.

Solution 2:

As discussed in https://stackoverflow.com/a/7561674/1818089,

along with

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(newWebChromeClient());

you need to enable DOM storage

WebSettingswebSettings= webView.getSettings();
webSettings.setDomStorageEnabled(true);

Solution 3:

just add

import android.webkit.WebChromeClient;
import android.webkit.WebView;

in YourApp.java

Post a Comment for "Android: Can't Get Javascript To Work On Webview Even With Setjavascriptenabled(true)"