htmlCode
=
下面是htmlCode中的值
<html>
<head>
<script><script
type=\"text/javascript\"
src=
\"ww
w
.fo
ok
ii.c
om/js/jquery.js\"
/></script>
</head>
<body></body>
</html>
webview中用loadData(htmlCode)
//webview加载html代码
把这个jquery.js文件放到了assets文件夹下
src="file:///android_asset/xxx.js"
并且要用
String
baseUrl
=
"file:///android_asset"
WV_View.loadDataWithBaseURL(baseUrl,
strHtml,
"text/html",
"utf-8",
null)
项目中出现一个兼容性问题,Oppo、Vivo手机Webview加载本地JS、CSS不执行
一、前提 OV手机低于android 7.0版本,
二、baseUrl是Https的
三、使用: webView.loadDataWithBaseURL(baseUrl, html, "text/htmlcharset=UTF-8", "utf-8", null) 方法加载
解决办法
还有一种不太好的解决办法: webView.loadDataWithBaseURL(null, html, "text/htmlcharset=UTF-8", "utf-8", null)
但是这样会导致页面内不是完整路径的图片找不到。