简体   繁体   English

JavaScript字符串限制?

[英]JavaScript String Limit?

I have a question concerning my javascript code (Sorry my english is not that good). 我有一个关于我的JavaScript代码的问题(对不起,我的英语不太好)。 The code works, however, with only one data entry, the string in the HTML which results, gets cut off near the end (last few characters seems to be dropped, the length of the character drop is consistent). 该代码有效,但是只有一个数据输入,结果是HTML中的字符串在结尾处被切断(似乎删除了最后几个字符,字符下降的长度是一致的)。 I'm wondering if I'm hitting a string limit or something similar. 我想知道我是否达到了字符串限制或类似的限制。 The problem data entry (which gets stored in the var gDef below) is 4110 characters long which doesn't seem like it should be a problem... Help? 问题数据条目(存储在下面的var gDef中)长4110个字符,这似乎不应该是问题...帮助吗?

The following is my code: 以下是我的代码:

gI = document.gForm.gLinks.options[document.gForm.gLinks.selectedIndex].value;

definition = "";        

gWord = (g[gI].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);

gDef = (g[gI].getElementsByTagName("DEFINITION")[0].childNodes[0].nodeValue).replace(/\n/g,'<br />').replace(/\[/g,'<').replace(/\]/g,'>');

definition += ("<div class=\"word\">");
definition += ("<h3>"+gWord+"</h3>");
definition += ("<div class=\"definition\">"+gDef+"</div>");
definition += ("</div>");

document.getElementById("showGlossary").innerHTML = definition;

Are you sure that the browser isn't hiding the string partially? 您确定浏览器没有部分隐藏字符串吗? The CSS property text-overflow can cause this. CSS属性text-overflow可能导致这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM