开发者

How can I automatically click cancel when an OK-Cancel alert pops up in the UIWebView?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜