<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ExtJS &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/extjs/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Mon, 01 Oct 2012 07:05:36 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>IE9中X-UA-Compatible失效的问题与值: 对象为 null 或未定义</title>
		<link>https://www.mudbest.com/ie9%e4%b8%adx-ua-compatible%e5%a4%b1%e6%95%88%e7%9a%84%e9%97%ae%e9%a2%98%e4%b8%8e%e5%80%bc-%e5%af%b9%e8%b1%a1%e4%b8%ba-null-%e6%88%96%e6%9c%aa%e5%ae%9a%e4%b9%89/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Thu, 02 Aug 2012 06:47:52 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[X-UA-Compatible]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1144</guid>

					<description><![CDATA[好端端的W3C标准页面被硬生生渲染成IE5，惨不忍睹。而在F12工具中强制调成IE9标准渲染模式，全部正常。于 ... <a title="IE9中X-UA-Compatible失效的问题与值: 对象为 null 或未定义" class="read-more" href="https://www.mudbest.com/ie9%e4%b8%adx-ua-compatible%e5%a4%b1%e6%95%88%e7%9a%84%e9%97%ae%e9%a2%98%e4%b8%8e%e5%80%bc-%e5%af%b9%e8%b1%a1%e4%b8%ba-null-%e6%88%96%e6%9c%aa%e5%ae%9a%e4%b9%89/" aria-label="阅读 IE9中X-UA-Compatible失效的问题与值: 对象为 null 或未定义">阅读更多</a>]]></description>
										<content:encoded><![CDATA[<p>好端端的W3C标准页面被硬生生渲染成IE5，惨不忍睹。而在F12工具中强制调成IE9标准渲染模式，全部正常。于是研究了一下问题在哪。</p>
<p>关于X-UA-Compatible和IE的Quirks Mode模式，Google一下有很多说明，这里有三篇很详细的文章：<br />
<strong>    <a href="http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx" title="[1] http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx" target="_blank">[1] http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx</a><br />
    <a href="http://www.fantxi.com/blog/archives/browser-mode/" title="[2] http://www.fantxi.com/blog/archives/browser-mode/" target="_blank">[2] http://www.fantxi.com/blog/archives/browser-mode/</a><br />
</strong></p>
<p>由于手上的一个项目，用到ExtJS，而版本也是3.0的，后发现在IE9中，ExtJS里的tree控件不能点击了，发现ExtJS3.0不支持IE9的，只有想其他办法，第一想法就是让IE9默认采用IE8的兼容模式运行。</p>
<p>将以下代码放于<head>里面，最好是放在离<head>最近的一个元素。<br />
<span id="more-1144"></span></p>
<pre class="brush: xml; title: ; notranslate">
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9&quot; /&gt;
</pre>
<p>另查到资料，说以下代码也行，但是怎么测试都行不通，是不是脸大的缘故，总之呢，下面的一个不行，上面一个肯定行，自己试下吧。</p>
<pre class="brush: xml; title: ; notranslate">
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=EmulateIE8&quot; /&gt;
</pre>
<p>这样IE9打开该页面就默认用IE8的兼容模式进行渲染，不兼容的问题就解决了。</p>
<p>但是呢，不知道是不是我脸大的缘故，在IE9下面，iframe本来好好的，但是一加入：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9&quot; /&gt;
</pre>
<p>iframe的高度瞬间崩溃了，这个纠结啊，搞了2个小时，搞不定，那也只好将就下吧，如果IE9就插入这段代码，但是要注意，千万不要用以下代码：</p>
<pre class="brush: php; title: ; notranslate">
&lt;!--&#x5B;if IE 9]&gt;
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9&quot; /&gt;
&lt;!&#x5B;endif]--&gt;
</pre>
<p>上面第注释的代码无论如何设置content都是无效的，IE9不会识别。搜索了一下，发现有两种说法。一种认为在X-UA-Compatible之前必须至少有一个meta标签[4]。另一种说法是X-UA-Compatible之前不能有script标签[5]，后一种说法应该是比较靠谱的，因为在官方的说明文章里有这么一句[1]：<br />
<strong>The X-UA-Compatible header is not case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.</strong></p>
<p>但问题是我源码的相应位置并没有script标签。迟疑很久，我怀疑是之前IE注释的问题，不仅如此，经过调试发现这些注释在IE中根本没有生效（IE注释的作用见参考资料[6]）。于是试着把它去掉变成：</p>
<pre class="brush: php; title: ; notranslate">
&lt;head&gt;
&lt;title&gt;1600ML! 微车世界 管理中心&lt;/title&gt;
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;meta content=&quot;1600ML Inc.&quot; name=&quot;Copyright&quot; /&gt;
&lt;/head&gt;
</pre>
<p>如果是php脚本的话，可以做个判断，这样就可以避免其他的一些问题，相关代码：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$mbrowser = $_SERVER&#x5B;'HTTP_USER_AGENT'];
if (strpos($mbrowser, 'MSIE 9.0')){
	$xuacompatible = '&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=9&quot; /&gt;';
}
?&gt;
</pre>
<p>然后将变量放入html代码里，这样就可以进行浏览器判断了。</p>
<p>附上主流的浏览器判断：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
if (strpos($mbrowser, 'MSIE 9.0')){
	//省略自写
}
if (strpos($mbrowser, 'MSIE 8.0')){
	//省略自写
}
if (strpos($mbrowser, 'MSIE 7.0')){
	//省略自写
}
if (strpos($mbrowser, 'MSIE 6.0')){
	//省略自写
}
if (strpos($mbrowser, 'Opera')){
	//省略自写
}
if (strpos($mbrowser, 'Chrome')){
	//省略自写
}

if (strpos($mbrowser, 'Firefox')){
	//省略自写
}
//其他如出一辙……
?&gt;
</pre>
<p><strong>结论：X-UA-Compatible最好紧跟在head之后，之前不要有任何不标准的标签。</strong></p>
<p><a name="pic"></a></p>
<p><strong>IE中存在多个文档模式，比如Quirks Mode，Standard Mode等。 这给Web开发者造成不少困惑。以下流程图全面完整解释了IE9是如何判断选择文档模式的，请参考。</strong></p>
<p><a href="http://www.mudbest.com/1144.action/attachment/062408406" target="_blank" rel="attachment wp-att-1155"><img fetchpriority="high" decoding="async" src="http://www.mudbest.com/wp-content/uploads/2012/08/062408406-245x430.png" alt="" title="062408406" width="245" height="430" class="alignnone size-medium wp-image-1155" srcset="https://www.mudbest.com/wp-content/uploads/2012/08/062408406-245x430.png 245w, https://www.mudbest.com/wp-content/uploads/2012/08/062408406-585x1024.png 585w, https://www.mudbest.com/wp-content/uploads/2012/08/062408406.png 1152w" sizes="(max-width: 245px) 100vw, 245px" /></a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
