View Full Version : writeln and write with a return character
w0lf42
05-24-2004, 06:35 PM
Is there any real difference between the following two code samples?
document.writeln("test message");and
document.write("test message\n");
Thanks
Willy Duitt
05-25-2004, 02:33 AM
The first example once rendered and you veiw source will show that each statement is on its own line. The second will display one long string.
w0lf42
05-25-2004, 12:51 PM
Actually, I was under the impression that the "\n" will cause a new line in the source code.
I was curious if there is any coding advantage to one over the other.
Thanks
agent002
05-25-2004, 01:17 PM
both codes are identical, as writeln() inserts a newline at the end automatically, and in the write() version it is inserted manually using \n. So, the advantage of the first one would be that you don't need to manually type the newlines if you're gonna have lots of them.
Willy Duitt
05-25-2004, 06:23 PM
\n will render and display a new line in a write statement(s) but the source will be one long string.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.