I'm having a problem with my UIWebView for my iPhone App... I am getting an alert thrown up with OK-Cancel b开发者_Python百科utton options, and I don't want the user to see this... But the web page automatically pops up an alert. How can I programmatically detect the Alert was thrown up and how do I click the cancel button on the alert?
Thanks, Matt
In a class derived from UIWebView, implement these methods:
- (void)webView:(id)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {}
- (BOOL)webView:(id)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame { return NO; }
While not strictly documented, you are not actually calling anything so it may be accepted.
Otherwise, you will have to find the javascript in the loaded page that is putting up the alert and remove it.
精彩评论