UIWebView:我可以在任何网页中禁用javascript alert()吗? [英] UIWebView: Can I disable the javascript alert() inside any web page?

查看:91
本文介绍了UIWebView:我可以在任何网页中禁用javascript alert()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UIWebView 来加载网址。

I am using UIWebView to load a URL.

在该网页的页面中,它使用 alert(无论msg)作为JavaScript。我的 UIWebView 会弹出一个窗口并显示该警告信息。

Inside the page of that URL, it uses alert("whatever msg") as JavaScript. My UIWebView will pop up a window and show that alert message.

有没有办法禁用这种弹出窗口或JavaScript警报窗口?

Is there a way to disable this kind of popup window or JavaScript alert window?

推荐答案

在您的网页视图加载其内容后添加此内容

Add this after your web view has loaded its content

[MyWebView stringByEvaluatingJavaScriptFromString:@"window.alert=null;"];

这篇关于UIWebView:我可以在任何网页中禁用javascript alert()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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