12

activity_main.xml

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView webView =(WebView)findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.loadUrl("file:///android_asset/www/index.html");
}

i have this code, but javascript is not working :(

1
  • Well just check if the browser settings have javascript disabled. Commented Dec 15, 2012 at 3:48

1 Answer 1

7

You've forgot one of the most important ones :

webView.getSettings().setPluginState(PluginState.ON);
Sign up to request clarification or add additional context in comments.

1 Comment

setPluginState(WebSettings.PluginState state) "This method was deprecated in API level 18. Plugins will not be supported in future, and should not be used." see developer.android.com/reference/android/webkit/…

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.