http://my.oschina.net/u/566401/blog/92659
1. 在webview读取网页中,在需要点击的url中添加onclick()事件
window.location="/alert"; //引号中可以改成自己想设置的字符
2.给本地webView添加 UIWebViewDelegate
添加如下方法:
01 | -( BOOL )webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType |
03 | if ([request.mainDocumentURL.relativePath isEqualToString:@ "/alert" ]) { |
04 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@ "本地代码执行" delegate:self cancelButtonTitle:@ "确定" otherButtonTitles: nil]; |