New line in document.write

This may seem an easy thing to do but for some reason I cant get it to work.
all I want to do is write on seperate lines. this is what I have and it wont work:

<script language=“javascript” type=“text/javascript”>
document.write(‘line1’);
document.write(‘line2’);
</script>

This wont work either:

<script language=“javascript” type=“text/javascript”>
document.write('line1
');
document.write('line2
');
</script>

Nor will this:

<script language=“javascript” type=“text/javascript”>
document.write(‘line1 \r’);
document.write(‘line2 \r’);
</script>

or even this:

<script language=“javascript” type=“text/javascript”>
document.write(‘line1
\r’);
document.write(‘line2
\r’);
</script>

I am NOT new to javascript at all, and I really cannot understand whats going on here :frowning:

Thanks in advance.

document.write/writeln output HTML, not plaintext (into an HTML document, anyway). You know how to do a linebreak in HTML, right? :wink:

<script type=“text/javascript”>

document.write (
‘line1’ ,
‘<br />’ ,
‘line2’
);

</script>

Since document.write/writeln are functions, the fewer times you call them, the better (functions take time to set up, and then clean up). Both of these take multiple arguments, as above. Could also go:

document.write (‘line1<br />line2’);

…but people won’t think you’re as cool. :cool:

Of course, I knew It was going to be somthing totally obvious, Now i feel pretty stupid :stuck_out_tongue: Thanks a lot for your help though.

Just fyi… :smiley:

<pre>
<script>
document.write('line1
');
document.write('line2
');
</script>
</pre>

http://www.idocs.com/tags/linepar/_PRE.html