how to display javascript popup in android webview

18,460

Solution 1

See answers to this question:

JavaScript alert not working in Android WebView

The answer from Stephen Quan is to just set the default webChromeClient

mWebView.setWebChromeClient(new WebChromeClient());

Solution 2

You can allow javascript and opening windows from javascript in a webview. Just set this settings

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

Be careful though because enabling javascript on your app webview can bring some serious security issues

check this links

From StackOverflow

Interesting Presentacion

and this one for webviews

Official Android WebView Link

Share:
18,460
user3235860
Author by

user3235860

Updated on August 21, 2022

Comments

  • user3235860
    user3235860 over 1 year

    Is it possible to open a javascript popup window on a android webviewer coded like this example from google? and if yes how? I dont want that the original page in the background is closed it has to be a popup like on the picture.

    Building Web Apps link

    enter image description here

  • user3235860
    user3235860 over 10 years
    I tried that already but it's not working. Do i need special permissions or something like that?
  • klifa
    klifa over 10 years
    you do need to add this permission but not javascript related <uses-permission android:name="android.permission.INTERNET" />
  • klifa
    klifa over 10 years
    If you want to run native javascript code, you better check this official android link about web views LINK Start reading where it says "Enabling Javascript in WebView"
  • klifa
    klifa over 10 years
    And one more thing, the link in your post is broken