New Line using document.write() and document.writeln()
I am trying to write a bunch of text onto a new document using document.write() and somehow need to format it to include line breaks.
I have tried including \n, and it does not work. I have also tried document.writeln() and that also does not work.
From what I have found on the Internet, one (if not both) of those methods should have worked..
Last edited by irishman101; 07-16-2010 at 09:04 AM.
If you want a new line in HTML, you use <br>. That will work regardless, but depending on the content, maybe you should use <p> for a paragraph or another HTML tag.
\n is new-line in the sense that after the full stop in my last sentence there is a new line. HTML ignores white space, so that's irrelevant when printing to the browser window.
I have found advice, that using document.write('<pre>') before the other document.writeln() and document.write('</pre>') at the end formats the text nicely.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread