@interface UIWebView(JavaScriptAlertOfUIWebView) - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect)frame; - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect)frame; @end @implementation UIWebView(JavaScriptAlertOfUIWebView) - (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect)frame { NSLog(@"%@",message); if (sender.delegate && [sender.delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) { NSError *error = [[NSError alloc]init]; [sender.delegate webView:sender didFailLoadWithError:error]; } // UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil]; // [alertView show]; } - (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(CGRect)frame { return YES; } @end