原生向H5传值的话,约定空方法进行接收
[self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"box(%d)",delegate.isLogined]];
相反:
webView代理方法里:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
}
截取当前发生行为的链接
NSString *requestString = [[request URL] absoluteString];
前端约定点击跳转链接进行判断是否允许发生跳转 或者跳回原生App
if( navigationType == UIWebViewNavigationTypeOther ) {
if ([requestString hasPrefix:[NSString stringWithFormat:@"%@/product_details/BuyPageCommon.aspx",BASE_URL]]&&delegate.isLogined) {
}
}