self.viewController.webView stringByEvaluatingJavaScriptFromString does not work

人盡茶涼 提交于 2019-12-06 15:09:15

On cordova-ios@3.x you should be able to do:

[self.webView stringByEvaluatingJavaScriptFromString:jsString];

On cordova-ios@4+ you will need to cast the Webview class as it also supports WKWebView:

if ([self.webView isKindOfClass:[UIWebView class]]) {
    [(UIWebView*)self.webView stringByEvaluatingJavaScriptFromString:jsString];
}

May want to try NSString* jsString = [NSString stringWithString:@"alert('ok');"];[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString]; or NSString* jsString = @"alert('ok');"[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!