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
and this one for webviews
Author by
user3235860
Updated on August 21, 2022Comments
-
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.
-
user3235860 over 10 yearsI tried that already but it's not working. Do i need special permissions or something like that?
-
klifa over 10 yearsyou do need to add this permission but not javascript related <uses-permission android:name="android.permission.INTERNET" />
-
klifa over 10 yearsIf 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 over 10 yearsAnd one more thing, the link in your post is broken