开发者

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

开发者 https://www.devze.com 2023-01-06 06:22 出处:网络
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

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

精彩评论

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

关注公众号