Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Max Length Of a Javascript String..

Status
Not open for further replies.

PatrickGreen

Programmer
Mar 11, 2003
35
US
To All:

Is there a max length of a javascript string when doing string concatenation (+). When I get to a length of 1957, the string just cuts off????

Any help would be greatly appreciate,
TIA,
Patrick
 
I'm pretty sure there's no ordinary limit. One of my applications regularly manipulates strings of thousands of characters...

Cheers,
[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
a quick test:
var1="...a string of 2700 chars..."
document.write(var1.length);

this works...
 
To All:

Thanks for the input. I found out where my error was.

Thanks Again...
 
<html>
<head>
<title>String length</title>
</head>
<body>

<div id=&quot;size&quot;>
Here
</div>

<a href=&quot;javascript:addToString()&quot;>see how much can it grow?</a>

<script>

var max = 10000;
var myString = &quot;&quot;;

function addToString()
{
for (var x = 0; x < max; x++)
{
myString += &quot;M&quot;
}

document.getElementById('size').innerHTML = &quot;size of the string : &quot; + myString.length + &quot; characters&quot;;
}

</script>
</body>
</html>

I wrote this test just for fun. It seems that I can click on the link to get passed 1 000 000 000 characters in a Gecko based browser with no problem but my IE6 (WinXP) is having trouble between each sets starting at around 1 000 000. Can anyone tell me if this is the same on their machine? Does Phoenix, Mozilla or Netscape handle this better on your machine as well? Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top