android WebView加载不出网页内容This request has been blocked; the content must be served over HTTPS.
来源:互联网 发布:javascript游戏 编辑:程序博客网 时间:2024/05/16 06:28
项目中遇到加载网页的时候都出现加载不出内容或者内容不全。但是QQ浏览器或者系统浏览器都没问题,也就是还是自己写的Webview处理有问题。总结了一下大概下面两个问题引起:实际问题可以参看Android Studio 打印的Log,会有Webview的追踪内容为chromium: xxxxxx.
情况一:
无法加载JS内容写的页面。
设置setDomStorageEnabled,可能是webview前端写的一些代码便签不支持。
WebSettings settings = webview.getSettings();settings.setJavaScriptEnabled(true);settings.setDomStorageEnabled(true);
情况二:
出现部分内容显示部分内容不显示,打印日志大概如下:
chromium: [INFO:CONSOLE(15)] "Mixed Content: The page at 'https://dihao.moxz.cn/' was loaded over HTTPS, but requested an insecure image 'http://sm.domobcdn.com/hm/2017/landing/img/dihao/p5.jpg'. This request has been blocked; the content must be served over HTTPS.", source: https://sm.domobcdn.com/hm/2017/landing/js/swiper.3.4.2.min.js (15)
这个是加载的地址是https的,一些资源文件使用的是http方法的,从安卓4.4之后对webview安全机制有了加强,webview里面加载https url的时候,如果里面需要加载http的资源或者重定向的时候,webview会block页面加载。需要设置MixedContentMode,解决此问题的代码如下:
WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); }
- android WebView加载不出网页内容This request has been blocked; the content must be served over HTTPS.
- android WebView加载不出网页内容This request has been blocked; the content must be served over HTTPS.
- This request has been blocked; the content must be served over HTTPS.
- this request has been blocked;the content must be served over https
- HTTPS调用百度地图API提示“BMap未定义, This request has been blocked; the content must be served over HTTPS.,was
- Mixed Content: The page was loaded over HTTPS,blocked the content must be served over HTTPS.
- android webView加载页面时显示出全部网页内容
- android webView加载页面时显示出全部网页内容
- 对于android WebView加载不出Html5网页的解决方法
- android webview加载https网页
- Android:Content has been consumed
- Android webview 加载https网页显示空白
- Android webview 加载https网页显示空白
- Android WebView加载https网页(亲测)
- Android webview 加载https网页显示空白
- Android WebView 不能加载出全部网页
- webView加载Https网页
- Android webview 加载不出视频
- vitamio基本用法
- java英文金曲大赛
- vs 中编译和生产的区别
- equals()
- C-G1. 修改路由器密码 ❀ 1900 ❀ 思科 (CISCO) 路由器
- android WebView加载不出网页内容This request has been blocked; the content must be served over HTTPS.
- 系统的简单注解
- angluar的上拉刷新
- Python:如何将字符串作为变量名
- 获取与指定时间间隔一定周期的时间
- nginx超时的问题(*52081 upstream timed out)
- code[vs] 3117 高精度练习之乘法
- 数据结构1
- 一个jsp页面引入另一个jsp页面的三种方式 及静态引入和动态引入的区别