penders - 9:23 am on Aug 3, 2011 (gmt 0)
Hi alt131, thanks for the reply, and very thorough as usual!
...document.writeIn should generate a new line at the end of each statement. Best I can tell, ie8 is recognising some character at the end of each expected "line", but not translating/acting on that as a newline.
Just to add, this 'problem' shows itself with document.write() as well, when no newlines are output. Also (another side issue), IE7 appears to have trouble with writeln(), in that it treats it exactly the same as write(), without newlines! incidentally, that should be the only difference between write() and writeln() - the convenience of a newline appended to the end of the output.
Couldn't reproduce the issue with block elements such as <p>.
Your absolutely right. My "display:block" comment is a bit wrong. It is definitely related to the <pre> element. The <pre> element needs to be on the outside. Yes, I'm using the <pre> element to preserve the white-space, necessary for the newlines output with writeln(). This is where my "display:block" came from....
This causes the problem: Just the <pre> element
This resolves the problem: An inner inline element
This causes the problem again: Make the inline element display:block (This is actually how I found the problem in the first place.)
(Or, substitute the <samp style="display:block;"> with a <p> and this also causes the problem again. Although this is invalid HTML and so should perhaps be discounted.)
In terms of separating the <pre> and <script> elements by a space (or newline), and seeing that reflected in the formatting, I believe that is correct.
Yes, I agree. I didn't intend to mean that it was wrong - just that it was undesirable.
What fascinated me is that clicking on the first line expands the element to display all the output, formatted exactly as desired!
Yes - I hadn't noticed that! That is weird! Or even just selecting the problematic area. Including Ctrl+A (to select the whole page).