document.write xml prolog

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

If both a strict XHTML doctype tag and an XML prolog are written into a popup using separate document.write commands, Mozilla/Firefox/Gecko based browsers will revert to quirks mode, instead of standards compliant mode.

Test page. Workaround is not included.
Reported by TarquinWJ.

Mozilla | Reported on 18 November 2004.

Comments

(Add your own)

Posted by Patrick Schriner on 23 November 2004

1

Afaik document.write is forbidden for XHTML. Only DOM operations are allowed.

Posted by Dante Evans on 24 November 2004

2

But why? That doesn't make any sense; there is absolutely no reason document.write should be forbidden.

Posted by porge on 24 November 2004

3

Why document.write() doesn't work in XML:
http://ln.hixie.ch/?start=1091626816&count=1

Posted by minghong on 25 November 2004

4

document.write and innerHTML can results in invalid XML. So for me, it makes sense to disabled these non-DOM methods in XML mode.

Posted by TarquinWJ on 24 December 2004

5

document.write is forbidden in documents served with an XML content type HTTP header (text/xml or application/XHTML+XML etc). This is because XML based documents can use the browser's more efficient XML parser, and not have to cope with error handling as with normal HTML documents. document.write _is_ permitted in XHTML documents served as HTML (text/html content-type header).

However, that is not the issue. The fact is that dynamically writing popup contents does not use a content-type header, so at a guess, the browser should use whatever the content-type was for the originating document.

In the case of the document being served with ther text/html content-type, this should work, but it doesn't, because the gecko engine only checks for the document type in the first data chunk. Since the doctype tag is in the second chunk, it fails, and falls back to assuming a transitional doctype, even though the second chunk contains a strict doctype. This is recognised as a bug by the Mozilla developers.

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes