Entry
How can you put in a newline character within a string constant without getting the "Unterminated string constant" Javascript error
Jan 12th, 2001 06:32
Juergen Thelen, Rawlie Poulson,
For javascript driven html outpout just use the <br> tag
var s = "line1<br>line2<br>line3";
document.write(s);
This should work in any browser (<br> tag introduced with HTML 2.0).
Inside alerts you can use \n to force a new line
var s = "line1\nline2\nline3";
alert(s);
This should work in any browser on windows/mac os platforms at least.
Never tested it on other platforms...
Hope this helps.
Juergen