0

I have a webview that displays a very simple remote webpage which has a script tag with alert in it. For some reason it doesn't show the alert when I run my app.

I've set setJavaScriptEnabled to true:

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);

here is my html on my server:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    Welcome!
    <script>
        alert('123');
    </script>
</body>
</html>

What am I missing?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
developer82
  • 13,237
  • 21
  • 88
  • 153

1 Answers1

1

You have to set a WebChromeClient, which can handle alerts:

webView.setWebChromeClient(new WebChromeClient());
A.D.
  • 1,412
  • 2
  • 19
  • 37