I have written a HTML page which has following code.
<div id="adsListContainer" style="margin: 5px;"> <textarea id="txtDesc" rows="20" cols="50"></textarea> <br /> <input id="txtCounts" value="0" size="8" /> <input type="button" value="Count" onclick="countChars()" /> </div>
上面的HTML被封闭在一个名为的test.html 文件,它被显示在Android的WebView控件。现在使用Java和web视图的使用loadURL()功能我执行JavaScript作为写的东西在文本区域如下code去。
The above html is enclosed in a file named test.html and it's being shown in android's WebView control. Now using Java and WebView's loadURL() function I am executing javascript as to write something in that textarea as following code goes.
javascript:document.getElementsByTagName("textarea")[0].value += 'anything goes here of not more than 50 chars';void(0);
甚至认为上述code ++工程,我叫了很多次,所以我可能在这个textarea元素插入7000+字符。
Even thought the above code works and I am calling it many times so I may insert 7000+ characters in this textarea element.
Java的code负责执行JavaScript是如下插入文本(HTML)到文本区域。
The Java code responsible for executing Javascript to insert text (HTML) into textarea is as follows.
int bStart = 0; int bEnd = 49; String description = "some huge description including html tags" int totalChars = description.length() - 1; while (bStart <= totalChars) { if (bEnd > totalChars) bEnd = totalChars; rv = "javascript:"; rv += "var tas=document.getElementsByTagName('textarea');"; // description rv += "if (tas.length>0) {"; rv += "var ta=tas[0];"; rv += "ta.value += '" + description.substring(bStart, bEnd) .replace("'", "'").replace('"', '"') + "';"; // description rv += "}"; webView.loadUrl(rv + "void(0);"); bStart += 50; bEnd += 50; }
虽然上面的code ++工程,但不完全。描述有 7245 字符,但它只能插入 6267 字符到网页的文本区域。
Although the above code works but not perfectly. The description has 7245 characters but it only insert 6267 characters into textarea of the web page.
有我丢失的东西?
我试图只与HTML + JavaScript的应用您的问题。请参阅这个小提琴。
I have tried to apply your issue only with HTML + JavaScript. Please see this fiddle.
正如你所看到的,这是正常工作。所以,我认为这个问题可能是更换转义序列。见你是从,这将增加说明变量的大小内环路改变转义序列字符。但是,totalChars具有是previously存储描述的大小的大小。所以,以后当你申请bStart&LT; = totalChars状态,它会计算,直到totalChars只(即已经小于当前大小)
As you can see, this is working properly. So, I think the issue may be with replacement of escape sequence characters. See that you are changing the escape sequence character from within the loop that will increase the size of description variable. But, totalChars has the size which is previously stored size of description. So, later when you apply "bStart <= totalChars" condition, it will count till the totalChars only (i.e. already less then the current size).
最后,你的描述有太多转义序列字符可能会产生这个问题。因此,更换整个字符串previously和放大器;然后添加子到你的Javascript。
Concluding, your description has too many escape sequences characters "may be" generating this problem. So, replace the whole string previously & then add substrings to your javaScript.
这可能会或可能不会解决你的问题,如果有任何一个又一个,还是。所以,请纠正我,如果我错了。
This may or may not solve your issue if there is any another one, still. So, please correct me if I am wrong.
感谢你。
相关推荐
周松勃(2023最新周松勃百科介绍)
山石榴(茜草科山石榴属植物)
南岛无核(2001年从海南省引进的品种)
Don't Let Me Be Lonely Tonight(Don't Let Me Be Lonely Tonigh
陈航(美国教育服务者)
邵芝岩毛笔(邵芝岩毛笔)
净WinForm的系统提示音在64位操作系统提示音、操作系统、系统、Wi
从.NET的DLL导出本地C函数?函数、NET、DLL
英语过去完成时的讲解 用法如下_过去完成时的用法 过去完成时的用
减肥用哪种跳绳好呢_减肥哪种跳绳好呢
什么是神经性心脏病_神经性心脏病的症状有哪些?
银行贷款攻略_2023年银行贷款政策
阑尾炎术后应该注意什么呢_专家为您介绍 阑尾炎术后的饮食注意事
如何保护我们脆弱的食道_孕妇如何挑选合适洗发水 ,孕妇如何保护好
六厘散的功效与作用_六星散的功效与作用
排卵日生男孩准确吗_排卵日同房易生男孩吗
石榴可延年益寿,可惜这几类人却没口福了!_8类人最易患口臭
金枪鱼水果沙拉的做法_金枪鱼鳄梨沙拉的做法
分享斑鸠的做法大全_水煮鱼做法大全
新车去甲醛的方法有哪些?_去甲醛最好的方法是什么
最新文章
谢雨欣(中国内地女演员、歌手)
马远良(2023最新马远良百科介绍)
赵少康(中国台湾地区媒体人)
浮动式联轴器(浮动式联轴器)
三和(刘克庄七言律诗组诗)
电流跟随器(电流跟随器)
从巴纽的BitmapImage。透明度问题。透明度、问题、BitmapImage
WPF中使用图像和图标图标、图像、WPF
从一月到十二月的对应英文缩写_9月英文缩写 一到十月缩写
羽泉奔跑——寻找未来的人生旅途_一、未来的道路并不平坦
鼻中隔偏曲手术多少钱_鼻中隔偏曲手术多久能恢复通气
月子米酒水做法_月子米酒水的做法
苹果x颜色_苹果X颜色
紫薯黑芝麻汤圆的做法_紫薯南瓜汤圆的做法
泰式辣蛋的做法_偷吃步泰式烤鸡的做法
跑步机与普通跑步的区别是什么_跑步机的正确跑步姿势是什么
布达拉宫旅游导游词(布达拉宫导游词精选)
最新《大明风华》观后感剧评5篇最新精选(2020《大明风华》最新剧
士官与军官有什么不同?(士官相当于什么级别军官)
男生夏天穿什么裤子可以既不热又显的得体时尚好看(男生夏天穿什么