js与oc的交互
2016-11-08 本文已影响0人
夏夏的一些事
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
// NSLog(@"1---%@",request.mainDocumentURL.relativePath);
if([request.mainDocumentURL.relativePath hasPrefix:@"//data="])
{
/* 暂时没有参数要处理
NSString * json = [request.mainDocumentURL.relativePath stringByReplacingOccurrencesOfString:@"//data=" withString:@""];
NSDictionary * dic = [json JSONValue];
NSLog(@"2---%@",json);
*/
[self back];
return NO;
}
return YES;
}
function toApp() { window.location = "http://toIOSApp://data={'data1':'aaa','data2':'bbb','data3':'ccc'}"; }