2

When I load youtube.com on web view it says please enable java script on your browser .

I have done getJavaScriptEnabled(true) in my code. Answer?

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
Stephen
  • 834
  • 7
  • 13
  • 1
    You use **g**etJavaScriptEnabled(). I'm pretty sure, you want to use **s**etJavaScriptEnabled(true); Also point your webview to https://www.whatismybrowser.com/detect/is-javascript-enabled to check if it is enabled or not. – DBX12 Nov 24 '16 at 10:27
  • https://developer.android.com/reference/android/webkit/WebSettings.html – IntelliJ Amiya Nov 24 '16 at 10:30
  • Possible duplicate of [Enabling general JavaScript in WebViewClient](http://stackoverflow.com/questions/5089578/enabling-general-javascript-in-webviewclient) – Ahmad Aghazadeh Nov 24 '16 at 11:31

2 Answers2

5
 WebView myWebView = (WebView) findViewById(R.id.myWebView);
 myWebView.loadUrl(" PUT YOUR URL");  //http://www.android.com
 WebSettings webSettings = myWebView.getSettings();
 webSettings.setJavaScriptEnabled(true);

You must add the INTERNET permission to your AndroidManifest.xml file to load website in your application.

vicky
  • 412
  • 4
  • 18
1

You have to use setJavaScriptEnabled(true) not getJavaScriptEnabled(true)

kunal
  • 124
  • 13