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

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

问题描述

我正在使用带有JavaScript的webview,因为它是我的应用程序全天候需要的。
我的问题是,我需要避免弹出窗口,而在我的web视图中加载url的是有办法做到这一点?



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

 告诉客户端显示一个javascript警报对话框。 
如果客户端返回true,WebView将假定客户端将处理该对话框。
如果客户端返回false,它将继续执行。

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



谢谢!

您可以尝试覆盖警报,确认等。
JavaScript:覆盖警报()


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?

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

Thanks!

解决方案

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天全站免登陆