参考:
[_webView stringByEvaluatingJavaScriptFromString:@"methodName();"];
NSString* returnValue =[theWebView stringByEvaluatingJavaScriptFromString:@"myFunction('pass your parameter')"]; One can use JavaScriptCore framework to run JavaScript code from Objective-C.#import <JavaScriptCore/JavaScriptCore.h>JSContext *context = [[JSContext alloc] init];[context evaluateScript: @"function greet(name){ return 'Hello, ' + name; }"];JSValue *function = context[@"greet"];JSValue* result = [function callWithArguments:@[@"World"]];[result toString]; // -> Hello, WorldHere is a demo: