[thelist] Javascript and breaking within strings

Christian Heilmann codepo8 at gmail.com
Mon Apr 18 16:33:14 CDT 2005


> [snip]
> Can you make a multiline block of text a string variable, without
> breaking it up?
> 
> WHAT I WOULD LIKE TO DO (gives me a "unterminated string literal"
> error):
> theVar = "Line 1 text<br>
> Line 2 text<br>
> Line 3<br>";
> 
> WHAT I AM FORCED TO DO:
> theVar = "Line 1 text<br>";
> theVar += "Line 2 text<br>";
> theVar += "Line 3 text<br>";
> 
> Thanks so much for any clarification.
> [/snip]
> 
> You can use a backslash IIRC
> 
> theVar = "Line 1 text<br>\
> Line 2 text<br>\
> Line 3<br>";

Funky. Haven't seen that yet. It is dirty though, as the resulting
string does contain the linebreaks and tabs and you'll need to clean
them out again.


-- 
Chris Heilmann 
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/  
Binaries: http://www.onlinetools.org/


More information about the thelist mailing list