Search code examples
javascriptiosuiwebview

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


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?


Solution

  • Add this after your web view has loaded its content

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