javascript在iOS 8的uiwebview中注入
作者:互联网
我正在iOS 8预览版2中测试我的项目.
现在我面临有关uiwebview的两个问题
我使用以下代码注入脚本
NSString *jsCLOSE_WINDOW = @"function CLOSE_WINDOW(){
document.location ='mySchema://FUNCTION=CLOSE_WINDOW';
}";
[self.webView stringByEvaluatingJavaScriptFromString:jsCLOSE_WINDOW];
在“-(void)webViewDidFinishLoad:(UIWebView *)webView”中
并得到回应
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
它在iOS 7.1和更早版本中可以正常工作.
但是在iOS 8预览2中
1.document.location = 'mySchema://FUNCTION=CLOSE_WINDOW';
seems not working anymore? I can't get the response in "shouldStartLoadWithRequest" 2.in iOS 7.1 and earlier every time page redirect to another
(ex:page1.html -> page2.html -> page3.html)
"webViewDidFinishLoad" will be triggered in every page.
But, in iOS 8 preview 2 it only triggered once in first page
我该如何解决?还是iOS 8中的新限制?
有任何想法吗?欣赏.
解决方法:
经过大量搜索.
最后,我找到了解决方案,
只需点击链接link here.
问题是javascript.
将javascript重写为示例样式
并且它现在可以在iOS 8(经过Beta3测试)中正常工作.
标签:objective-c,ios8,uiwebview,javascript 来源: https://codeday.me/bug/20191029/1959753.html