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
  • 156,572
  • 25
  • 250
  • 300
developer82
  • 12,550
  • 20
  • 80
  • 143

1 Answers1

1

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

webView.setWebChromeClient(new WebChromeClient());
A.D.
  • 1,342
  • 2
  • 18
  • 34