Has a javascript variable a maximum length?

Hi all,

Wondering if there is a maximum length for a javasript variable.

I am asking this because i have problems with a vertical javascript scroller.

The content is parsed by php, but somehow if php adds a new line the scroller doesn’t work. if all the parsed content is on one line it works great.

Any ideas how come???

Could guess, but might be better to see what’s what. And, no, a JS variable is just a location in memory which can hold a lot of data - it’s not unlimited, but that’s unlikely to be the issue.

Well here is more.

Doing this step by step to see where i go wrong. I ‘parse’ the content for the javascript variable by php.

This is how i want it to parse


var content='<a href="somefile.php" target="_parent">blah</a><br><br><a href="somefile.php" target="_parent">blah</a><br><br><a href=""someefile.php" target="_parent"> </a><br><br>';

but my php parsed it like


var content='<a href="somefile.php" target="_parent">blah</a><br><br><a href="somefile.php" target="_parent">blah</a><br><br><a href=""someefile.php" target="_parent"> 
</a><br><br>';

hence, the breakline between …target=“_parent”> and </a>
Somehow the javascript scroller doesn’t work. So i removed the “newline” so all the content of var content is on one line and then it works.

So is there a max length of a javascript variable before it starts on a new line.

I hope it is a little bit clearer

Sorry, misunderstood you. The problem isn’t that the string is too long, or that it’s not all on one line - it’s that it’s unterminated. If you want to spread out a string over multiple lines, either each line must be properly terminated (", ') or you’ll need an escape character - a backslash - to hide the line feed. All JS parsers will insert line-termination semicolons if your string just stops cold. These work:


.....someefile.php" target="_parent">' +
'</a><br><br.....

var content = '.....someefile.php" target="_parent">';
content += '</a><br><br.....

.....someefile.php" target="_parent">\\
</a><br><br

Really an issue with your PHP.

hmm,

thx, adios for clearing things up.

Gonna tweak my php code. The strange thing with my php code is it works when the parse content isn’t long and it doesn’t work when it gets longer. That why i thought maybe it is a javascript issue.

content +=… didn’t think about that.

Grtz