views:

52

answers:

3

Hi,

I am loading an External web page in the UIWebView. When the web page loads, there is an Alert Box ( with OK and Cancel buttons) with some Suggestion/ Info about the web page. I want to block this Alert Box when the web page loads in the UIWebView component in my iphone app. How can I implement in my code?

Thanks in advance.

Kind Regards, Mahesh

A: 

Are you the one 'in charge' of this external web page? If that's the case, you could do something like this:

Make the UIWebView load externalpage.html?noalert instead of externalpage.html. Then on externalpage.html you can check whether this query string variable exists, and only show the alert() if it doesn't:

if(!document.location.search || document.location.search.substring(1) != 'noalert') {
    alert('Boo!');
}
Douwe Maan
A: 

Hi, Thanks for your reply. I am not in-charge for the external web page(but i could ask the concern web page owner to do the changes with respect to following requirement). The requirement is that the Alert Box (used to tell about my iphone app) could be shown when we view the web page in iPhone Safari browswer , but not in UIWebView in which I am using the same web page) of my iphone app. I am using the same web page url both in iPhone Safari and in my iPhone app with UIWebView. So requirement is show the Alert box when we view the web page in iPHone Safari and don't show the Alert box when we view the same web page in iPhone app (within in UIWebView). Hope I have clearly explained my requirement. Please give any solution for this.

Mahesh
+1  A: 

using stringByEvaluatingJavaScriptFromString: method you can change anything you want on the page with any javascript you provide, so you can overload or replace the alert function to do what you want

Alexander Voloshyn