我要转让本地资源到一个页面上,从远程服务器加载。
I want to "transfer" local resources to a page, loaded from remote server.
我想要做的财产以后是这样的:
I want to do somthing like this:
webView.loadUrl('http://my.server.com/page.html');
webView.loadUrl('javascript:function someLong(){}function codeHere(){}....');
这是为节省带宽,并减少加载时间。
This is for saving a bandwidth and reduce loading time.
我看到的,资产的文件不能从远程Web页面加载中...
As i see, assets files can't be loaded from remote web page...
看起来是没有限制的,或者是非常大的。我已经做了简单的code一些测试
Looks like there is no limit or it is very large. I've done some tests with simple code
webView.loadUrl(
"javascript:function a(s){alert(s.length + ' ' + s.substring(s.length-5))}");
String repeated =
String.format(String.format("%%0%dd", 80000), 0).replace("0", ".") + "xx";
webView.loadUrl("javascript:a('"+repeated+"')");
第一行:定义一个函数,第二行 - prepare长字符串,第三个 - 调用自定义的函数很长的字符串参数
First line: define a function, second line - prepare long string, third one - call defined function with very long string argument.
它完美。结果我看到JS警告说:80002 ...... XX
It works perfectly. As a result i seeing JS alert saying: "80002 ...xx"