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.
As i see, assets files can't be loaded from remote web page...
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+"')");
First line: define a function, second line - prepare long string, third one - call defined function with very long string argument.
It works perfectly. As a result i seeing JS alert saying: "80002 ...xx"
As you can read here webView.loadUrl("javascript:wave()");
only calls a JS methods, not inject them to HTML page. Maybe you want to use webView.loadData()
or webView.loadDataWithBaseURL()
methods? Or have I misunderstood you?
By default the loadURL makes a get request which is having a limit of 254 characters. That why the problem is.