Why HTML1113: Document mode restart from IE9 Standards to Quirks
Asked Answered
R

2

23

I open a webpage in IE9 - and all of a sudden the document mode switches to Quirks mode. The page itself is dead simple - no doctype, no meta tag, just a piece of (test purpose) javascript inside the xslt forming the page.
See http://home.arcor.de/martin.honnen/xslt/test2012041901.xml using the mentioned xsl on the same location. For convenience I copied the contents below.

Page content is

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test2012041901.xsl"?>
<test/>

And xsl contains

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
  xmlns:ms="urn:schemas-microsoft-com:xslt"
  xmlns:my="http://example.com/my"
  exclude-result-prefixes="ms my">

  <xsl:output method="html" version="5.0"/>

  <ms:script language="JScript" implements-prefix="my">
  <![CDATA[
  function tokenize (input) {
    var doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
    var fragment = doc.createDocumentFragment();
    var tokens = input.split(';');
    for (var i = 0, l = tokens.length; i < l; i++)
    {
      var item = doc.createElement('item');
      item.text = tokens[i];
      fragment.appendChild(item);
    }
    return fragment.selectNodes('item');
  }
  ]]>
  </ms:script>

  <xsl:template match="/">
    <html>
      <head>
        <title>Example</title>
      </head>
      <body>
        <h1>Example</h1>
        <ul>
          <xsl:apply-templates select="my:tokenize('Kibology;for;all')"/>
        </ul>
      </body>
    </html>
   </xsl:template>

   <xsl:template match="item">
     <li>
       <xsl:value-of select="."/>
     </li>
   </xsl:template>

</xsl:stylesheet>

Why does this happen? Is it an internet options setting that triggers this? How can I prevent quirks mode being automatically chosen in IE9?
And: earlier with the same page this automatic quirks mode did not occur - I must have done something, like a setting change, maybe even just forth and back to the original value again, which led to this changed behavior. But what?

F12 developer tools show the following in the console:

XML5001: Applying Integrated XSLT Handling. 
HTML1114: Codepage unicode from (UNICODE byte order mark) overrides conflicting codepage utf-8 from (10) 
test2012041901.xml
HTML1113: Document mode restart from IE9 Standards to Quirks 
test2012041901.xml
HTML1114: Codepage unicode from (UNICODE byte order mark) overrides conflicting codepage utf-8 from (10) 
test2012041901.xml

Not sure what the byte order mark message is all about - maybe that's related to the issue?

Oh and dev tools also show this in the script part:

㼼浸敶獲潩㵮ㄢ〮•湥潣楤杮∽呕ⵆ∸㸿㰊砿汭猭祴敬桳敥⁴祴数∽整瑸砯汳•牨晥∽整瑳〲㈱㐰㤱㄰砮汳㼢ਾ琼獥⽴ਾ

Note that all this only happens with newly opened tabs, not existing ones in quirks mode already.

Redfin answered 4/5, 2012 at 22:51 Comment(0)
R
20

As no one jumps up to the occasion, I will answer the question myself.
As paulsm4 indicated in comment to the question, it's the missing doctype which triggers quirks mode. See http://hsivonen.iki.fi/doctype/ for an excellent overview of doctypes, browser types and resulting browser modes.

With respect to the funny string of Asian characters - I did some further research on this and discovered where it comes from. I opened a new file in UltraEdit, converted it from utf-8 to unicode first and then copied the text. The result in hex view reveals it all:

Little Endian

As we see, it's just the xml file uploaded, plus a preceding byte order mark FF FE, which according to wikipedia is a utf-16 Little Endian one:

byte order mark

Now for the messages in the console: the order of events in the browser is apparently as follows:

  1. get XML file
  2. get referred XSL file and apply transformation (XML5001); process result
  3. BOM = FF FE which is utf-16 overrides utf-8 mentioned in xml header (HTML1114)
  4. IE9 notices missing doctype, switches to quirks mode (HTML1113) and reloads result file again
  5. Again, BOM encoding overrides xml header encoding (HTML1114)
  6. File displayed
Redfin answered 8/5, 2012 at 7:34 Comment(0)
D
3

Have you tried explicitly setting compatibility in the HTML you generate?

HTML5 doctype putting IE9 into quirks mode?

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  ..
Deryl answered 4/5, 2012 at 22:57 Comment(4)
nope - as you can see - it just goes to quirks mode unsollicited. My question is not how to correct it in the html (but in the internet options if possible) and I just don't understand why it goes to quirks in the first place. And note that the link you gave is the one I excluded because I have no doctype at all.Redfin
Dude - have you considered that not having a doctype might cause it to go into Quirks mode?!?Deryl
So - you're saying that no doctype and no meta is the trigger to go to quirks mode - always? No I did not consider that because I did not encounter this rule anywhere. I am surprised but intrigued now. Pity I am not able to recreate the earlier situation where quirks mode was not auto chosen - I am afraid then that I will have to regard that as an inexplicable hickup of IE9.Redfin
I finally found something useful on this: http://hsivonen.iki.fi/doctype/. If someone (anyone) cares to supply an answer like "this is normal behaviour, see the site xxx <link above>" then I will accept that answer.Redfin

© 2022 - 2024 — McMap. All rights reserved.