javascript 如何在android webview中显示javascript弹出窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21354551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to display javascript popup in android webview
提问by user3235860
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.
是否可以在 android webviewer 上打开一个 javascript 弹出窗口,代码像谷歌的这个例子一样?如果是,如何?我不希望背景中的原始页面被关闭,它必须是图片上的弹出窗口。
回答by Display name
See answers to this question:
请参阅此问题的答案:
JavaScript alert not working in Android WebView
JavaScript 警报在 Android WebView 中不起作用
The answer from Stephen Quan is to just set the default webChromeClient
Stephen Quan 的答案是设置默认的 webChromeClient
mWebView.setWebChromeClient(new WebChromeClient());
回答by klifa
You can allow javascript and opening windows from javascript in a webview. Just set this settings
您可以在 web 视图中允许 javascript 和从 javascript 中打开窗口。只需设置此设置
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
Be careful though because enabling javascript on your app webview can bring some serious security issues
不过要小心,因为在您的应用程序 webview 上启用 javascript 会带来一些严重的安全问题
check this links
检查这个链接
and this one for webviews
而这个用于 webviews