为什么HTML1113:从IE9标准来怪癖文档模式重启 [英] Why HTML1113: Document mode restart from IE9 Standards to Quirks

查看:709
本文介绍了为什么HTML1113:从IE9标准来怪癖文档模式重启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开IE9网页 - 一下子文档模式开关来Quirks模式。页面本身是死的简单 - 没有DOCTYPE,没有meta标签,只是一张(测试目的)的XSLT形成在页面内的javascript结果
见<一href=\"http://home.arcor.de/martin.honnen/xslt/test2012041901.xml\">http://home.arcor.de/martin.honnen/xslt/test2012041901.xml使用在相同的位置上提到的xsl。为了方便我复制下面的内容。

网页内容是

 &LT;?XML版本=1.0编码=UTF-8&GT?;
&LT;?xml样式表类型=文/ XSL的href =test2012041901.xsl&GT?;
&lt;试验/&GT;

和XSL包含

 &LT;的xsl:样式表
  的xmlns:XSL =htt​​p://www.w3.org/1999/XSL/Transform
  版本=1.0
  的xmlns:MS =瓮:架构 - 微软COM:XSLT
  的xmlns:我=htt​​p://example.com/my
  排除-result- prefixes =MS我&GT;  &LT; XSL:输出方法=HTML版本=5.0/&GT;  &LT; MS:SCRIPT LANGUAGE =JScript的implements- preFIX =我&GT;
  &LT;![CDATA [
  函数记号化(输入){
    VAR DOC =新的ActiveXObject('Msxml2.DOMDocument.6.0');
    变种片段= doc.createDocumentFragment();
    VAR令牌= input.split(';');
    对于(VAR I = 0,1 = tokens.length; I&LT;升;我++)
    {
      VAR项目= doc.createElement('项目');
      item.text =令牌[I]
      fragment.appendChild(项目);
    }
    返回fragment.selectNodes('项目');
  }
  ]]&GT;
  &LT; / MS:脚本&GT;  &LT;的xsl:模板匹配=/&GT;
    &LT; HTML和GT;
      &LT; HEAD&GT;
        &LT;标题物实施例&LT; /标题&GT;
      &LT; /头&GT;
      &LT;身体GT;
        &所述; H1物实施例&下; / H1&GT;
        &LT; UL&GT;
          &LT; XSL:申请模板选择=我:记号化('Kibology;因为,所有')/&GT;
        &LT; / UL&GT;
      &LT; /身体GT;
    &LT; / HTML&GT;
   &LT; / XSL:模板&GT;   &LT;的xsl:模板匹配=项&GT;
     &LT;立GT;
       &LT;的xsl:value-of的选择= /&gt;中。
     &LT; /李&GT;
   &LT; / XSL:模板&GT;&LT; / XSL:样式&GT;

为什么会出现这种情况?它是一个internet选项设置触发此?我怎样才能prevent怪癖模式下自动选择IE9?结果
和:与前面相同的页面没有发生自动怪癖模式 - 我必须再次做了,像一个设置改变,甚至只是来回原始值,而导致这一变化的行为。不过什么?

F12开发者工具在控制台中显示以下内容:

  XML5001:应用集成XSLT处理。
HTML1114:codePAGE UNI $ C $从(UNI code字节顺序标记)C覆盖冲突的codePAGE UTF-8(10)
test2012041901.xml
HTML1113:从IE9标准来怪癖文档模式重启
test2012041901.xml
HTML1114:codePAGE UNI $ C $从(UNI code字节顺序标记)C覆盖冲突的codePAGE UTF-8(10)
test2012041901.xml

不知道字节顺序标记的消息是怎么一回事? - 也许这就是涉及到这个问题。

呵呵及开发工具在脚本部分还表明这一点:

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

请注意,这一切只新开标签页,怪癖模式早已不是现有的发生。


解决方案

由于没有人跳起来之际,我会回答我的问题。结果
由于paulsm4的评论指出的问题,它是缺失的文档类型触发怪癖模式。请参见 http://hsivonen.iki.fi/doctype/ 的文档类型,浏览器类型和产生的浏览器模式的一个很好的概述。

对于亚洲字符的字符串有趣 - 我做了一些这方面的深入研究,发现它从何而来。我在UltraEdit打开一个新的文件,将其转换从UTF-8到UNI code,然后再复制的文本。十六进制查看结果揭示了这一切:

正如我们看到的,只是上载的XML文件,再加上preceding字节顺序标记FE FF,它根据维基百科是一个UTF-16小端之一:

现在在控制台的消息:事件在浏览器中的顺序是显然如下:


  1. 获取XML文件

  2. 获得简称XSL文件,并应用转换(XML5001);处理结果

  3. BOM = FF FE是UTF-16替代UTF-8在XML头提到的(HTML1114)

  4. IE9通知书丢失的文档类型,切换到怪异模式(HTML1113)和重装再次导致文件

  5. 同样,BOM编码覆盖XML头编码(HTML1114)

  6. 文件显示

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.

解决方案

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:

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:

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

这篇关于为什么HTML1113:从IE9标准来怪癖文档模式重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆