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.782.220 m and Safari 5.0.5, it seems to be rendered as text/html, ignoring the encoding specification in the open() call. By saying that it seems to be rendered as HTML, I mean that each instance of white space has been replaced by a single space character. In Firefox 3.6, Opera 11.51 and Internet Explorer 8, this renders correctly. These results are consistent across Windows and Mac OS/X.
I've searched stackoverflow with [chrome]+text/plain, [safari]+text/plain and [webkit]+text/plain, and saw no hits. I've also searched for text/plain in the chrome and webkit bug reporting sites, and seen no similar reports.
Has anyone else run across this, or have any suggestions on how to get my data to render correctly on webkit-based browsers?
A simple demo page for this problem is:
<html><head>
<script type="text/javascript">
function displayInNewWindow() {
var win;
var doc;
win = window.open("", "WINDOWID");
doc = win.document;
doc.open("text/plain");
doc.write("Line1\tField2\tField3\nLine2\tField2\tField3\n");
doc.close();
}
</script>
</head>
<body>
<script type="text/javascript">displayInNewWindow();</script>
<p>We're here!</p>
</body>