Closed Bug 8146 Opened 25 years ago Closed 25 years ago

document.writeln is not inserting a newline

Categories

(Core :: DOM: Core & HTML, defect, P3)

x86
Windows 98
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: jcarpenter0524, Assigned: vidur)

Details

- Run the following code:

<HTML><HEAD></HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
document.writeln("Some text.");
document.writeln("Some more text that should be on the next line.");
</SCRIPT>
</BODY>
</HTML>

- Notice that even though I am using "writeln" the text is all on the same line.
QA Contact: gerardok → janc
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
This is not a bug - check behavior in Navigator 4.x. The newline is only
significant when you're writing a plaintext document. To actually get a newline
in the HTML case, you need to include a <P> or <BR> element.
Jan, didn't we already have this conversation before? I seem to remember
discussing it a while ago.
Status: RESOLVED → REOPENED
We talked about using the write(); method with regard to whitespace in the
testcase, but not about writeln();

In section "2.4. Objects related to HTML documents" at this URL:
http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html
W3C defines the writeln(); method as:
"Write a string of text followed by a newline character to a document stream
opened by open(). The text is parsed into the document's structure model."
Doesn't that mean that in HTML it should add a return?  (My appologies if I'm
missunderstanding the spec.)
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
It adds the newline to the document SOURCE.
The specs you quoted clearly says that. (It adds the text to the parser input.)
Depending on the context, it may be treated as breaking space or line break.
Try the following:

<HTML><HEAD></HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
document.writeln("<pre>");
document.writeln("Some text.");
document.writeln("Some more text that should be on the next line.");
document.writeln("</pre>");
</SCRIPT>
</BODY>
</HTML>

In this case you do get a line break, which confirms that document.writeln
does put the newline to the source, as the standard says it should.
Status: RESOLVED → VERIFIED
Thanks, I didn't understand the spec.
can you (hyp-x@inf.bme.hu) please point me to the specific location in the spec
where it states "It adds the newline to the document SOURCE." I am unable to
locate that little tidbit of data -- thanks
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.