UIWebView: Can I disable the javascript alert() inside any web page?

ios, javascript, uiwebview

Solution

Add this after your web view has loaded its content

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

Problem

I am using `UIWebView` to load a URL. 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. Is there a way to disable this kind of popup window or JavaScript alert window?

Original source

Related problems