iOS 获取UIWebView上面的按钮点击事件

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

if ([request.mainDocumentURL.relativePath isEqualToString:@"/alert"]) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"本地代码执行" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];

[alert show];

return false;  //执行本地代码,返回false不让网页读取网络资源

}

return true;  //为yes加载内容,否则不

}

你可能感兴趣的:(iOS 获取UIWebView上面的按钮点击事件)