美文网首页
[blocked] The page at *.html was

[blocked] The page at *.html was

作者: luckycoder | 来源:发表于2017-11-09 16:41 被阅读0次
    
    //当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

          本文链接:https://www.haomeiwen.com/subject/anhmmxtx.html