I am creating a page from JavaScript using document.open(\"text/plain\") and document.write(). The text to be rendered is multiple lines of tab separated text. In Chrome 13.0.7
You need to use the <pre>
tag around your content in order to get it to render the way you want it to. The browser is still going to treat the document you're writing the code into as an HTML document. The <pre>
tag will tell the browser to render the content a pre-formatted text, which will honor all line breaks and white-space characters.
You should drop the parameter to open() since it's not supported in other browsers, and prefix your parameter to the first write() with '<PLAINTEXT>'
, a beyond-deprecated tag from the depths of HTML history which does exactly what you want (it has no closing tag.)