Is there a length limit on the parameters of js? Found no more than 2083 characters

  • 2020-03-30 02:40:28
  • OfStack

A common javascript function with only one entry parameter
 
function test(info) 
<img none';="" document.getelementbyid('_20_37_open_text').style.display="none" ;="" document.getelementbyid('_20_37_closed_image').style.display="inline" document.getelementbyid('_20_37_closed_text').style.display="inline" ;"="" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" style="border: 0px; max-width: 100%; ">{ 
alert(info); 
} 

The page is generated with aspx code, the entry parameter to the test function may be a long string, and the page is constructed with many of the tags shown below based on a data set.
 
<a href="javascript:test('ssssss... Here is very long ..ssssss')">test</a> 

After the page is generated, some links can be clicked, some can't. A rough treatment of the value of the entry parameter with substring shows that it cannot exceed 2083 characters. Is there a length limit on function arguments in js? Never heard of it. There were no reports of this.

Try < A> Label, < Button> Then call the js function in the clik event, the parameter passed the full length, found no errors...

This Epiphany turned out to be < A href> The cause of the trouble, < A href> Get is used to pass the parameter, and the url has a length limit of 2k no matter what. Even in this case, the js function can not be dropped more than.

Related articles: