Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
861 views
in Technique[技术] by (71.8m points)

cordova - android Not allowed to load local resource:file:///android_asset

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 ); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...