我试图从服务器加载HTML页面的页面包含链接到Android的SD卡.js文件的脚本。
Java的:
字符串URL =http://192.168.84.86:8080/test/maw/js_load_test.html;
this.loadUrl(URL);
js_load_test.html:
<脚本SRC =文件:///sdcard/test.js>< / SCRIPT>
我也试过:
<脚本SRC =文件:///android_asset/www/js/test.js>< / SCRIPT>
test.js文件存在和js文件的路径是正确的。 但在logcat的: 文件:///sdcard/test.js:
03-18 13:01:12.467:E / Web控制台(26189):不允许加载本地 资源:文件:///sdcard/test.js为:0
文件:///android_asset/www/js/test.js:
03-18 13:01:53.467:E / Web控制台(26189):不允许加载本地 资源:文件:///android_asset/www/js/test.js为:0
解决方案这可能有助于
https://groups.google.com/group/android-developers/browse_thread/thread/e20e87d2faf9ff41?pli=1#
webview.loadDataWithBaseURL(文件:/// android_asset /,HTML,text / html的,
UTF-8,NULL);
I'm trying to load an html page from a server the page contains a script that links to android sdcard .js file.
Java:
String url ="http://192.168.84.86:8080/test/maw/js_load_test.html";
this.loadUrl(url);
js_load_test.html:
<script src="file:///sdcard/test.js"></script>
I've also tried :
<script src="file:///android_asset/www/js/test.js"></script>
test.js file exists and js file path is correct. But in logcat: file:///sdcard/test.js:
03-18 13:01:12.467: E/Web Console(26189): Not allowed to load local resource: file:///sdcard/test.js at :0
file:///android_asset/www/js/test.js:
03-18 13:01:53.467: E/Web Console(26189): Not allowed to load local resource: file:///android_asset/www/js/test.js at :0
解决方案
This may help
https://groups.google.com/group/android-developers/browse_thread/thread/e20e87d2faf9ff41?pli=1#
webview.loadDataWithBaseURL( "file:///android_asset/", html, "text/html",
"utf-8", null );