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.
This site is no longer maintained. I’m sorry, but it’s just too much work for too little return. You can continue to browse old bug reports, though.
Search reports by browser:
2 Posted by Dante Evans on 24 November 2004 | Permalink
But why? That doesn't make any sense; there is absolutely no reason document.write should be forbidden.
3 Posted by porge on 24 November 2004 | Permalink
Why document.write() doesn't work in XML:
http://ln.hixie.ch/?start=1091626816&count=1
4 Posted by minghong on 25 November 2004 | Permalink
document.write and innerHTML can results in invalid XML. So for me, it makes sense to disabled these non-DOM methods in XML mode.
5 Posted by TarquinWJ on 24 December 2004 | Permalink
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.
1 Posted by Patrick Schriner on 23 November 2004 | Permalink
Afaik document.write is forbidden for XHTML. Only DOM operations are allowed.