<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>随网之舞</title>
	<atom:link href="http://dancewithnet.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dancewithnet.com</link>
	<description>WEB Design{HTML:CSS:Javascript:DOM:AJAX:PHP:Usability}/Viewpoint/Photo/Food/Mood</description>
	<lastBuildDate>Thu, 05 Nov 2009 14:27:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>动态加载JavaScript的小实践</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/Hk3SIjwxLyg/</link>
		<comments>http://dancewithnet.com/2009/11/05/a-little-practice-about-js-lazy-load/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 16:56:30 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[Javascript & DOM & AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1488</guid>
		<description><![CDATA[动态加载JavaScript文件和CSS资源为Web前端开发提供了巨大的灵活性，同时也实现了lazy load和按需加载，相比XMLHttpRequest而言其没有跨域的限制使其广泛应用。其基本原理是：在页面DOMReady后，利用... ]]></description>
			<content:encoded><![CDATA[<p>动态加载JavaScript文件和CSS资源为Web前端开发提供了巨大的灵活性，同时也实现了lazy load和按需加载，相比XMLHttpRequest而言其没有跨域的限制使其广泛应用。其基本原理是：在页面DOMReady后，利用JavaScript把指定文件路径的script和link元素插入到页面中，然后判断其加载状态再进行继续操作。</p>
<p><span id="more-1488"></span></p>
<p><a href="http://developer.yahoo.com/yui/3/get/">YUI的Get</a>就专门提供了一套动态加载的机制，是YUI最基础的功能之一。在YUI中利用Get加载JavaScript和CSS资源会在HTML的head节点中插入如下代码：</p>
<pre><code>&lt;script id="..." type="text/javascript" src="some.js"&gt;&lt;/script&gt;
&lt;link id="..." type="text/css" rel="stylesheet" href="some.css"&gt;
</code></pre>
<p>当页面编码和JavaScript或CSS资源编码不一致时，常见的方法是通过charset属性声明其编码，比如页面是gb2312，而资源文件为utf-8，则设置编码后其插入的代码是</p>
<pre><code><span>//YUI3.0.0 和 YUI 2.8.0中</span>
&lt;script id="..." type="text/javascript" src="some.js" charset="utf-8"&gt;&lt;/script&gt;
&lt;link id="..." type="text/css" rel="stylesheet" href="some.css" charset="utf-8"&gt;
</code></pre>
<p>然而，<a href="http://dancewithnet.com/lab/2009/yui-loader-bug-in-ie/in-gb2312.html">在IE的一些特殊情况下加载JavaScript时，当你刷新页面时会看到状态栏上有如下的错误提示</a>：<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/11/yui-loader-bug-in-ie.png" alt="YUI3.0.0动态加载JavaScript的bug" title="YUI3.0.0动态加载JavaScript的bug" width="593" height="460" class="alignnone size-full wp-image-1489" /></p>
<p>当你<a href="http://dancewithnet.com/lab/2009/yui-loader-bug-in-ie/random-in-gb2312.html">通过随机参数让JavaScript文件不缓存</a>时，或者<a href="http://dancewithnet.com/lab/2009/yui-loader-bug-in-ie/fixed-in-gb2312.html">让script元素中的charset属性位于src属性之前（比如利用YUI2.8.0之前版本加载）</a>就不会有这个错误提示。所以，这个问题可能是IE的缓存解码机制的bug，也可以看着是<a href="http://yuilibrary.com/projects/yui3/ticket/2528363">YUI的bug（已经提交给YUI开发团队，将在3.1.0中解决）</a>。</p>
<p>因此，动态添加script或CSS资源时，把charset放在资源路径前面是最佳实践。<a href="http://dancewithnet.com/lab/2009/yui-loader-bug-in-ie/fixed-in-gb2312.html">对于YUI，暂时可以这样修改源码来修复</a>。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/vUPykXjTrgWG78k9MnVcDToH92I/0/da"><img src="http://feedads.g.doubleclick.net/~a/vUPykXjTrgWG78k9MnVcDToH92I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vUPykXjTrgWG78k9MnVcDToH92I/1/da"><img src="http://feedads.g.doubleclick.net/~a/vUPykXjTrgWG78k9MnVcDToH92I/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/Hk3SIjwxLyg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/11/05/a-little-practice-about-js-lazy-load/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/11/05/a-little-practice-about-js-lazy-load/</feedburner:origLink></item>
		<item>
		<title>卢广：《关注中国污染》</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/P6f6Acpt43s/</link>
		<comments>http://dancewithnet.com/2009/10/19/pollution-in-china/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 13:11:20 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[收藏 & 转载]]></category>
		<category><![CDATA[中国]]></category>
		<category><![CDATA[健康]]></category>
		<category><![CDATA[卢广]]></category>
		<category><![CDATA[摄影]]></category>
		<category><![CDATA[污染]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1473</guid>
		<description><![CDATA[污染（环境污染） 指自然的或人为的向环境中添加某种物质而超过环境的自净能力而产生危害的行为。我们习惯了城市的繁华，却不知污染正在农村包围城市；现在农民工成为污染的最直接受... ]]></description>
			<content:encoded><![CDATA[<p>污染（环境污染） 指自然的或人为的向环境中添加某种物质而超过环境的自净能力而产生危害的行为。我们习惯了城市的繁华，却不知污染正在农村包围城市；现在农民工成为污染的最直接受害者，但没有人能独善其身。</p>
<p><a href="http://www.smithfund.org/winners/">2009年10月14日中国纪实摄影师卢广的作品《关注中国污染》荣获2009年尤金·史密斯人道主义摄影大奖</a>。卢广说：“我现在考虑的就是怎么能好好地解决这些问题，解决不了也没关系，我先记录，记录对我来说是第一位的。”向其致敬。以下是部分获奖作品。</p>
<p><span id="more-1473"></span></p>
<p>2009年6月11日：江苏省常熟市氟化学工业园污水处理厂，负责收集处理各化工厂的污水，但他们并没有处理污水，通过管道从长江底延伸1500米处排放污水。<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/6_guang.jpg" alt="污水处理厂排放污水" title="污水处理厂排放污水" width="448" height="299" class="alignnone size-full wp-image-1480" /></p>
<p>2008年7月19日：江苏连云港盐场工人在愤怒地说，风往我们这边吹时，化工厂排入的气体又臭又刺鼻受不了，到了晚上毒气放得更多 <br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/11_guang.jpg" alt="江苏连云港盐场的毒气" title="江苏连云港盐场的毒气" width="448" height="299" class="alignnone size-full wp-image-1485" /></p>
<p>2008年3月18日：河北省涉县天津钢铁厂是重污染企业，企业规模还在不断扩大，严重影响当地居民的生活 <br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/2_guang.jpg" alt="河北省涉县天津钢铁厂是重污染企业" title="河北省涉县天津钢铁厂是重污染企业" width="448" height="299" class="alignnone size-full wp-image-1476" /></p>
<p>2008年3月18日：河北省涉县固新村现有癌症病人50多人，每年癌症死亡20多人<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/12_guang.jpg" alt="癌症村：河北省涉县固新村" title="癌症村：河北省涉县固新村" width="448" height="299" class="alignnone size-full wp-image-1474" /></p>
<p>2007年9月24日：在山西临汾市污染严重地区，农民在棉花地里干了两小时的活之后全身都是煤灰<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/5_guang.jpg" alt="煤灰雨" title="煤灰雨" width="448" height="299" class="alignnone size-full wp-image-1479" /></p>
<p>2006年4月23日：在黄河边放羊的老汉受不了第三排水沟散发的臭气 <br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/3_guang.jpg" alt="黄河边的臭气" title="黄河边的臭气" width="448" height="299" class="alignnone size-full wp-image-1477" /></p>
<p>2006年4月22日：宁夏石嘴山湖滨工业园区高大的烟囱上粉尘从天而降，当地居民叫苦连天，他们出门就得做好防范措施<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/7_guang.jpg" alt="从天而降的粉尘" title="从天而降的粉尘" width="448" height="299" class="alignnone size-full wp-image-1481" /></p>
<p>2005年11月25日：广东省贵屿镇河流、水塘都已被污染，村民们只好在被严重污染的水塘里洗涤 <br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/8_guang.jpg" alt="在被严重污染的水塘里洗涤" title="在被严重污染的水塘里洗涤" width="448" height="299" class="alignnone size-full wp-image-1482" /></p>
<p>2005年7月26日：内蒙古拉僧庙工业园区每天大量的工业污水流向黄河滩<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/4_guang.jpg" alt="工业污水流向黄河滩" title="工业污水流向黄河滩" width="448" height="299" class="alignnone size-full wp-image-1478" /></p>
<p>2005年4月10日：宁夏西吉县民工马某带上5个孩子来到内蒙古黑龙柜工业区白灰厂打工，孩子最大的9岁，没有上学，最小的不到2岁。他们在污染严重的地区，孩子们的手脸整天都是脏兮兮的<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/10_guang.jpg" alt="西吉县的失学儿童" title="西吉县的失学儿童" width="448" height="299" class="alignnone size-full wp-image-1484" /></p>
<p>2005年4月10日：在高耗能、高污染企业的民工没有任何防护措施，照样卖命的干活，每天大量粉尘吸进肺部。在这里干一、二年，他们就感到身体不适，甚至发病，这些民工大多是贫困地区来的<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/1_guang.jpg" alt="无劳保防护的工人" title="无劳保防护的工人" width="448" height="299" class="alignnone size-full wp-image-1475 float-left" /></p>
<p>2005年4月8日：15岁的甘肃天水人杨新闰，上完小学二年级就辍学了，跟着父母来到黑龙贵工业区，他一天能赚16元<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/10/9_guang.jpg" alt="甘肃天水人杨新闰" title="甘肃天水人杨新闰" width="448" height="299" class="alignnone size-full wp-image-1483" /></p>
<p>延伸阅读：</p>
<ul class="refer">
<li><a href="http://lizhensheng.blshe.com/post/38/452931">卢广在纽约荣获尤金·史密斯人道主义摄影大奖</a></li>
<li><a href="http://www.bundpic.com/link.php?action=print&#038;linkid=9709">“记录是第一位的”</a></li>
<li><a href="http://heyanguang.blshe.com/post/188/168804">卢广，为什么出错的总是你</a></li>
<li><a href="http://luguang.blshe.com/post/6396/169066">对贺老师“卢广，为什么出错的总是你”一文的回复</a></li>
<li><a href="http://image.fengniao.com/vision/content/1/122-1.html">蜂鸟视觉盛宴：关注中国污染（全部获奖作品）</a></li>
<li><a href="http://www.ipe.org.cn/">中国水污染地图</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/EVabununF4JtKCQWb4iDtsJ7aUc/0/da"><img src="http://feedads.g.doubleclick.net/~a/EVabununF4JtKCQWb4iDtsJ7aUc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/EVabununF4JtKCQWb4iDtsJ7aUc/1/da"><img src="http://feedads.g.doubleclick.net/~a/EVabununF4JtKCQWb4iDtsJ7aUc/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/P6f6Acpt43s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/10/19/pollution-in-china/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/10/19/pollution-in-china/</feedburner:origLink></item>
		<item>
		<title>IE中选择符的4095限制</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/oVmkRlPfapo/</link>
		<comments>http://dancewithnet.com/2009/09/10/ie-css-4095-limit/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:42:42 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[4095]]></category>
		<category><![CDATA[addRule]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[cssText]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1471</guid>
		<description><![CDATA[去年曾总结了《IE对CSS样式表的限制和解决方案》中限制的第4条写道“一个CSS文件的不能超过288kb？”，这是一个疑问句，当时没有重现出来且参考来自Internet Explorer CSS File Size Limit。今天终于... ]]></description>
			<content:encoded><![CDATA[<p>去年曾总结了<a href="http://dancewithnet.com/2008/04/22/a-solution-of-limit-of-style-tags-in-ie/">《IE对CSS样式表的限制和解决方案》</a>中限制的第4条写道“一个CSS文件的不能超过288kb？”，这是一个疑问句，当时没有重现出来且参考来自<a href="http://joshua.perina.com/africa/gambia/fajara/post/2008/1/25/internet-explorer-css-file-size-limit">Internet Explorer CSS File Size Limit</a>。今天终于看到了IE在CSS上的另一个限制：<strong>IE中每个style标签或css文件的选择符个数不能超过4095。</strong>其实style属性也应该有这个限制，但是几乎不可能发生。这个限制在IE6、IE7和IE8中存在。请看<a href="http://dancewithnet.com/lab/2009/ie-css-4095-limit/" class="link-btn">IE关于4095个选择符限制的DEMO</a>。</p>
<p><span id="more-1471"></span></p>
<p>DEMO中的<a href="http://dancewithnet.com/lab/2009/ie-css-4095-limit/style.css">style.css</a>有4913个选择符，大小为554kb，但在IE中却在4095个选择符之后失效，所以说明IE的CSS文件不存在不能超过288kb的限制。</p>
<p>所以在IE中对style标签使用<a href="http://msdn.microsoft.com/en-us/library/aa358796%28VS.85%29.aspx">addRule方法</a>和<a href="http://msdn.microsoft.com/en-us/library/ms533698(VS.85).aspx">cssText属性</a>添加样式时都可能会碰到这个限制，比如使用addRule方法添加第4096个选择符时会报“Invalid Argument”的异常。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/vYyU9T3Ll_1qKEx1nslmvCRU-BY/0/da"><img src="http://feedads.g.doubleclick.net/~a/vYyU9T3Ll_1qKEx1nslmvCRU-BY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vYyU9T3Ll_1qKEx1nslmvCRU-BY/1/da"><img src="http://feedads.g.doubleclick.net/~a/vYyU9T3Ll_1qKEx1nslmvCRU-BY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/oVmkRlPfapo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/09/10/ie-css-4095-limit/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/09/10/ie-css-4095-limit/</feedburner:origLink></item>
		<item>
		<title>CSS实现HTML元素透明的那些事</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/t0lZdV9UZR0/</link>
		<comments>http://dancewithnet.com/2009/09/06/css-opacity/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 15:44:00 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Javascript & DOM & AJAX]]></category>
		<category><![CDATA[-ms-filter]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[hasLayout]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1469</guid>
		<description><![CDATA[CSS3草案中定义了{opacity: &#124; inherit;}来声明元素的透明度，这已经得到了大多数现代浏览器的支持，而IE则很早通过特定的私有属性filter来实现的，所以HTML元素的透明效果已经无处不在了。首... ]]></description>
			<content:encoded><![CDATA[<p>CSS3草案中定义了<a href="http://www.w3.org/TR/css3-color/#transparency"><code>{opacity:<length> | inherit;}</code></a>来声明元素的透明度，这已经得到了大多数现代浏览器的支持，而IE则很早通过特定的私有属性<a href="http://msdn.microsoft.com/en-us/library/ms532967%28VS.85%29.aspx"><code>filter</code></a>来实现的，所以HTML元素的透明效果已经无处不在了。首先看看<a href="http://developer.yahoo.com/yui/articles/gbs/">A级浏览器</a>所支持的用<a href="https://developer.mozilla.org/en/CSS/opacity">CSS实现元素透明的方案</a>：</p>
<p><span id="more-1469"></span></p>
<table>
<tr>
<th>浏览器</th>
<th>最低<br />版本</th>
<th>方案</th>
</tr>
<tr>
<th rowspan="3">Internet Explorer</th>
<td>4.0</td>
<td><code>filter: alpha(opacity=xx);</code></td>
</tr>
<tr>
<td>5.5</td>
<td><code>filter: progid:DXImageTransform.Microsoft.Alpha(opacity=xx);</code>
</td>
</tr>
<tr>
<td>8.0</td>
<td><code>filter: "alpha(opacity=xx)";<br />
filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=xx)";<br />
-ms-filter: "alpha(opacity=xx)";<br />
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=30)";</code>
</td>
</tr>
<tr>
<th>Firefox (Gecko)</th>
<td>0.9 (1.7)</td>
<td><code>opacity</code></td>
</tr>
<tr>
<th>Opera</th>
<td>9.0</td>
<td><code>opacity</code></td>
</tr>
<tr>
<th>Safari (WebKit)</th>
<td>1.2 (125)</td>
<td><code>opacity</code></td>
</tr>
</table>
<p>实际上在IE8中，-ms-filter是filter的别名，两者区别是<a href="http://msdn.microsoft.com/en-us/library/ms530752%28VS.85%29.aspx">-ms-filter的属相值必须被单引号或双引号包围</a>，而filter中则不是必须，而在IE8之前的版本中，filter的属性值必须不被单引号或双引号包围。</p>
<p id="hasLayout">IE中的HTML元素要实现透明，则其必须具备layout，这样的元素有仅可读的属性<a href="http://msdn.microsoft.com/en-us/library/ms530764%28VS.85%29.aspx">hasLayout</a>，且其值为true</a>。具体情况如下：</p>
<ol>
<li><code>body</code>、<code>img</code>、<code>table</code>、<code>tr</code>、<code>th</code>、<code>td</code>等元素的<code>hasLayout</code>一直为<code>true</code>。</li>
<li><code>type</code>为<code>text</code>、<code>button</code>、<code>file</code>或<code>select</code>的<code>input</code>的<code>hasLayout</code>一直为<code>true</code>。</li>
<li>设置<code>{position:absolute}</code>的元素的<code>hasLayout</code>为<code>true</code></li>
<li>设置<code>{float:left|right}</code>的元素的<code>hasLayout</code>为<code>true</code></li>
<li>设置<code>{display:inline-block}</code>的元素的<code>hasLayout</code>为<code>true</code></li>
<li>设置<code>{height:xx}</code>或<code>{width:xx}</code>的元素必须具体以下两个条件之一，其<code>hasLayout</code>才能为<code>true</code>：
<ol>
<li>IE8兼容模式和IE8以前的浏览器中，在标准(strict)模式下其<code>display</code>的值是<code>block</code>，如<a href="http://dancewithnet.com/lab/2009/css-opacity/#demo3">demo3</a>就不行。</li>
<li>元素在怪癖模式（compat mode）下。</li>
</ol>
</li>
<li>设置了<code>{zoom:xx}</code>的元素在IE8的兼容模式或IE8之前的浏览器中其<code>hasLayout</code>为<code>true</code>，但在IE8的标准模式下则不会触发<code>hasLayout</code>。</li>
<li>设置了<code>{writing-mode:tb-rl}</code>的元素的<code>hasLayout</code>为<code>true</code>。</li>
<li>元素的<a href="http://msdn.microsoft.com/en-us/library/ms537837%28VS.85%29.aspx"><code>contentEditable</code></a>的属性值为<code>true</code>。</li>
<li>在IE8标准模式下设置了<code>{display:block}</code>的元素的<code>hasLayout</code>一直为<code>true</code>，如<a href="http://dancewithnet.com/lab/2009/css-opacity/#demo8">demo8</a>。</li>
</ol>
<p>关于hasLayout的更多详情可以看<a href="http://msdn.microsoft.com/en-us/library/bb250481%28VS.85%29.aspx">Exploring Internet Explorer &#8220;HasLayout&#8221; Overview</a>和<a href="http://www.satzansatz.de/cssd/onhavinglayout.html">On having layout</a></p>
<p>从上面就可以看出IE实现HTML元素的透明如此混乱，为了向下兼容和自己的私有属性让IE上实现元素透明有多种方式，比如<a href="http://dancewithnet.com/lab/2009/css-opacity/" class="link-btn">CSS Opacity实例中的demo1到demo8</a>，虽然<a href="http://blogs.msdn.com/ie/archive/2008/09/08/microsoft-css-vendor-extensions.aspx">IE团队推荐实现透明的方式</a>是：</p>
<pre><code>{
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
  filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50);
  opacity: .5;
}</code></pre>
<p>而目前简单最好用的实现方式是<a href="http://dancewithnet.com/lab/2009/css-opacity/" class="link-btn">如CSS Opacity中demo4这样</a>：</p>
<pre><code>{
    filter:alpha(opacity=30);
    opacity:.3;
}</code></pre>
<p>实际上目前最流行的JavaScript框架的设置样式方法都是应用这种方式，并且针对IE设置了<code>{zoom:1}</code>来让元素的<code>hasLayout</code>为<code>true</code>，但在IE8的标准模式下<code>zoom</code>并不能触发<code>hasLayout</code>，所以利用它们设置<code>hasLayout</code>为<code>false</code>的元素的透明度时在IE8的标准模式下是失败的，这个bug在<a href="http://developer.yahoo.com/yui/">YUI</a><ins datetime="2009-09-09T09:38:41+08:00">（我已经给YUI团队提交了这个bug，他们会在<a href="http://yuilibrary.com/projects/yui2/ticket/2528440">下个版本修复</a>，最新的2.8.0中依旧存在，期待2.9.0吧）</ins>、<a href="http://prototypejs.org">Prototype</a>、<a href="http://jquery.com">jQuery</a>和<a href="http://mootools.net">Mootools</a>的最新版本中都存在，具体请在IE8标准模式下看<a href="http://dancewithnet.com/lab/2009/css-opacity/#demo9">demo9到demo11</a>。同样由于在IE8中设置透明度的方式多种多样，所以利用JavaScript获取HTML元素的透明度值需要考虑多种情况，YUI完美解决了这个问题，Prototype比jQuery稍微周全一点，而Mootools直接是<a href="https://mootools.lighthouseapp.com/projects/2706/tickets/707-getstyleopacity-always-returns-1">bug</a>，具体可以<a href="http://dancewithnet.com/lab/2009/css-opacity/" class="link-btn">在IE下看demo1到demo8</a>的演示。从这个角度给4个框架来个排名的话，YUI第一、Prototype第二、jQuery第三、Mootools垫底。</p>
<p>我简单的实现了设置和获取Opacity的函数，可以避开上面框架存在的bug，请<a href="http://dancewithnet.com/lab/2009/css-opacity/#demo12" class="link-btn">在IE8标准模式下看demo12</a>：</p>
<pre><code><span>//设置CSS opacity 属性的函数，解决IE8的问题</span>
var setOpacity = function(el,i){
  if(window.getComputedStyle){<span>// for non-IE</span>
    el.style.opacity = i;
  }else if(document.documentElement.currentStyle){ <span>// for IE</span>
    if(!el.currentStyle.hasLayout){
      el.style.zoom = 1;
    }
    if(!el.currentStyle.hasLayout){ <span>//在IE8中zoom不生效，所以再次设置inline-block</span>
      el.style.display = 'inline-block';
    }
    try{
      <span>//测试是否已有filter
      //http://msdn.microsoft.com/en-us/library/ms532847%28VS.85%29.aspx</span>
      if(el.filters){
        if(el.filters('alpha')){
	  el.filters('alpha').opacity = i * 100;
	}else{
	  el.style.filter += 'alpha(opacity='+ i * 100 +')';
	 }
       }
    }catch(e){
      el.style.filter = 'alpha(opacity='+ i * 100 +')';
    }
  }
}

<span>//获取CSS opacity 属性值的函数</span>
<span>//借鉴自http://developer.yahoel.com/yui/docs/YAHOO.util.Dom.html#method_getStyle</span>
var getOpacity = function(el){
  var value;
  if(window.getComputedStyle){
    value = el.style.opacity;
    if(!value){
      value = el.ownerDocument.defaultView.getComputedStyle(el,null)['opacity'];
    }
    return value;
  }else if(document.documentElement.currentStyle){
    value = 100;
    try { // will error if no DXImageTransform
        value = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
    } catch(e) {
        try { // make sure its in the document
            value = el.filters('alpha').opacity;
        } catch(err) {
        }
    }
    return value / 100;
  }
}
</code></pre>
<p>不得不说，这些事都是IE整出来的……</p>

<p><a href="http://feedads.g.doubleclick.net/~a/jvY7vj6B1gHkFHV9HK-giho9jcQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/jvY7vj6B1gHkFHV9HK-giho9jcQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/jvY7vj6B1gHkFHV9HK-giho9jcQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/jvY7vj6B1gHkFHV9HK-giho9jcQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/t0lZdV9UZR0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/09/06/css-opacity/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/09/06/css-opacity/</feedburner:origLink></item>
		<item>
		<title>老虎菜</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/Mvb0C6wpaGw/</link>
		<comments>http://dancewithnet.com/2009/08/31/spicy-salad/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 15:48:29 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[爱厨房爱美食]]></category>
		<category><![CDATA[凉拌菜]]></category>
		<category><![CDATA[厨艺]]></category>
		<category><![CDATA[美食]]></category>
		<category><![CDATA[老虎菜]]></category>
		<category><![CDATA[菜谱]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1465</guid>
		<description><![CDATA[原料

辣椒（青椒和尖椒）
黄瓜
香菜：又叫香荽、胡菜、原荽、园荽、芫荽、芫茜、胡荽、莞荽、莚荽菜、莚葛草、满天星、盐熟菜（安徽庐江方言）
大葱
香油、酱油、味精和盐


做法

辣椒... ]]></description>
			<content:encoded><![CDATA[<h3>原料</h3>
<ol>
<li>辣椒（青椒和尖椒）</li>
<li>黄瓜</li>
<li>香菜：又叫香荽、胡菜、原荽、园荽、芫荽、芫茜、胡荽、莞荽、莚荽菜、莚葛草、满天星、盐熟菜（安徽庐江方言）</li>
<li>大葱</li>
<li>香油、酱油、味精和盐</li>
</ol>
<p><span id="more-1465"></span></p>
<h3>做法</h3>
<ol>
<li>辣椒、黄瓜和大葱洗净后切成细丝</li>
<li>香菜洗净后切成寸段</li>
<li>把加工好的菜放入大碗中，加入酱油、盐和味精（依据个人口味还可以加入糖和醋），然后进行充分搅拌</li>
<li>最后浇上香油就搞定了<br /><img src="http://dancewithnet.com/wp-content/uploads/2009/08/spicy-salad.jpg" alt="老虎菜" title="老虎菜" width="640" height="480" class="size-full wp-image-1466" /></li>
</ol>
<h3>传说</h3>
<p>这道菜是去了北京才吃到，当时就是因为这个有趣的菜名才点的，吃了之后就喜欢上。来杭州后就一直再没有吃过，于是这周就动手做了一把。当然，有趣的名字也意味着有趣的故事：</p>
<ol>
<li>传说在东北有一个儿媳妇不太会做家务事，对做菜更是一窍不通。一天家中的婆婆让儿媳妇做一道拿手菜，儿媳妇犯了难，不知从何下手，但还是逞强的将辣椒、黄瓜、大葱、香菜等原料洗净切丝。胡乱的扔在一起用调料凉拌。当这盘“自创”的菜端上桌子，婆婆看见如此离谱的做法，尝了一口不禁感叹的说道：“媳妇，你可真虎啊。”（虎：在东北方言中除了指老虎之外，还意指此人傻、缺心眼。）于是，此后人们就将这道菜称之为“老虎菜”。</li>
<li>张作霖统治东北时，有一段时间不思饮食。就在这时，有个厨师顺手拿起几样蔬菜，举刀就切，黄瓜、大葱、尖辣椒切成丝，香菜切成段，然后放入盐、醋、糖，凉拌一番，就端上了餐桌。张作霖一尝，食欲大振，胃口大开，便向厨师问起这道菜的名字。厨师自知此菜本无名，是随意而为，可又不好据实回答，于是想到这菜是做给“东北虎”张大帅吃的，便顺水推舟地说：“这菜，叫老虎菜。”张作霖一听十分高兴地说：“吃老虎菜好开胃啊。”老虎菜后来走出张氏帅府，成为东北百姓的家常菜。再后来，老虎菜走出东北，又添加了香油、蒜蓉、辣椒粉等调味料，成为许多地方的旺销菜。一拌即成的老虎菜，居然成了一道名菜。 </li>
<li>究问其名，有人说这是创新菜，爽脆的黄瓜、鲜嫩的香菜、酸味的米醋、辣味的尖椒、大葱、大蒜，凉拌生吃，爽脆鲜香，强烈刺激舌尖味蕾，无法抵挡，如老虎一般，故称“老虎菜”。如此一说，也不无道理，也就如此这般地传开了。 </li>
</ol>
<p>关于菜料的营养和注意事情请参看百度百科的<a href="http://baike.baidu.com/view/24294.htm">老虎菜</a>条目。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/FaPae5sDS3wbYsBAz3Rr-DJk0UY/0/da"><img src="http://feedads.g.doubleclick.net/~a/FaPae5sDS3wbYsBAz3Rr-DJk0UY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/FaPae5sDS3wbYsBAz3Rr-DJk0UY/1/da"><img src="http://feedads.g.doubleclick.net/~a/FaPae5sDS3wbYsBAz3Rr-DJk0UY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/Mvb0C6wpaGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/08/31/spicy-salad/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/08/31/spicy-salad/</feedburner:origLink></item>
		<item>
		<title>酸/碱性食物表</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/Fw91o9Hk3qM/</link>
		<comments>http://dancewithnet.com/2009/08/18/acid-alkali-food-table/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 15:26:23 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[爱厨房爱美食]]></category>
		<category><![CDATA[健康]]></category>
		<category><![CDATA[碱性食物]]></category>
		<category><![CDATA[酸性体质]]></category>
		<category><![CDATA[食物]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1464</guid>
		<description><![CDATA[人体酸碱性通常指人体血液的酸碱性，正常PH值在7.2-7.4之间，呈弱碱性。如果人体PH值小于7.2，就是处于病态，7.0或以下，就是非常不健康。
所谓食物的酸碱性，是指食物中的无机盐属于酸性... ]]></description>
			<content:encoded><![CDATA[<p>人体酸碱性通常指人体血液的酸碱性，正常PH值在7.2-7.4之间，呈弱碱性。如果人体PH值小于7.2，就是处于病态，7.0或以下，就是非常不健康。</p>
<p>所谓食物的酸碱性，是指食物中的无机盐属于酸性还是属于碱性。食物的酸碱性取决于食物中所含矿物质的种类和含量多少的比率而定：钾、钠、钙、镁、铁进入人体之后呈现的是碱性反应；磷、氯、硫进入人体之后则呈现酸性。</p>
<p><span id="more-1464"></span></p>
<p>很早就看过<a href="http://www.williamlong.info/archives/429.html">《治疗癌症：酸性体质和碱性食品》</a>，也听说过“弱碱性体质更健康，多吃碱性食物有助于保持身体弱碱性”。但<a href="http://health.sohu.com/20090701/n264888242.shtml">最近有专家说</a>：“明确一种因果关系：人体因不健康而‘酸’，并非因‘酸’而不健康”。人体处于亚健康或不健康状态时，体质确实呈酸性。但如果器官已经受损，即使有办法调整为碱性体质，也不可能恢复健康。人体有强大的激素、神经调整机制，其酸碱度就是通过神经体液调整系统来进行的。与其变着法的找碱性食品，不如维护好神经体液调整系统。要做到这一点，就要养成健康的生活习惯，平衡膳食，坚持适量运动等。</p>
<p>虽然有各种各样的观点，我也无意证明什么，不过从小三同学总结的酸/碱性食物表来看，碱性食物的确符合目前的健康饮食方式。</p>
<h3>酸/碱性食物表</h3>
<table>
<tr>
<th></th>
<th>蔬菜</th>
<th>水果</th>
<th>肉蛋鱼禽及其制品</th>
<th>坚果/豆类/米面</th>
<th>饮料/零食/油/调料</th>
</tr>
<tr>
<th>强碱性</th>
<td>茎叶类：白菜、菠菜、生菜、卷心菜、海带、海带及海藻类、莼菜、马齿菜、蕺菜（鱼腥草）、蕹菜（空心菜）<br />
ps：几乎所有蔬菜，尤其是绿叶蔬菜都属于碱性食物<br />
果实/膨胀根茎类：黄瓜、胡萝卜、芋头、番茄、佛手瓜、西葫芦、葫芦瓜、瓠瓜</td>
<td>柑橘类、无花果、西瓜、葡萄及葡萄干、甜瓜、香瓜、哈密瓜、菜瓜、蒟弱</td>
<td></td>
<td>板栗、杏仁</td>
<td>饮料类：茶、咖啡、葡萄酒<br />调味类：蜂蜜、食盐、食醋、食碱</td>
</tr>
<tr>
<th>中/弱碱性</th>
<td>茎叶类：竹笋、香菇、蘑菇、慈菇、金针菇、猴头、黑木耳、油菜、芹菜、菠菜、菜花、茼蒿、荆芥、荠菜、银耳、香椿、韭菜、雪里蕻、芫荽、高丽菜、芦笋、牛蒡<br />
果实/膨胀根茎类：四季豆、洋葱、生姜、大蒜、辣椒、甜椒、苦瓜、冬瓜、丝瓜、南瓜、莲藕、茄子、番薯（红薯）、马铃薯（土豆）、甘蓝菜、莴苣、茭白、甜菜（紫菜头）、百合、大头菜、胡椒、薤白（野蒜）</td>
<td>草莓、苹果、梨、香蕉、樱桃、梅干、柠檬、山楂、猕猴桃、柿子、桑葚、甘蔗、香蕉、荸荠、枇杷、芒果、罗汉果、石榴、木瓜、龙眼（桂圆）、槟榔、荔枝、柠檬、桃子、樱桃。</td>
<td>牛奶</td>
<td>绿豆、大豆、豆浆、豆腐、魔芋、葛粉</td>
<td></td>
</tr>
<tr>
<th>中/弱酸性</th>
<td>葱、海苔、豌豆</td>
<td></td>
<td>蛋肉禽类：鸡蛋白、奶油、牛油、黄油、培根、火腿、香肠<br />水产类：虾类、章鱼、鱿鱼、鳗鱼、河鱼、鲤鱼、文蛤、章鱼、泥鳅、鲷鱼、鲍鱼</td>
<td>面条、面粉、意粉、空心粉、米糕、荞麦、大麦、荞麦、玉米、燕麦、黑麦、大麻种子、大多数豆类<br />PS：粗粮大多是碱性的，细粮是酸性 </td>
<td>巧克力、油炸豆腐<br />
PS：几乎所有油炸类食品和甜点<br />油类：果油、菜籽油、玉米油、大麻籽油、胡麻油、猪油、橄榄油、红花油、芝麻油、葵花籽油</td>
</tr>
<tr>
<th>强酸性</th>
<td></td>
<td></td>
<td>蛋肉禽类：牛肉、猪肉、鸡肉、兔肉、奶酪、蛋黄<br />水产类：金枪鱼、牡蛎、比目鱼</td>
<td>米、麦、面包、饼干、花生米及花生酱、榛子、核桃、腰果、巴西坚果</td>
<td>啤酒及其它酒类、糖类</td>
</tr>
</table>
<h3>常见食 品 酸 碱 度 表</h3>
<table>
<tr>
<th colspan="2">酸 性 食 品</th>
<th colspan="2">碱 性 食 品</th>
</tr>
<tr>
<th>品 种</th>
<th>pH值</th>
<th>品 种</th>
<th>pH值</th>
</tr>
<tr>
<th>鸡蛋黄</th>
<td>2.9</td>
<th>橘子</th>
<td>12.1</td>
</tr>
<tr>
<th>白酒</th>
<td>3.5</td>
<th>菠菜</th>
<td>11.5</td>
</tr>
<tr>
<th>香烟</th>
<td>4.4</td>
<th>茶</th>
<td>10.7</td>
</tr>
<tr>
<th>方便面</th>
<td>5.0</td>
<th>梨</th>
<td>10.6</td>
</tr>
<tr>
<th>雪糕</th>
<td>5.4</td>
<th>香蕉</th>
<td>10.6</td>
</tr>
<tr>
<th>大米</th>
<td>5.4</td>
<th>胡萝卜</th>
<td>10.5</td>
</tr>
<tr>
<th>饼干</th>
<td>5.6</td>
<th>咖啡</th>
<td>9.7</td>
</tr>
<tr>
<th>糙米</th>
<td>5.7</td>
<th>西瓜</th>
<td>9.6</td>
</tr>
<tr>
<th>糖果</th>
<td>5.7</td>
<th>草霉</th>
<td>9.5</td>
</tr>
<tr>
<th>面包</th>
<td>5.9</td>
<th>苹果</th>
<td>9.1</td>
</tr>
<tr>
<th>纯净水</th>
<td>5.9</td>
<th>葡萄</th>
<td>8.8</td>
</tr>
<tr>
<th>猪肉</th>
<td>6.0</td>
<th>莴苣</th>
<td>8.5</td>
</tr>
<tr>
<th>鱿鱼</th>
<td>6.0</td>
<th>甘蔗</th>
<td>8.4</td>
</tr>
<tr>
<th>小麦粉</th>
<td>6.1</td>
<th>牡蛎</th>
<td>8.4</td>
</tr>
<tr>
<th>鹅肉</th>
<td>6.2</td>
<th>茄子</th>
<td>8.3</td>
</tr>
<tr>
<th>狗肉</th>
<td>6.2</td>
<th>黄瓜</th>
<td>8.2</td>
</tr>
<tr>
<th>火腿肠</th>
<td>6.2</td>
<th>芹菜</th>
<td>8.0</td>
</tr>
<tr>
<th>鸡肉</th>
<td>6.3</td>
<th>鸡蛋白</th>
<td>8.0</td>
</tr>
<tr>
<th>鲫鱼</th>
<td>6.4</td>
<th>元葱</th>
<td>7.8</td>
</tr>
<tr>
<th>加鱼</th>
<td>6.4</td>
<th>小豆</th>
<td>7.6</td>
</tr>
<tr>
<th>牛肉</th>
<td>6.5</td>
<th>水菜</th>
<td>7.5</td>
</tr>
<tr>
<th>大马哈鱼</th>
<td>6.5</td>
<th>莲藕</th>
<td>7.5</td>
</tr>
<tr>
<th>鸭肉</th>
<td>6.6</td>
<th>人奶</th>
<td>7.4</td>
</tr>
<tr>
<th>大麦</th>
<td>6.8</td>
<th>大豆</th>
<td>7.4</td>
</tr>
<tr>
<th>豌豆</th>
<td>6.9</td>
<th>牛奶</th>
<td>7.2</td>
</tr>
<tr>
<th>干紫菜</th>
<td>7.0</td>
<th>豆腐</th>
<td>7.2</td>
</tr>
</table>

<p><a href="http://feedads.g.doubleclick.net/~a/W4HzvGLDXXGwO8Pvbn1qiGjcSx4/0/da"><img src="http://feedads.g.doubleclick.net/~a/W4HzvGLDXXGwO8Pvbn1qiGjcSx4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/W4HzvGLDXXGwO8Pvbn1qiGjcSx4/1/da"><img src="http://feedads.g.doubleclick.net/~a/W4HzvGLDXXGwO8Pvbn1qiGjcSx4/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/Fw91o9Hk3qM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/08/18/acid-alkali-food-table/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/08/18/acid-alkali-food-table/</feedburner:origLink></item>
		<item>
		<title>Data URI 和 MHTML</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/tCpPVflqXho/</link>
		<comments>http://dancewithnet.com/2009/08/15/data-uri-mhtml/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 16:54:53 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[datauri]]></category>
		<category><![CDATA[MHTML]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1463</guid>
		<description><![CDATA[Data URI
Data URI是由RFC 2397定义的一种把小文件直接嵌入文档的方案。通过如下语法就可以把小文件变成指定编码直接嵌入到页面中：
data:[&#60;MIME-type&#62;][;base64],&#60;data&#62;


MIME-type：指定嵌入数... ]]></description>
			<content:encoded><![CDATA[<h3>Data URI</h3>
<p><a href="http://en.wikipedia.org/wiki/Data_URI_scheme">Data URI</a>是由<a href="http://tools.ietf.org/html/rfc2397">RFC 2397</a>定义的一种把小文件直接嵌入文档的方案。通过如下语法就可以把小文件变成指定编码直接嵌入到页面中：</p>
<pre><code>data:[&lt;MIME-type&gt;][;base64],&lt;data&gt;
</code></pre>
<ol>
<li>MIME-type：指定嵌入数据的<a href="http://zh.wikipedia.org/wiki/MIME">MIME</a>。其形式是<code>[type]/[subtype]; parameter</code>，比如png图片对应的MIME是image/png。parameter可以用來指定附加的信息，更多情況下是用于指定text/plain和text/htm等的文字编码方式的charset参数。默认是text/plain;charset=US-ASCII。</li>
<li>base64：声明后面的数据的编码是<a href="http://zh.wikipedia.org/wiki/Base64">base64</a>的，否则数据必须要用百分号编码（即对内容进行urlencode）。</li>
</ol>
<p><span id="more-1463"></span></p>
<p>在上个世纪<a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#h-13.3.1">HTML4.01引入了Data URI方案</a>，到今天为止<a href="http://en.wikipedia.org/wiki/Data_URI_scheme#Web_browser_support">除了IE6和IE7之外，所有主流浏览器都支持</a>，但<a href="http://msdn.microsoft.com/en-us/library/cc848897%28VS.85%29.aspx">IE8对Data URI的支持还是有限制的</a>，只支持object（仅是图片时）、img、input type=image、link和CSS中的URL，且数据量不能大于32K。</p>
<h4>优点：</h4>
<ol>
<li><a href="http://developer.yahoo.com/performance/rules.html#num_http">减少HTTP请求数</a>，没有了TCP连接消耗和同一域名下浏览器的并发数限制。</li>
<li>对于小文件会降低带宽。虽然编码后数据量会增加，但是却减少了http头，当http头的数据量大于文件编码的增量，那么就会降低带宽。</li>
<li>对于HTTPS站点，HTTPS和HTTP混用会有安全提示，而HTTPS相对于HTTP来讲开销要大更多，所以Data URI在这方面的优势更明显。</li>
<li>可以把整个多媒体页面保存为一个文件。</li>
</ol>
<h4>缺点：</h4>
<ol>
<li>无法被重复利用，同一个文档应用多次同一个内容，则需要重复多次，数据量大量增加，增加了下载时间。</li>
<li>无法被独自缓存，所以其包含文档重新加载时，它也要重新加载。</li>
<li>客户端需要重新解码和显示，增加了点消耗。</li>
<li>不支持数据压缩，base64编码会增加1/3大小，而urlencode后数据量会增加更多。</li>
<li>不利于安全软件的过滤，同时也存在一定的安全隐患。</li>
</ol>
<h3>MHTML</h3>
<p>MHTML是<a href="http://en.wikipedia.org/wiki/MHTML">MIME HTML (Multipurpose Internet Mail Extension HTML)</a>的缩写，是由<a href="http://tools.ietf.org/html/rfc2557">RFC 2557</a>定义的把一个多媒体的页面所有内容都保存到同一个文档解决方案。这个方案是由微软提出从IE5.0开始支持，另外Opera9.0也开始支持，Safari可以把文件保存为.mht（MHTML文件的后缀）格式，但不支持显示它。</p>
<p>MHTML和Data URI还比较类似，有更强大的功能和更复杂的语法，并且没有Data URI中“无法被重复利用”的缺点，但MHTML使用起来不够灵活方便，比如对资源引用的URL在mht文件中可以是相对地址，否则必须是绝对地址。hedger在<a href="http://www.hedgerwow.com/360/dhtml/base64-image/demo.php">《Cross Browser Base64 Encoded Images Embedded in HTML》</a>针对IE的解决方案使用的是相对路径就是因为声明了<code>Content-type:message/rfc822</code>使IE按照MHTML来解析，如果不修改<code>Content-type</code>则需要使用MHTML协议，这个时候必须使用绝对路径，如<a href="http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/">《MHTML &#8211; when you need data: URIs in IE7 and under》</a>。</p>
<h3>应用</h3>
<p>Data URI和MHTML两者的配合可以完整的解决所有的主流浏览器，它们由于无法被缓存和重复利用的缺陷，所以并不适合直接在页面中使用，但在CSS和JavaScript文件中对图片适当地使用有非常大的优越性：</p>
<ol>
<li>大大减少请求数，现在大型网站的CSS引用了大量的图片资源。</li>
<li>CSS和JavaScript都可以被缓存，间接的实现了数据的缓存。</li>
<li>利用CSS可以解决Data URI的重复利用问题</li>
<li>告别<a href="http://www.alistapart.com/articles/sprites">CSS Sprites</a>，CSS Sprites的出现是为了减少请求数，但它除了<a href="http://blog.vlad1.com/2009/06/22/to-sprite-or-not-to-sprite/">带来在不确定情况下的异常</a>外，CSS Sprites还需要人为的图片合并，即使有合并工具也依旧必须人为地在如何有效的拼图上耗费大量的时间，并带来维护的困难。当你遵循一定的设计原则后，你就可以完全抛弃CSS Sprites来编写CSS，最后使用工具在上传到服务器环节把图片转换成Data URI和MHTML，如<a href="http://bluehua.org/tag/data-uri">《利用data-uri合并样式表和图片》</a>中用python实现的工具，这可以节约大量的时间。</li>
<li>base64编码把图片文件增加了1/3，Data URI和MHTML同时使用相当于增加了2/3，但CSS和JavaScript可以使用<a href="http://developer.yahoo.com/performance/rules.html#gzip">gzip压缩</a>，其可以节省2/3的数据量，所以使用gzip压缩后的最终数据量是<code>(1 + 1/3) * 2 * (1/3) = 8/9</code>，所以最终流量是减少的。</li>
</ol>
<p>为了方便在CSS中实现Data URI和MHTML，我写了一个<a href="http://dancewithnet.com/lab/2009/data-uri-mhtml/create.php" class="link-btn">Data URI &#038; MHTML 生成器</a>，你可以看利用其生成<a href="http://dancewithnet.com/lab/2009/data-uri-mhtml/create/1250345288.php">Data URI &#038; MHTML应用实例</a>。</p>
<p>在CSS文件中使用应用MHTML时URL必须使用绝对路径，导致非常不灵活，所以可以考虑使用CSS expression来解决（<a href="http://dancewithnet.com/lab/2009/data-uri-mhtml/create/1250347436.php">DEMO</a>），比如：</p>
<pre><code><span>   /*
   http://old9.blogsome.com/2008/10/26/css-expression-reloaded/
   http://dancewithnet.com/2009/07/27/get-right-url-from-html/
   */</span>
  *background-image:expression(function(ele){
    ele.style.backgroundImage = 'url(mhtml:' +
         document.getElementById('data-uri-css').getAttribute('href',4) +
         '!03114501408821761.gif)';
   }(this));
</code></pre>

<p><a href="http://feedads.g.doubleclick.net/~a/x7ctSQMF_iTTQrrp7nH7W4GmIZI/0/da"><img src="http://feedads.g.doubleclick.net/~a/x7ctSQMF_iTTQrrp7nH7W4GmIZI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/x7ctSQMF_iTTQrrp7nH7W4GmIZI/1/da"><img src="http://feedads.g.doubleclick.net/~a/x7ctSQMF_iTTQrrp7nH7W4GmIZI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/tCpPVflqXho" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/08/15/data-uri-mhtml/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/08/15/data-uri-mhtml/</feedburner:origLink></item>
		<item>
		<title>在HTML中获取正确的URL属性值</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/QjnFU-F9X2Y/</link>
		<comments>http://dancewithnet.com/2009/07/27/get-right-url-from-html/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 15:57:23 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[Javascript & DOM & AJAX]]></category>
		<category><![CDATA[getAttribute]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1462</guid>
		<description><![CDATA[在HTML中，常见的URL有多种表示方式：
相对URL：
    example.php
    demo/example.php
    ./example.php
    ../../example.php
    /example.php
绝对URL：
    http://dancewithnet.com/example.php
    http://dancewithnet.com:80/example.php
 ... ]]></description>
			<content:encoded><![CDATA[<p>在HTML中，常见的URL有多种表示方式：</p>
<pre><code>相对URL：
    example.php
    demo/example.php
    ./example.php
    ../../example.php
    /example.php
绝对URL：
    http://dancewithnet.com/example.php
    http://dancewithnet.com:80/example.php
    https://dancewithnet.com/example.php</code></pre>
<p>同时HTML中有大量的元素属性值为URL，一般利用JavaScript获取这些URL属性值有两种方法：</p>
<p><span id="more-1462"></span></p>
<pre><code>&lt;a href="example.php" id="example-a"&gt;此时页面绝对URL是http://dancewithnet.com/&lt;/a&gt;
&lt;script&gt;
var oA = document.getElementById('example-a');
oA.href ==  'http://dancewithnet.com/example.php';
oA.getAttribute('href') == 'example.php';
&lt;/script&gt;
</code></pre>
<p>我们希望通过直接访问属性的方式得到完整绝对URL，通过getAttribute方法得到其原始的属性值，实际上这是一个比较理想的结果，在所有的A级浏览器中，能顺利得到这个结果的只有Firefox和IE8，其他浏览器都或多或少特殊情况，具体哪些元素的属性存在什么样的情况请看<a href="http://dancewithnet.com/lab/2009/get-right-url-from-html/index.html" class="link-btn">演示实例</a>。</p>
<p>在大部分浏览器中存在的问题是，两种方式都返回的是原始属性值，而实际应用中往往需要的是其绝对的URL，<a href="http://www.sitepoint.com/blogs/2007/08/10/dealing-with-unqualified-href-values/">《Dealing with unqualified HREF values》</a>中的解决方案太过于复杂，这里提供一种相对简单的解决方案，如果不考虑区别浏览器代码会非常简单：</p>
<pre><code>&lt;form action="example.php" id="example-form"&gt;
此时页面绝对URL是http://dancewithnet.com/&lt;/form&gt;
&lt;script>
var oForm = document.getElementById('example-form');

<span>//IE6、IE7、Safari、Chrome、Opera</span>
oForm.action ==  'example.php';
oForm.getAttribute('action') == 'example.php';

<span>//获取绝对URL的通用解决方案</span>
getQualifyURL(oForm,'action') == 'http://dancewithnet.com/example.php';

getQualifyURL = function(oEl,sAttr){
  var sUrl = oEl[sAttr],
      oD,
      bDo = false;
  <span>//是否是IE8之前版本
  //http://www.thespanner.co.uk/2009/01/29/detecting-browsers-javascript-hacks/
  //http://msdn.microsoft.com/en-us/library/7kx09ct1%28VS.80%29.aspx
  /*@cc_on
    try{
      bDo = @_jscript_version < 5.8 ?true : @false;
    }catch(e){
      bDo = false;
    }
  @*/
  //如果是Safari、Chrome和Opera</span>
  if(/a/.__proto__=='//' || /source/.test((/a/.toString+''))
                               || /^function \(/.test([].sort)){
    bDo = true;
  }
  if(bDo){
    oD = document.createElement('div');
    <span>/*
    //DOM 操作得到的结果不会改变
    var oA = document.createElement('a');
    oA.href = oEl[sAttr];
    oD.appendChild(oA);
    */</span>
    oD.innerHTML = ['&lt;a href="',sUrl,'"&gt;&lt;/a&gt;'].join('');
    sUrl = oD.firstChild.href;
  }
  return sUrl;
}
&lt;/script&gt;
</code></pre>
<p>在IE6和IE7这两个史前的浏览器身上还有一些更有意思的事情，两种方法在HTML元素A、AREA和IMG获取的属性值都是绝对URL，幸好<a href="http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx">微软为getAttribute提供了第二个参数</a>可以解决这个问题，同时还可以对IFEAM和LINK元素解决前面提到的两种方法都返回原始属性的问题：</p>
<pre><code>&lt;link href="../../example.css" id="example-link"&gt;
&lt;a href="example.php" id="example-a"&gt;此时页面绝对URL是http://dancewithnet.com/&lt;/a&gt;

&lt;script&gt;
var oA = document.getElementById('example-a'),
     oLink = document.getElementById('example-link');

oA.href ==  'http://dancewithnet.com/example.php';
oA.getAttribute('href') == 'http://dancewithnet.com/example.php';
oA.getAttribute('href',2) == 'example.php';

oLink.href ==  'example.php';
oLink.getAttribute('href') == 'example.php';
oLink.getAttribute('href',4) == 'http://dancewithnet.com/example.php';
&lt;/script&gt;
</code></pre>

<p><a href="http://feedads.g.doubleclick.net/~a/nAMqlL64pdRuYq8Yhwebmq5JhIU/0/da"><img src="http://feedads.g.doubleclick.net/~a/nAMqlL64pdRuYq8Yhwebmq5JhIU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nAMqlL64pdRuYq8Yhwebmq5JhIU/1/da"><img src="http://feedads.g.doubleclick.net/~a/nAMqlL64pdRuYq8Yhwebmq5JhIU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/QjnFU-F9X2Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/07/27/get-right-url-from-html/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/07/27/get-right-url-from-html/</feedburner:origLink></item>
		<item>
		<title>用doctype激活浏览器模式</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/5wytCIFCfTg/</link>
		<comments>http://dancewithnet.com/2009/06/14/activating-browser-modes-with-doctype/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 07:19:36 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[doctype]]></category>
		<category><![CDATA[doctype嗅探]]></category>
		<category><![CDATA[dtd]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1457</guid>
		<description><![CDATA[为了处理根据Web标准创作的网页和根据在20世纪90年代末流行的陈旧实践创作的网页，现代的Web浏览器实现了各种不同的引擎模式。本文说明了那些模式是什么以及如何触发它们。
原文：Henri Siv... ]]></description>
			<content:encoded><![CDATA[<p>为了处理根据Web标准创作的网页和根据在20世纪90年代末流行的陈旧实践创作的网页，现代的Web浏览器实现了各种不同的引擎模式。本文说明了那些模式是什么以及如何触发它们。</p>
<p>原文：<a href="http://hsivonen.iki.fi/author/">Henri Sivonen</a>的<a href="http://hsivonen.iki.fi/doctype/">Activating Browser Modes with Doctype</a><sup>2009.05.19</sup></p>
<h3>文档范围</h3>
<p>本文包括的模式转换（mode switching）适用于Firefox和其他基于Gecko的浏览器，Safari、Chrome和其他基于Webkit的浏览器，Opera、 Konqueror、Mac版Internet Explorer、Windows版Internet Explorer和内嵌IE的浏览器。避免提及<a href="http://hsivonen.iki.fi/engines/">浏览器引擎的名字</a>，取而代之的是使用该引擎最知名浏览器的名字。</p>
<p>本文着重介绍模式的选择机制，而不是记录每个模式的确切行为。</p>
<p><span id="more-1457"></span></p>
<h3>模式</h3>
<p>以下是各种不同的模式：</p>
<h4>内容类型为text/html的模式</h4>
<p>text/html内容的模式选择取决于doctype嗅探（doctype sniffing，<a href="#sniffing">本文后面有讨论</a>）。在IE8中，模式也取决于其他因素。然而在IE8的默认情况下，那些不在微软提供黑名单上的非局域网（non- intranet）站点的模式取决于文档类型。</p>
<p>再怎么强调每个浏览器中模式精确行为的不同也是不过分的，即使本文中进行了统一的讨论。</p>
<dl>
<dt>怪癖模式（Quirks Mode）</dt>
<dd>怪癖模式中，为了避免“破坏”那些根据在20世纪90年代末流行的实践创作的页面，浏览器违反了现代的Web格式规范。不同的浏览器实现了不同的怪癖行为。Internet Explorer6、7和8中，怪癖模式有效地冻结在IE5.5 。其他浏览器中，怪癖模式是对准标准模式的少量偏移。
</dd>
<dd>如果正在创作新网页，你应该符合相关的规范（特别是CSS2.1）且使用标准模式。</dd>
<dd></dd>
<dt>标准模式（Standards Mode）</dt>
<dd>标准模式中，浏览器尝试给符合标准的文档在规范上的正确处理达到在指定浏览器中的程度。</dd>
<dd>不同的浏览器遵循不同的阶段，所以标准模式也不是一个单一目标。</dd>
<dd>HTML5把这种模式叫“非怪癖模式（no quirks mode）”</dd>
<dt>准标准模式（Almost Standards Mode）</dt>
<dd>irefox、Safari、Chrome、Opera(从7.5开始)和IE8也有个叫“准标准模式”的模式，它按照传统的做法来实现表格单元格的垂直尺寸而不是严格的遵照CSS2规范。Mac IE5、Windows IE6和7、Opera7.5以前版本和Konqueror无需准标准模式，因为它们至少没有在各自的标准模式下严格遵循CSS2规范来实现表格单元格垂直尺寸。实际上，它们的标准模式更接近Mozilla的准标准模式而不是Mozilla的标准模式。</dd>
<dd>HTML5把这种模式叫着“受限怪癖模式(limited quirks mode)”。</dd>
<dd></dd>
<dt>IE7模式</dt>
<dd>IE8有个模式主要是冻结了IE7标准模式的副本。其他浏览器没有像这样的模式，且该模式也未被HTML5指定。</dd>
</dl>
<h4>内容类型为application/xhtml+xml的模式（XML模式）</h4>
<p>Firefox、Safari、Chrome和Opera中，application/xhtml+xml HTTP内容类型（不是meta元素也不是doctype!）会触发XML模式。在XML模式中，浏览器尝试给XML文档在规范上的正确处理达到在制定浏览器中的程度。</p>
<p>IE6、7和8不支持application/xhtml+xml，Mac IE5也如此。</p>
<p>基于WebKit的Nokia S60 浏览器中，application/xhtml+xml HTTP内容类型不能触发XML模式，因为在移动的围墙花园（mobile walled gardens）中关注点是对不规范内容的兼容性。（<a href="http://simon.html5.org/articles/mobile-results">旧式的“移动浏览器”无法使用真正的XML解析器</a>，因为不规范内容已被标记为XML。）</p>
<p>由于没有充分地测试Konqueror，我无法确切说出在这个浏览器中会发生什么。</p>
<h4>非Web模式（Non-Web Modes）</h4>
<p>某些引擎拥有的模式与Web内容无关。为了完整性，它们仅仅在这里被提到。Opera有个WML2.0模式。Leopard上的WebKit有个用于旧式Dashboard widgets的特定模式。</p>
<h3>影响</h3>
<p>以下是这些模式的主要影响：</p>
<h4>布局</h4>
<p>text/html的模式主要是影响CSS布局。例如，表格不继承样式是个怪癖。在某些浏览器的怪癖模式下，盒模型（box model）变成IE5.5的盒模型。本文档没有列举出所有的布局怪癖。</p>
<p>准标准模式（有这种模式的浏览器中）中，仅包含图片的表格单元格的高和标准模式中不同。</p>
<p>XML模式中，选择器有不同的区分大小写行为。此外，用于HTML body元素的特有规则不能应用在那些没有实现最新CSS2.1改变的较旧版本的浏览器。</p>
<h4>解析</h4>
<p>也有一些怪癖影响HTML和CSS的解析且会导致符合标准的网页被错误解析。怪癖布局决定了这些怪癖是否开启。无论如何，了解怪癖模式和标准模式在CSS布局和解析（非HTML解析）上的主要异同是非常重要的。</p>
<p>一些人错误地把标准模式称为“严格解析模式（strict parsing mode）”，其让人误解了浏览器强制执行HTML语法规则和用浏览器评估标记的正确性。情况并非如此。即使当标准模式布局生效时，浏览器依旧会做标签杂烩汤（tag soup，http://en.wikipedia.org/wiki/Tag_soup）修正工作。（在2000年Netscape6发布前，Mozilla的确有用于强制执行HTML语法规则的解析模式。这些模式和现有的Web内容不兼容而被遗弃。）</p>
<p>另一个常见的误解是关于XHTML解析的。通常认为用XHTML doctype得到不同的解析。其实并非如此，内容类型是text/html的XHTML文档所用解析器和HTML文档的是同一个。目前浏览器在意的是文档类型为text/html的XHTML仅是“撒面包丁的标签杂烩汤（tag soup with croutons）”（到处是额外的斜线）。</p>
<p>仅当使用XML文档类型的文档（例如：application/xhtml+xml或xmapplication/）会触发XML模式来解析，这时的解析器完全不同于HTML解析器。</p>
<h4>脚本</h4>
<p>虽然怪癖模式主要是关于CSS的，但也有一些是关于脚本的。例如，Firefox的怪癖模式中，HTML id 属性像在IE一样建立了全局脚本作用域的对象引用。IE8中关于脚本的影响比其他浏览器更值得关注。</p>
<p>XML模式中，某些DOM API的行为彻底不同，因为XML的DOM API行为被定义时不兼容HTML的行为。</p>
<h3 id="sniffing">doctype嗅探（也叫doctype转换）</h3>
<p>现代浏览器使用doctype嗅探来决定text/html文档的引擎模式。这意味着模式的选择是基于HTML文档开始的文档类型声明（或缺少）。（这不适于使用XML文档类型的文档。）</p>
<p>文档类型声明（doctype）是SGML的语法伪造，SGML是个旧式的标记框架，HTML5之前的HTML就是依据其定义的。HTML4.01规范中，文档类型声明描述的是HTML的<a href="http://www.w3.org/TR/html4/struct/global.html#h-7.2">版本信息</a>。尽管名字叫“文档类型声明”且HTML 4.01规范所描述的是关于“版本信息”，文档类型声明并不适用把SGML或XML文档分类为特定类型的文档，即使它看起来像是（因为名字）。（<a href="#xml">更多内容在附录中</a>）</p>
<p>HTML4.01规范和ISO 8879（SGML）都没有说关于使用文档类型声明作为引擎模式转换的任何事情。doctype嗅探是基于观察，在doctype嗅探被设计时，绝大部分的怪癖文档既没有文档类型声明也没有引用旧的DTD。HTML5接受这个事实，且定义了text/html中doctype作为唯一的模式转换。</p>
<p>典型的预HTML5（pre-HTML5）文档类型声明包含（被空白分开）“&lt;!DOCTYPE”字符串，根元素（“html”）的通用标识符， “PUBLIC”字符串，处于引号中的DTD公共标识符，同一DTD的可能系统标识符（URL）和字符 “&gt;”。文档类型声明位于文档的根元素开始标签之前。</p>
<h3>选择doctype</h3>
<h4>text/html</h4>
<p>下面是创建新的text/html文档时如何选择doctype的简单指南：</p>
<dl>
<dt>标准模式，最前沿的验证</dt>
<dd><code>&lt;!DOCTYPE html&gt;</code></dd>
<dd>如果想<a href="http://html5.validator.nu/">验证</a>诸如<code>&lt;video&gt;</code>、<code>&lt;canvas&gt;</code>和ARIA这样的新特性，那么这样做是对的。注意，HTML5的有效定义依旧在变化中，请确保在Firefox、Safari、Chrome、Opera9或Opera10中测试图像对齐。在Internet Explorer中测试图像对齐是不足够的，无论如何请确保在IE8中也进行了测试。</dd>
<dt>标准模式，更稳定的验证目标</dt>
<dd><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;</code></dd>
<dd>这个doctype也会触发标准模式，且10岁大的HTML4.01有效定义是稳定的。请确保在Firefox、Safari、Chrome、 Opera9或Opera10中测试图像对齐。在Internet Explorer中测试图像对齐是不足够的，无论如何请确保在IE8中也进行了测试。</dd>
<dt>要使用标准模式，但仍要验证不推荐标记或在表格布局中使用切片图像且不想去修复它们。</dt>
<dd><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</code></dd>
<dd>它会触发准标准模式（和老掉牙的Mozilla中的完全标准模式full Standards mode）。请注意，如果以后移植到HTML5上，基于利用表格实现的切片图像的布局可能会<a href="http://www.mozilla.org/docs/web-developer/faq.html#gaps">被破坏</a>（且完整标准模式也如此）。</dd>
<dt>故意要使用怪癖模式</dt>
<dd>没有doctype。</dd>
<dd>请别这样做。故意为怪癖模式所做的设计将会困扰你，在将来你的同事或继任者甚至没有人关心Windows IE6（Netscape4.x和IE5已经没有人关心了）。为怪癖模式设计是个坏主意。相信我。</dd>
<dd>如果你想依旧支持Windows IE6，对它做一个特别的hack使用<a href="http://www.quirksmode.org/css/condcom.html">条件注释</a>比使其他浏览器退步到怪癖模式好。</dd>
</dl>
<p>我不推荐任何的XHTML doctype，因为<a href="http://hixie.ch/advocacy/xhtml">XHTML被用作text/html被认为是有害的</a>。无论如何，如果你选择使用XHTML doctype，请注意XML声明会使IE6（但不是IE7！）触发怪癖模式。</p>
<h4>application/xhtml+xml</h4>
<p>对application/xhtml+xml的简单指南是绝不使用doctype。该方式下的网页不是“严格一致”的XHMTL1.0，但这并不重要。（请看后面的<a href="#xml">附录</a>）</p>
<h3>IE8 并发症</h3>
<p><a href="http://www.alistapart.com/articles/beyonddoctype">A List Apart 曾介绍</a> ，IE8除doctype外会使用基于meta元素的模式转换作为模式选择的因素之一。（请看<a href="http://ln.hixie.ch/?start=1201080691&#038;count=1">Ian Hickson</a>、<a href="http://lists.w3.org/Archives/Public/public-html/2007Apr/0279.html">David Baron</a>、<a href="http://dbaron.org/log/2008-01#e20080124a">David Baron again</a>、<a href="http://weblogs.mozillazine.org/roc/archives/2008/01/post_2.html">Robert O’Callahan</a> 和 <a href="http://webkit.org/blog/155/versioning-compatibility-and-standards/">Maciej Stachowiak</a>的评论。）</p>
<p>IE8有4种模式：IE5.5怪癖模式、IE7标准模式、IE8 准标准模式 和IE8标准模式。模式的选择取决于来自几个方面的数据：doctype、meta元素、HTTP头、来自微软的定期下载数据、局域网域、用户所做设置、局域网管理员所做设置、父框架的模式（如果有）和地址栏兼容视图按钮被用户触发。（对于嵌入该引擎的其他应用，模式也取决于嵌入的应用。）</p>
<p>幸运的是如果出现下列情况，IE8大体上会像其他浏览器一样使用doctype嗅探：</p>
<ul class="circle">
<li>作者没有设置X-UA-Compatible HTTP头</li>
<li>作者没有设置X-UA-Compatible meta标签</li>
<li>微软没有在黑名单中放置该站点的域名</li>
<li>局域网管理员没有把该站点放置到<a href="http://go.microsoft.com/fwlink/?LinkId=145413">黑名单</a>上</li>
<li>用户没有按下兼容视图按钮（Compatibility View button） (或以其他方式添加到某个特定的用户黑名单中)</li>
<li>该站点不在局域网域中</li>
<li>用户没有选择在IE7中显示所有站点</li>
<li>页面没有通过frame嵌入到兼容模式的页面中</li>
</ul>
<p>上述除两个关于X-UA-Compatible的情况外，IE8像IE7一样执行doctype嗅探。IE7仿真（ IE7 emulation）叫兼容视图。</p>
<p>在 X-UA-Compatible 情况下，IE8的行为和其他浏览器完全不同。想看本页的<a href="#ie8modes">附录</a>或<a href="http://hsivonen.iki.fi/doctype/ie8-mode.pdf">PDF</a>和<a href="http://hsivonen.iki.fi/doctype/ie8-mode.png">PNG</a>格式的流程图。</p>
<p>不幸的是，没有 X-UA-Compatible的HTTP头或meta标签，即使使用了合适的doctype，IE8让用户无意间使页面从IE8的标准模式降到IE7模式，这是一种仿真的IE7标准模式。更糟糕的是，局域网管理员也可以这么做。微软也可以把你所用的所有域名到列入黑名单。</p>
<p>为了对付这些影响，doctype是不够的，你需要X-UA-Compatible HTTP头和meta标签。</p>
<p>下面的简单指南是针对已经有doctype在其他浏览器触发标准模式或者准标准模式的新的text/html文档如何选择X-UA-Compatible HTTP头或meta标签的：
</p>
<dl>
<dt>你的域名没有在微软的黑名单上，你更关注是没有浏览器专属的令人讨厌的东西而不是确保用户无法回退去呈现IE7的行为。</dt>
<dd>你不需要包括X-UA-Compatible HTTP头或meta标签。</dd>
<dt>你的域名在微软的黑名单中，由于你域名中的其他作者破坏了站点或许导致用户对整个域启用了兼容视图，你担心Google或Digg用frame嵌入你的站点或你想确保用户无法使用兼容视图</dt>
<dd>首先，在你的页面包含后面的meta元素（它在HTML5中是非法的） <code>&lt;meta http-equiv="X-UA-Compatible" content="IE=Edge"&gt;</code> （在任何脚本元素前），或者设置后面的HTTP头：X-UA-Compatible: IE=Edge</dd>
<dt>你的站点在IE7中工作但在IE8中破坏</dt>
<dd>首先，在你的页面包含后面的meta元素（它在HTML5中是非法的）<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">（在任何脚本元素前），或者设置后面的HTTP头： X-UA-Compatible: IE=EmulateIE7，然后修复你的站点不依赖非标准的IE7行为和迁移到IE=Edge。</dd>
</dl>
<h3>相关链接</h3>
<ul>
<li>Eric Meyer在<a href="http://www.oreillynet.com/pub/a/network/2000/04/14/doctype/index.html">使用正确doctype</a>中写的关于Mac IE5的模式</li>
<li><a href="http://www.mozilla.org/docs/web-developer/quirks/doctypes.html">Mozilla的doctype嗅探</a> by David Baron</li>
<li>Lance Silver在<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie60/html/cssenhancements.asp">IE6中的CSS增强</a>中讨论了在Windows IE6中的模式和doctype嗅探</li>
<li><a href="http://www.opera.com/docs/specs/doctype/">Opera9的doctype转换</a></li>
<li>Faruk Ateş的<a href="http://farukat.es/journal/2009/05/245-ie8-and-the-x-ua-compatible-situation">IE8和X-UA-Compatible解决方案</a></li>
</ul>
<h3 id="xml">补遗：对XML的实现者和规范作者的恳求</h3>
<p>请不要把doctype嗅探带到XML。</p>
<p>doctype嗅探是用签杂烩汤似的方法解决一个标签杂烩汤问题。doctype嗅探是在HTML4和CSS2规范发布后设计的一种试探方法，它从文档中区分出过时文档以符合其作者可能期望的行为。</p>
<p>偶尔有人建议在XML上使用doctype嗅探来调度不同的处理、识别正在使用的词汇表或激活特性。这是个坏主意。调度和词汇表识别应该是基于名字空间的，而特性激活应该是基于明确的处理指令或元素。</p>
<p>良构（well-formedness）的整个思想是介绍允许XML的无DTD解析，且推广无doctype文档。在正式情况下，两个XML文档有相同的规范形式且应用不同地处理它们（且不同之处并非因为没有选择处理外部实体），这个应用或许被破坏了。在实践情况下，如果两个XML文档导致同样的内容被报告（qnames忽略）给SAX2<a href="http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html">内容处理器</a>且应用不同地处理文档，这个应用或者被破坏了。考虑到作为 Web作者无法相信每个人都会使用解决额外实体的XMLprocessor来解析其页面（即使一些浏览器看起来这样做，因为它们会映射一定公共的标识符到一个有删节的定义实体的DTD），插入doctype到XML中用于Web是毫无意义的且通常会导致货运崇拜（cargo cultish）习惯。(您仍然使用W3C验证器的<a href="http://validator.w3.org/docs/users.html#option-doctype">DTD覆盖功能</a>来对一个DTD进行验证，虽然W3C验证器会说结果仅仅是暂时有效。或更好的是，你可以用<a href="http://validator.nu/">放宽NG验证</a>，它不会污染模式引用的文档。)为了嗅探而要求doctype是非常愚蠢的，即使那是在HTML实践中的解决方法。</p>
<p>此外，当低级别的规范定义两个相等的东西时，高级别的规范不应该尝试给它们不同的含义。请考虑<code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</code>。如果删除公共标识符，依旧指定了同样的DTD，因此doctype <code>&lt;!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</code>表示和前面的doctype一样。应该不同地嗅探它们么？可以进一步理论。假设复制给example.com一个叫foobar.dtd的DTD：<code>&lt;!DOCTYPE html SYSTEM "http://example.com/foobar.dtd"&gt;</code>。这该如何嗅探？应该是同一个意思。甚至整个DTD可以贴在文档中。</p>
<p>换句话说，如果有#include &#8220;foo.h&#8221;，你不应该给名字foo.h绑定任何black magic，因为它应该允许复制foo.h的内容到文档中或复制foo.h到bar.h中且表示#include &#8220;bar.h&#8221;。</p>
<p>我不担心HTML和SGML构造相同的参数的原因是Web浏览器不会使用真正的SGML解析器去解析HTML，所以我认为伪装成SGML进行处理是没有用的。无论如何，如果你还不相信，请看<a href="http://groups.google.com/group/comp.text.sgml/msg/c3e53dee2c152a81">W. Eliot Kimber关于此事的文章 comp.text.sgml</a> </p>
<h3>附录：text/html中一些doctype的处理方式</h3>
<p>下表中，怪癖模式、标准模式和准标准分别表示为Q、S和A。当浏览器仅有两种模式时，如果表格单元格的行高和Mozilla的标准模式表现一致时，标准模式标记为“S”，如果表格单元格的行高和Mozilla的准标准模式表现一致时，则标记为“A”。</p>
<p>请注意使用XML内容模型提供服务的XHTML在XML模式下渲染。</p>
<p>本表的目的并不是说表中所有的doctype都是新建页面的合理选择。本表的目的是为了展示我的推荐是依据什么样的数据。</p>
<p>下列的简写符号是用于列标题：</p>
<dl>
<dt>NS6</dt>
<dd>Mozilla 0.6…0.9.4 和 Netscape 6.0…6.2.3</dd>
<dt>Old Moz</dt>
<dd>Mozilla 0.9.5 到 1.1 alpha 和 Mozilla 1.0</dd>
<dt>Moz &#038; Safari &#038; Opera 10 &#038; HTML5</dt>
<dd>Mozilla 1.0.1, Mozilla 1.1 beta和更高版本, Firefox 到 Netscape 7, Safari 0.9 到 Safari 4.0 beta, Opera 10, Chrome, Konqueror 3.5, HTML5指定的行为</dd>
<dt>Opera 9.0</dt>
<dd>Opera 9.0…9.20</dd>
<dt>IE 8 &#038; Opera 9.5</dt>
<dd>无 X-UA-Compatible和兼容模式覆盖的默认IE8（该情况下“A”意味着IE8准标准模式）、 Opera 7.5…8.54 和 9.5…9.6</dd>
<dt>IE 7 &#038; Opera 7.10</dt>
<dd>IE7、兼容模式且无X-UA-Compatible覆盖的IE8（这种情况下“A”意味IE7模式）和Opera 7.10…7.23</dd>
<dt>IE 6 &#038; Opera 7.0</dt>
<dd>Windows IE 6 和 Opera 7.0…7.03</dd>
<dt>Mac IE 5</dt>
<dd>Mac IE 5.0…5.2.3</dd>
<dt>Konq 3.2</dt>
<dd>Konqueror 3.2.2…3.3 (也可能包括 3.1…3.2.1; 我尚未确定)</dd>
</dl>
<table class="small stat">
<thead>
<tr>
<th>Doctype</th>
<th>NS6 </th>
<th>Old Moz </th>
<th>Moz &amp; Safari &amp; Opera10 &amp; HTML5</th>
<th>Opera9.0</th>
<th>IE8 &amp; Opera9.5 </th>
<th>IE7 &amp; Opera7.10 </th>
<th>IE6 &amp; Opera7.0 </th>
<th>Mac IE5 </th>
<th>Konq3.2 </th>
</tr>
</thead>
<tbody>
<tr>
<th> <a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=">None</a>
      </th>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+3.2+Final%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.0%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.0%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Fstrict.dtd%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"<br />
"http://www.w3.org/TR/html4/strict.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Fstrict.dtd%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"<br />
"http://www.w3.org/TR/html4/strict.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.0+Transitional%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01+Transitional%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Floose.dtd%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2F1999%2FREC-html401-19991224%2Floose.dtd%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<br />
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"&gt;</a></code></p>
</th>
<td class="quirks">Q</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.0+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Floose.dtd%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"<br />
"http://www.w3.org/TR/html4/loose.dtd"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.1%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml11%2FDTD%2Fxhtml11.dtd%22%3E">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+Basic+1.0%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml-basic%2Fxhtml-basic10.dtd%22%3E">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Strict%2F%2FEN%22+%22http%3A%2F %2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd%22%3E">&lt;!DOCTYPE<br />
html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</a></code>
      </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.1%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml11%2FDTD%2Fxhtml11.dtd%22%3E">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+Basic+1.0%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml-basic%2Fxhtml-basic10.dtd%22%3E">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Strict%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd%22%3E">&lt;?xml<br />
version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E">&lt;?xml<br />
version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</a></code></p>
</th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22ISO%2FIEC+15445%3A2000%2F%2FDTD+HTML%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "ISO/IEC 15445:2000//DTD HTML//EN"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22ISO%2FIEC+15445%3A2000%2F%2FDTD+HyperText+Markup+Language%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "ISO/IEC 15445:2000//DTD HyperText Markup<br />
Language//EN"&gt;</a></code> </th>
<td class="quirks">Q</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22ISO%2FIEC+15445%3A1999%2F%2FDTD+HTML%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "ISO/IEC 15445:1999//DTD HTML//EN"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href="http://hsivonen.iki.fi/doctype/test-quirks.php?doctype=%3C%21DOCTYPE+HTML+PUBLIC+%22ISO%2FIEC+15445%3A1999%2F%2FDTD+HyperText+Markup+Language%2F%2FEN%22%3E">&lt;!DOCTYPE<br />
HTML PUBLIC "ISO/IEC 15445:1999//DTD HyperText Markup<br />
Language//EN"&gt;</a></code> </th>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="quirks">Q</td>
</tr>
<tr>
<th><code><a href='test-quirks.php?doctype=%3C%21DOCTYPE+html%3E'>&lt;!DOCTYPE html&gt;</a></code></th>
<td class="quirks">Q</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="standards">S</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td class="almost">A</td>
<td></td>
</tr>
</tbody>
</table>
<h4>历史记录</h4>
<p>Moziila的doctype嗅探代码在2000年10月、2001年9月和2002年6月有大幅度的修改。本文档描述的Mozilla（和 Netscape 6.x）建立的状态可以自2000.10.19起在ftp.mozilla.org上看到。本文档未涉及Mozilla M18（和Netscape 6.0 PR3）中的doctype嗅探的工作方式。Safari的doctype嗅探代码自第一个公开的测试版起也有大幅度的修改。本文档不包括比版本V73也叫0.9更早的行为。
</p>
<p>Konqueror3.5之前的doctype嗅探代码似乎来自于Safari的很早的一个版本。Konqueror现在和Safari匹配，其doctype嗅探代码来自Mozilla。</p>
<p>从表中可见，Opera的doctype嗅探正由规律的从类似IE向类似Mozilla转变，虽然Opera9.5和9.6在倒退的路上。同时，Opera怪癖模式的布局行为已从仿效IE6的怪癖模式转换到Mozilla的怪癖模式。</p>
<h3 id="ie8modes">附录：IE8的模式选择</h3>
<dl>
<dt>开始：进入“X-UA-Compatible meta?”</dt>
<dt>X-UA-Compatible meta?</dt>
<dd>IE=7：使用IE7标准</dd>
<dd>IE=EmulateIE7: 进入“怪癖或无doctype?(兼容模式)”</dd>
<dd>IE=IE8 或 IE=IE7 或 IE=a 或 IE=EmulateIE8 或没有或首先出现 script：进入&#8221;X-UA-Compatible HTTP头?&#8221;</dd>
<dd>IE=8 或 IE=Edge 或 IE=99 或 IE=9.9：进入“准标准模式?”</dd>
<dd>IE=5：使用怪癖模式（IE5.5）</dd>
<dt>X-UA-Compatible HTTP头?</dt>
<dd>IE=7：使用IE7标准模式</dd>
<dd>IE=EmulateIE7：进入“怪癖或无doctype？（兼容模式）”</dd>
<dd>IE=IE8 或 IE=IE7 或 IE=a 或 IE=EmulateIE8 或没有：进入“显示所有站点…预设置？”</dd>
<dd>IE=8 或 IE=Edge 或 IE=99 或 IE=9.9：进入“准标准模式？”</dd>
<dd>IE=5：使用怪癖模式（IE5.5）</dd>
<dt>怪癖模式或无doctype?(兼容模式)</dt>
<dd>是：使用怪癖模式（IE5.5）</dd>
<dd>否：使用IE7标准模式</dd>
<dt>显示所有站点…预设置？</dt>
<dd>是：进入“怪癖模式或无doctype?(兼容模式)”</dd>
<dd>否：进入“显示局域网站点…预设置？”</dd>
<dt>显示局域网站点…预设置？</dt>
<dd>是：进入“站点位于局域网域？”</dd>
<dd>否：进入“域名在微软维护的名单上？”</dd>
<dt>域名在微软维护的名单上？</dt>
<dd>是：进入“怪癖模式或无doctype?(兼容模式)”</dd>
<dd>否：进入“被兼容模式页面用Frame嵌入？”</dd>
<dt>被兼容模式页面用Frame嵌入？</dt>
<dd>是：进入“怪癖模式或无doctype?(兼容模式)”</dd>
<dd>否：进入“按下了兼容模式按钮？”</dd>
<dt>按下了兼容模式按钮？</dt>
<dd>是：进入“怪癖模式或无doctype?(兼容模式)”</dd>
<dd>否：进入“怪癖模式或无doctype?(IE8)”</dd>
<dt>怪癖模式或无doctype?(IE8)</dt>
<dd>是：进入“使用怪癖模式（IE5.5）”</dd>
<dd>否：进入“准标准模式？”</dd>
<dt>准标准模式？</dt>
<dd>是：使用IE8准标准模式</dd>
<dd>否：使用IE8标准模式</dd>
</dl>
<p>这些步骤都可以通过<a href="http://hsivonen.iki.fi/doctype/ie8-mode.pdf">PDF</a>和<a href="http://hsivonen.iki.fi/doctype/ie8-mode.png">PNG</a>格式的流程图看到。</p>
<h3>鸣谢</h3>
<p>感谢Simon Pieters、Simon Pieters和Anne van Kesteren帮助我改正了各种Opera版本的模式表和他们的评论。感谢Simon Pieters制作了另一份IE8的流程图。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/WVTZRV9N9xURAzxZqzvam3PWcYs/0/da"><img src="http://feedads.g.doubleclick.net/~a/WVTZRV9N9xURAzxZqzvam3PWcYs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/WVTZRV9N9xURAzxZqzvam3PWcYs/1/da"><img src="http://feedads.g.doubleclick.net/~a/WVTZRV9N9xURAzxZqzvam3PWcYs/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/5wytCIFCfTg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/06/14/activating-browser-modes-with-doctype/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/06/14/activating-browser-modes-with-doctype/</feedburner:origLink></item>
		<item>
		<title>炒土豆片</title>
		<link>http://feedproxy.google.com/~r/dancewithnet/~3/ez6uhZv9LCM/</link>
		<comments>http://dancewithnet.com/2009/05/30/fried-potato-chips/#comments</comments>
		<pubDate>Sat, 30 May 2009 15:04:56 +0000</pubDate>
		<dc:creator>秦歌</dc:creator>
				<category><![CDATA[爱厨房爱美食]]></category>
		<category><![CDATA[厨艺]]></category>
		<category><![CDATA[土豆]]></category>
		<category><![CDATA[美食]]></category>
		<category><![CDATA[花椒]]></category>
		<category><![CDATA[菜谱]]></category>

		<guid isPermaLink="false">http://dancewithnet.com/?p=1453</guid>
		<description><![CDATA[原料

土豆：学名是马铃薯，“土豆”是方言说法。
花椒：别名香椒、大花椒、青椒、青花椒、山椒、狗椒、蜀椒、川椒、红椒、红花椒、大红袍，因其味麻，又称作麻椒
香葱
植物油、盐


作... ]]></description>
			<content:encoded><![CDATA[<h3>原料</h3>
<ol>
<li>土豆：学名是马铃薯，“土豆”是方言说法。</li>
<li>花椒：别名香椒、大花椒、青椒、青花椒、山椒、狗椒、蜀椒、川椒、红椒、红花椒、大红袍，因其味麻，又称作麻椒</li>
<li>香葱</li>
<li>植物油、盐</li>
</ol>
<p><span id="more-1453"></span></p>
<h3>作法</h3>
<ol>
<li>土豆去皮后切成薄片，用水浸泡，临用时捞出沥干</li>
<li>倒入适量的油，旺火烧之六成热</li>
<li>撒入适量花椒，有花椒香味溢出时，立即倒入土豆片翻炒之，如果能颠锅就更好了</li>
<li>待土豆片稍软且弱有透明时，撒入适当的食盐，继续翻炒</li>
<li>片刻后，关火出锅</li>
</ol>
<p class="noIndent"><img src="http://dancewithnet.com/wp-content/uploads/2009/05/fried-potato-chips.jpg" alt="炒土豆片" title="炒土豆片" width="640" height="480" class="alignnone size-full wp-image-1454" /></p>
<h3>注意</h3>
<ol>
<li>凡腐烂、霉烂或生芽较多的土豆，因含过量龙葵素，极易引起中毒，一律不能食用。</li>
<li>土豆宜去皮吃，有芽眼的部分应挖去，以免中毒。</li>
<li>土豆切开后容易氧化变黑，属正常现象，不会造成危害。</li>
<li>把切好的土豆片、土豆丝放入水中，这样避免了其氧化变黑，又可以去掉太多的淀粉避免炒糊。但注意不要泡得太久而致使水溶性维生素等营养流失。</li>
</ol>
<h3>营养</h3>
<p>土豆味甘、性平、微凉，入脾、胃、大肠经；有和胃调中，健脾利湿，解毒消炎，宽肠通便，降糖降脂，活血消肿，益气强身，美容，抗衰老之功效。主治胃火牙痛、脾虚纳少、大便干结、高血压、高血脂等病症；还可辅助治疗消化不良、习惯性便秘、神疲乏力、慢性胃痛、关节疼痛、皮肤湿疹等症。</p>
<p>花椒除各种肉类的腥气；促进唾液分泌，增加食欲；使血管扩张，从而起到降低血压的作用；服花椒水能去除寄生虫；有芳香健胃、温中散寒、除湿止痛、杀虫解毒、止痒解腥的功效。 </p>
<p>香葱有助消化、解热、通便的作用。</p>

<p><a href="http://feedads.g.doubleclick.net/~a/G5ZdxrG_DtHdPHmWCl7F8zuNY9A/0/da"><img src="http://feedads.g.doubleclick.net/~a/G5ZdxrG_DtHdPHmWCl7F8zuNY9A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/G5ZdxrG_DtHdPHmWCl7F8zuNY9A/1/da"><img src="http://feedads.g.doubleclick.net/~a/G5ZdxrG_DtHdPHmWCl7F8zuNY9A/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/dancewithnet/~4/ez6uhZv9LCM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://dancewithnet.com/2009/05/30/fried-potato-chips/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://dancewithnet.com/2009/05/30/fried-potato-chips/</feedburner:origLink></item>
	</channel>
</rss>
