执行javascript脚本
UIWebView的实例方法:
- (NSString * _Nullable)stringByEvaluatingJavaScriptFromString:(NSString * _Nonnull)script
返回执行javascript脚本的结果
需要注意的是:JavaScript allocations are limited to 10 MB. The web view raises an exception if you exceed this limit on the total memory allocation for JavaScript.
实例:
获取当前的url
NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];