Answer the question
In order to leave comments, you need to log in
How to make webview run javascript?
Opens the page in a webview located on the server, but the javascript does not work. Tell good people
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
WebView myWebView = (WebView) findViewById(R.id.webBrowser);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("http:Моя ссылка);
}
}
Answer the question
In order to leave comments, you need to log in
Should work, where did you get the idea that it does not work at all? If it does not work alert
, etc., this is a separate problem.
What version of android? What version of webview on android? What SDK version are you using? What makes you think that js does not work? Checking on a simple page with a simple js script is not fate to make sure that it definitely does not work?
Transfer:
webSettings.setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
WebSettings webSettings = myWebView.getSettings();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question