//当webView 加载的html 页面中有加载完 需要运行的js 会报错 [blocked] The page at *.html was not allowed to run insecure content from
//原因为 客户端加载完运行的js 请求的https URL 为不可信任的地址 被webView拦截
//1.换成 NSURLConnection 请求 接口即可 2.请求的https URL 为可信任
解决办法 用NSURLSession 进行重定向的时候会报错
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//会引起错误的请求方式
/*
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];
__weak typeof(self) weakSelf = self;
NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
}];
[task resume];
*/
//临时解决方案
NSURLConnection *connection =[[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];
return NO;
}
[blocked] The page at *.html was not allowed to run insecure content from
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Day 12 神句文档 The team contends that these bear more than a...
- andorid studio 运行正常,通过命令行react-native run-android 报错。如图: ...