A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 曹伟 中级黑马   /  2013-8-29 15:23  /  2117 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 就是我 于 2013-9-2 08:53 编辑

今天在测试一个旧项目时,有个问题,后台生成一个字符串(该字符串的长度超长的.)赋值给一个隐藏控件(inpu type="hidden"),然后js获得这个隐藏控件的值。<input id="txtUrl" type="text" value="act=Volume&SchoolId=121307,121318,121320,124302,124311,124313,124322,124333,124340,124501,124503,124504,124505,124506,124507,124508,124509,124510,124512,124514,124515,124516,124517,124518,124519,124520,124521,124523,124524,124525,124526,124527,124528,124529,124530,124531,124532,124534,124535,124536,124537,124538,124539,124541,124542,124543,124544,124545,124546,124547,124548,124549,124601,124602,124603,124604,124605,124606,124607,124608,124609,124610,124611,124612,124613,124614,124615,124616,124617,124618,124619,124620,124621,124622,124623,124624,124625,124626,124627,124628,124629,124630,124631,124632,124633,124634,124635,124636,124637,124638,124639,124640,124641,124642,124643,124644,124645,124646,124647,124648,124650,124651,124652,124653,124654,124655,124656,124657,124658,124659,124660,124661,124664,124665,124666,124667,124668,124669,124670,124671,124672,124673,124674,124675,124676,124677,124678,124679,124680,124681,124682,124683,124684,124685,124686,124687,124688,124689,124690,124691,124692,124693,124694,124697,124698,124699,124700,124701,124702,124703,124704,124705,124706,124707,124708,124709,124710,124711,124712,124713,124714,124715,124716,124718,124719,124720,124721,124722,124723,124724,124725,124726,124727,124730,124731,124732,124733,124734,124735,124736,124737,124738,124739,124740,124741,124742,124743,124744,124745,124746,124747,124748,124749,124750,124751,124752,124753,124754,124755,124756,124757,124758,124760,124761,124762,513501,513601,513602,513603,521301,521303,523301,523502,523503,523504,523601,523602,523603,523604,523605,523606,523607,533501,533502,533503,533504,533505,533601,533602,533603,533604,533605,533606,533607,533608,533609,533610,533611,533612,540301,543501,543502,543503,543504,543505,543601,543602,543603,543604,543605,543606,543607,543608,543609,551301,553501,553502,553503,553504,553505,553601,553602,553603,553604,553605,553606,553607,553608,553609,553610,553611,553612,553613,563301,563601,563602,563603,563604,573501,573601,573602,580301,581301,581302,583301,583501,583502,583503,583505,583601,583602,583603,583604,583605,583606,583607,583608,591501,593302,593501,593502,593503,593504,593505,593601,593602,593603,593604,593605,593606,593607,593608,593609,593610,593611,593612,593613,593614,603501,603601,603602,603603,613501,613502,613503,613504,613505,613601,613602,613604,613605,613606,613607,613608,613609,613610,613611,613612,613613,613614&ChidName=&CardId=&Close=&Status=&SchoolName=&year=0" />
            <input type="button" value="确定" />
            <script type="text/javascript">
                function fnClick() {
                    var obj = document.getElementById("txtUrl");
                    alert(obj.value); //后面的字符串被截断,出现省略号,不是隐藏控件所有的值
                    alert(obj.value.length); //2451(文本框存储的最大长度为2451???)
                }

            </script>

难道给文本框赋值的字符串长度最大为2451???



评分

参与人数 1技术分 +1 收起 理由
赵宗荣 + 1

查看全部评分

2 个回复

倒序浏览
把你上面的value复制到WPS文字里统计了下字数,确实是2451,并不是只能输入这么多字符,你修改下字符数加几个字符再运行就知道了。
IE中出现省略号,省略了部分字符的显示,但只是省略显示,并没有改变字符串。Chrome中没有省略,但弹出的窗口不可调宽度,导致看不到全部字符(任务栏透明刚好看到最后两行)。

我记得VS里WinForm的TextBox控件属性中有一项,规定的文本框可输入的字符数默认是3万多。
回复 使用道具 举报
黑骏马 发表于 2013-9-2 03:24
把你上面的value复制到WPS文字里统计了下字数,确实是2451,并不是只能输入这么多字符,你修改下字符数加几 ...

嗯,了解,谢谢!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马