<?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>71街 &#187; html</title>
	<atom:link href="http://www.71j.cn/archives/tag/html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.71j.cn</link>
	<description>杜工的技术博客</description>
	<lastBuildDate>Fri, 16 Dec 2011 03:52:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>重视HTML文件头部声明</title>
		<link>http://www.71j.cn/archives/136</link>
		<comments>http://www.71j.cn/archives/136#comments</comments>
		<pubDate>Thu, 04 Feb 2010 02:37:50 +0000</pubDate>
		<dc:creator>杜工</dc:creator>
				<category><![CDATA[感悟]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://71j.cn/?p=136</guid>
		<description><![CDATA[以前处理页面，习惯&#8230;这样写下去，后来W3C开始流行，发现好多好玩的东西在这样的标签下都不支持了，比如样式表中让元素居中的写法，margin:0 auto; 于是只好使用这样的写法了： &#60;!&#8211... ]]></description>
			<content:encoded><![CDATA[<p>以前处理页面，习惯&#8230;这样写下去，后来W3C开始流行，发现好多好玩的东西在这样的标签下都不支持了，比如样式表中让元素居中的写法，margin:0 auto;<br />
于是只好使用这样的写法了：</p>
<p>&lt;!&#8211;CTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt&#8211;&gt;</p>
<p>再写一个函数，比如原来的documeng.body.scrollTop在原有写法上是奏效的，但到了新标准中就会变为0，只好多加一些判断：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getSrollTop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> scrollPos<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> window.<span style="color: #660066;">pageYOffset</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
scrollPos <span style="color: #339933;">=</span> window.<span style="color: #660066;">pageYOffset</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> document.<span style="color: #660066;">compatMode</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">&amp;&amp;</span>
document.<span style="color: #660066;">compatMode</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'BackCompat'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
scrollPos <span style="color: #339933;">=</span> document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> document.<span style="color: #660066;">body</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
scrollPos <span style="color: #339933;">=</span> document.<span style="color: #660066;">body</span>.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> scrollPos<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.71j.cn/archives/136/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

