js与oc的交互

- (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'}";     }

你可能感兴趣的:(js与oc的交互)