在 android webview 中禁用弹出窗口和警报框 [英] Disable popups and alertboxes in android webview

查看:52
本文介绍了在 android webview 中禁用弹出窗口和警报框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用启用了 javascript 的 webview,因为我的应用程序需要全职工作.我的问题是我需要在 web 视图中加载 url 时避免弹出窗口,有没有办法做到这一点?

I am using webview with javascript enables since it is required in my app fulltime. My issue is that I need to avoid popups while loading url's in my webview is there a way to do that?

我遇到了 onJsAlert() 方法,但根据 androids 文档

I came across the onJsAlert() method but as per androids documentation

 Tell the client to display a javascript alert dialog.
 If the client returns true, WebView will assume that the client will handle the dialog.
 If the client returns false, it will continue execution.

这不是我想要的.我想避免弹出窗口和警报框(包括提示和确认)任何帮助将不胜感激

and this is not what i want. I want to avoid popups and alert boxes (including prompt and confirm) any help would be appreciated

谢谢!

推荐答案

您可以尝试覆盖警报、确认等.也许可以添加一个标记来指示何时允许和何时不允许警报显示.JavaScript:覆盖alert()

You could try overriding alert,confirm, etc. Maybe add a flag on when to allow and when not to allow the alert to show. JavaScript: Overriding alert()

这篇关于在 android webview 中禁用弹出窗口和警报框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆