<?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>潔靜精微 &#187; 前端</title>
	<atom:link href="http://julabs.me/blog/category/front/feed/" rel="self" type="application/rss+xml" />
	<link>http://julabs.me/blog</link>
	<description>想努力创造完美的东西，必须具备心灵的纯洁，同时富于宗教精神。</description>
	<lastBuildDate>Wed, 18 Jan 2012 06:34:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>用JavaScript操作important样式</title>
		<link>http://julabs.me/blog/control-important-style-javascript/</link>
		<comments>http://julabs.me/blog/control-important-style-javascript/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 13:20:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[cssText]]></category>
		<category><![CDATA[important]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=381</guid>
		<description><![CDATA[一般用JavaScript来控制元素样式的代码如下： document.getElementById(&#34;someDom&#34;).style.color=&#34;#f00&#34;; 但对于已经设置了“important”属性样式的元素，这一句就起不了作用了，就必须用到另一个属性：cssText，代码如下： document.getElementById(&#34;someDom&#34;).style.cssText=&#34;color:#f00 !important&#34;; // 用jQuery更方便 $(&#34;#someDom&#34;).css(&#34;cssText&#34;,&#34;color:#f00 !important&#34;); 但cssText也有个缺点，它会覆盖掉以前的inline样式，可以用累加的方式得以保留原有样式。代码如下： var elem = document.getElementById(&#34;someDom&#34;); elem.style.cssText +=&#34;;color:#f00 !important&#34;; 注意上面的累加语句等号右侧的“;”千万不能少，因为IE的cssText属性会默认去掉最后一个“;”，所以如果累加的话一定要重新加上。]]></description>
			<content:encoded><![CDATA[<p>一般用JavaScript来控制元素样式的代码如下：</p>
<pre><code class="javascript">
document.getElementById(&quot;someDom&quot;).style.color=&quot;#f00&quot;;
</code></pre>
<p>但对于已经设置了“important”属性样式的元素，这一句就起不了作用了，就必须用到另一个属性：<strong>cssText</strong>，代码如下：</p>
<pre><code class="javascript">
document.getElementById(&quot;someDom&quot;).style.cssText=&quot;color:#f00 !important&quot;;

// 用jQuery更方便
$(&quot;#someDom&quot;).css(&quot;cssText&quot;,&quot;color:#f00 !important&quot;);
</code></pre>
<p>但<strong>cssText</strong>也有个缺点，它会覆盖掉以前的inline样式，可以用累加的方式得以保留原有样式。代码如下：</p>
<pre><code class="javascript">
var elem = document.getElementById(&quot;someDom&quot;);
elem.style.cssText +=&quot;;color:#f00 !important&quot;;
</code></pre>
<p>注意上面的累加语句等号右侧的“<strong>;</strong>”千万不能少，因为<abbr title="Internet Explorer">IE</abbr>的<strong>cssText</strong>属性会默认去掉最后一个“<strong>;</strong>”，所以如果累加的话一定要重新加上。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/control-important-style-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS只允许数字输入</title>
		<link>http://julabs.me/blog/accept-only-number-input/</link>
		<comments>http://julabs.me/blog/accept-only-number-input/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 15:04:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[数字]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=371</guid>
		<description><![CDATA[假设有个ID值为“i_text”的text控件，为其设置只允许数字输入的代码： document.getElementById(&#34;i_text&#34;).onkeypress = function(e){ var e = e &#124;&#124; window.event, //获得事件 k = e.which &#124;&#124; e.keyCode; // 获得 keyCode 值 /** * 8 为退格健 * 0 为上、下、左、右方向健 * 48 为 0 健，57 为 9 健 * 48 到57 健分别是0,1,2,3,4,5,6,7,8,9 * &#8230; <a href="http://julabs.me/blog/accept-only-number-input/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>假设有个ID值为“<strong>i_text</strong>”的<strong>text</strong>控件，为其设置只允许数字输入的代码：</p>
<pre><code class="javascript">
document.getElementById(&quot;i_text&quot;).onkeypress = function(e){
	var e = e || window.event, //获得事件
	k = e.which || e.keyCode; // 获得 keyCode 值
	/**
	 * 8 为退格健
	 * 0 为上、下、左、右方向健
	 * 48 为 0 健，57 为 9 健
	 * 48 到57 健分别是0,1,2,3,4,5,6,7,8,9
	 * . 点号的keyCode为 46，如果需要输入小数
	 * - 减号的keyCode为 45，如果需要输入负数
	*/
	if(k!=8 &amp;&amp; k!=0 &amp;&amp; (k&lt;48 || k&gt;57)){
		return false;
	}
}
</code></pre>
<p>注释代码中已经给出了，需要指出的是<abbr title="Internet Explorer 8">IE8</abbr>目前只支持<strong>keyCode</strong>，<abbr title="Internet Explorer 9">IE9</abbr>还没有试。如果使用<a href="http://jquery.com/" target="_blank">jQuery</a>那就更简单了，代码如下：</p>
<pre><code class="javascript">
$(&quot;#i_text&quot;).bind('keypress',function(e){
	var k = e.which;
	if(k!=8 &#038;&#038; k!=0 &#038;&#038; (k&lt;48 || k&gt;57)){
		return false;
	}
});
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/accept-only-number-input/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>window.location的用法</title>
		<link>http://julabs.me/blog/javascript-window-location/</link>
		<comments>http://julabs.me/blog/javascript-window-location/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 16:44:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[location]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=364</guid>
		<description><![CDATA[参考地址：window.location 工作中经常要对window.location进行相关的操作，在这里列出它的属性和方法，方便查找。现以链接http://julabs.me:8080/blog/front/javascript-window-location.html?author=julabs#comment为例来讲解window.location的属性： 属性 详解 例样 hash URL中在“#”号后面的部分，包括“#”在内 #comment host 主机名和端口号 julabs.me:8080 hostname 主机名，不包括端口号 julabs.me href 整个URL地址 http://julabs.me:8080/blog/front/javascript-window-location.html?author=julabs#comment pathname 相对于主机名和端口号的路径 /blog/front/javascript-window-location.html port 地址的端口号 8080 protocol 地址的协议 http:// search URL中在“?”号后面的部分，包括“?”在内 ?author=julabs 下表列出的是window.location的方法： 方法 详解 assign(url) 根据参数url所提供的地址来载入相应的页面 reload(forceget) 重载当前的页面，参数forceget是个boolean类型的值。当forceget为true时，页面会请求从服务器载入，如果为false则直接从缓存载入，默认为false replace(url) 将当前页面替换成参数url所对应的页面。与assign()方法的差别就在于，replace()方法不会将前一个页面地址保存在历史记录中，所以也就不能通过返回按钮回到前一个地址页面 toString() 返回Location所对应的URL值，相当于window.location.href]]></description>
			<content:encoded><![CDATA[<p>参考地址：<a href="https://developer.mozilla.org/en/DOM/window.location" target="_blank">window.location</a></p>
<p>工作中经常要对<strong>window.location</strong>进行相关的操作，在这里列出它的属性和方法，方便查找。现以链接<strong>http://julabs.me:8080/blog/front/javascript-window-location.html?author=julabs#comment</strong>为例来讲解<strong>window.location</strong>的属性：</p>
<table>
<thead>
<tr>
<th>属性</th>
<th>详解</th>
<th>例样</th>
</tr>
</thead>
<tbody>
<tr>
<td>hash</td>
<td>URL中在“#”号后面的部分，包括“#”在内</td>
<td>#comment</td>
</tr>
<tr>
<td>host</td>
<td>主机名和端口号</td>
<td>julabs.me:8080</td>
</tr>
<tr>
<td>hostname</td>
<td>主机名，不包括端口号</td>
<td>julabs.me</td>
</tr>
<tr>
<td>href</td>
<td>整个URL地址</td>
<td>http://julabs.me:8080/blog/front/javascript-window-location.html?author=julabs#comment</td>
</tr>
<tr>
<td>pathname</td>
<td>相对于主机名和端口号的路径</td>
<td>/blog/front/javascript-window-location.html</td>
</tr>
<tr>
<td>port</td>
<td>地址的端口号</td>
<td>8080</td>
</tr>
<tr>
<td>protocol</td>
<td>地址的协议</td>
<td>http://</td>
</tr>
<tr>
<td>search</td>
<td>URL中在“?”号后面的部分，包括“?”在内</td>
<td>?author=julabs</td>
</tr>
</tbody>
</table>
<p>下表列出的是<strong>window.location</strong>的方法：</p>
<table>
<thead>
<tr>
<th>方法</th>
<th>详解</th>
</tr>
</thead>
<tbody>
<tr>
<td>assign(url)</td>
<td>根据参数<strong>url</strong>所提供的地址来载入相应的页面</td>
</tr>
<tr>
<td>reload(forceget)</td>
<td>重载当前的页面，参数<strong>forceget</strong>是个<strong>boolean</strong>类型的值。当<strong>forceget</strong>为<strong>true</strong>时，页面会请求从服务器载入，如果为<strong>false</strong>则直接从缓存载入，默认为<strong>false</strong></td>
</tr>
<tr>
<td>replace(url)</td>
<td>将当前页面替换成参数<strong>url</strong>所对应的页面。与<strong>assign()</strong>方法的差别就在于，<strong>replace()</strong>方法不会将前一个页面地址保存在历史记录中，所以也就不能通过返回按钮回到前一个地址页面</td>
</tr>
<tr>
<td>toString()</td>
<td>返回<strong>Location</strong>所对应的URL值，相当于<code>window.location.href</code></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/javascript-window-location/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>正则表达式验证身份证</title>
		<link>http://julabs.me/blog/regular-id-card-number/</link>
		<comments>http://julabs.me/blog/regular-id-card-number/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 12:39:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[regular]]></category>
		<category><![CDATA[正则]]></category>
		<category><![CDATA[身份证]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=361</guid>
		<description><![CDATA[下面是一个简单的正则表达式验证身份证函数： function isIdCardNo(arg){ return /(^\d{15}$)&#124;(^\d{17}(?:\d&#124;x&#124;X)$)/.test(arg); } 当然这个函数非常简单，不过能用就可以了。]]></description>
			<content:encoded><![CDATA[<p>下面是一个简单的正则表达式验证身份证函数：</p>
<pre><code class="javascript">function isIdCardNo(arg){
	return /(^\d{15}$)|(^\d{17}(?:\d|x|X)$)/.test(arg);
}
</code></pre>
<p>当然这个函数非常简单，不过能用就可以了。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/regular-id-card-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用CSS3实现惊艳的图片过渡效果</title>
		<link>http://julabs.me/blog/image-effects-webkit-css3/</link>
		<comments>http://julabs.me/blog/image-effects-webkit-css3/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 14:51:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=343</guid>
		<description><![CDATA[《Amazing Image Hover Effects with Webkit and CSS 3》这篇教程所展示的惊艳效果完全由CSS 3实现的，当然一定要是在基于以Webkit为核心的浏览器里，演示请看这里：查看演示。 演示里面展示了滑动、缩放、改变透明度共6种效果，以前这些效果必须是由JavaScript或者Flash来实现，现在完全用CSS 3和Webkit就可以轻松实现了。相信通过查看这些演示，能够让人认识和体会到CSS 3的强大。]]></description>
			<content:encoded><![CDATA[<p><a href="http://dinolatoga.com/2009/09/18/amazing-imag-hover-effects-with-webkit-and-css/" target="_blank">《Amazing Image Hover Effects with Webkit and CSS 3》</a>这篇教程所展示的惊艳效果完全由<abbr title="Cascading Style Sheets 3">CSS 3</abbr>实现的，当然一定要是在基于以<a href="http://webkit.org/" target="_blank">Webkit</a>为核心的浏览器里，演示请看这里：<a href="http://dinolatoga.com/demo/webkit-image-hover-effects/" target="_blank">查看演示</a>。</p>
<p><a href="http://dinolatoga.com/demo/webkit-image-hover-effects/" target="_blank">演示</a>里面展示了滑动、缩放、改变透明度共6种效果，以前这些效果必须是由<strong>JavaScript</strong>或者<strong>Flash</strong>来实现，现在完全用<abbr title="Cascading Style Sheets 3">CSS 3</abbr>和<a href="http://webkit.org/" target="_blank">Webkit</a>就可以轻松实现了。相信通过查看这些演示，能够让人认识和体会到<abbr title="Cascading Style Sheets 3">CSS 3</abbr>的强大。</p>
<p class="img"><a href="http://dinolatoga.com/demo/webkit-image-hover-effects/" target="_blank"><img src="/blog/img/10/image-hover-webkit-css3.jpg" alt="Amazing Image Hover Effects using Webkit and CSS" width="450" height="644" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/image-effects-webkit-css3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>网站favicon.ico显示不了的原因</title>
		<link>http://julabs.me/blog/favicon-ico-disappear/</link>
		<comments>http://julabs.me/blog/favicon-ico-disappear/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 13:18:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[图标]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=325</guid>
		<description><![CDATA[现在人们都喜欢在自己的网站上放上自己的favicon.ico，不仅可以标识网站的身份，自己看着也赏心悦目。但有很多原因会导致favicon.ico显示不出来，我总结了下，有以下几个原因： 图标的链接地址或者HTML代码出错了 这是个低级错误，但也不是不可能发生的，首先要看看图标的链接地址和HTML代码对不对。一般如果直接把favicon.ico图标放在网站的根目录下，页面是可以自动寻址到这个图标文件的。正确的代码如下： &#60;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&#62; 火狐还支持GIF动画格式的图标，代码如下： &#60;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&#62; &#60;link rel="shortcut icon" href="favicon.gif" type="image/gif" /&#62; 没有清空缓存 要清空浏览器的缓存，在IE中不仅要清空Internet临时文件，也要把历史记录清空。对于360、搜狗、傲游这些浏览器清空缓存会稍微麻烦点，它们会将favicon.ico存储在自己特定的文件夹里，以加快页面的访问速度。 360浏览器 要进入自己的Application Data中寻找360浏览器的数据，比如我的用户名为Jon。如果用的是XP，那么就找到C:\Documents and Settings\Jon\Application Data\360se\data\ico文件夹；如果是Win7，那么就找到C:\Users\Jon\AppData\Roaming\360se\data\ico文件夹。这里是360浏览器缓存网站favicon.ico的地方，把ico文件夹清空。 搜狗浏览器 同样也要找Application Data，比如我的用户名为Jon。如果用的是XP，那么就找到C:\Documents and Settings\Jon\Application Data\SogouExplorer\FavIcon文件夹；如果是Win7，那么就找到C:\Users\Jon\AppData\Roaming\SogouExplorer\FavIcon文件夹。这里是搜狗浏览器缓存网站favicon.ico的地方，把FavIcon文件夹清空。 傲游浏览器 我使用的是傲游浏览器2，把它安装到了D:\Maxthon2目录下，那么在这个目录下找到名为Favicons的文件夹，这里是傲游浏览器缓存网站favicon.ico的地方，把Favicons文件夹清空。 favicon.ico格式不对 最好使用专业的Icon制作软件，可以在《免费的图标制作工具》一文中找一些使用。要想知道自己的图标文件格式是否正确，可以先下载其它网站的Icon来对比下。比如可以下载Google的favicon.ico文件，地址为：http://www.google.com/favicon.ico。把自己的favicon.ico和Google的favicon.ico放在一起，开启文件浏览的缩略图模式。看下面的图片，可以正确显示的就是正确格式，不能显示的就是错误格式。在下图中favicon-1.ico、favicon-2.ico都能正确显示，是正确的格式，而favicon-3.ico的格式错误，显示不正确。 &#8230; <a href="http://julabs.me/blog/favicon-ico-disappear/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>现在人们都喜欢在自己的网站上放上自己的<strong>favicon.ico</strong>，不仅可以标识网站的身份，自己看着也赏心悦目。但有很多原因会导致<strong>favicon.ico</strong>显示不出来，我总结了下，有以下几个原因：</p>
<h4>图标的链接地址或者HTML代码出错了</h4>
<p>这是个低级错误，但也不是不可能发生的，首先要看看图标的链接地址和<abbr title="HyperText Markup Language">HTML</abbr>代码对不对。一般如果直接把<strong>favicon.ico</strong>图标放在网站的根目录下，页面是可以自动寻址到这个图标文件的。正确的代码如下：</p>
<pre><code class="html">&lt;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&gt;
</code></pre>
<p><a target="_blank" href="http://www.mozillaonline.com/">火狐</a>还支持<abbr title="Graphics Interchange Format">GIF</abbr>动画格式的图标，代码如下：</p>
<pre><code class="html">&lt;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&gt;
&lt;link rel="shortcut icon" href="favicon.gif" type="image/gif" /&gt;
</code></pre>
<h4>没有清空缓存</h4>
<p>要清空浏览器的缓存，在<abbr title="Internet Explorer">IE</abbr>中不仅要清空<strong>Internet临时文件</strong>，也要把<strong>历史记录</strong>清空。对于<a href="http://se.360.cn/" target="_blank">360</a>、<a href="http://ie.sogou.com/" target="_blank">搜狗</a>、<a href="http://www.maxthon.cn/" target="_blank">傲游</a>这些浏览器清空缓存会稍微麻烦点，它们会将<strong>favicon.ico</strong>存储在自己特定的文件夹里，以加快页面的访问速度。</p>
<h5><a href="http://se.360.cn/" target="_blank">360浏览器</a></h5>
<p>要进入自己的<strong>Application Data</strong>中寻找<a href="http://se.360.cn/" target="_blank">360浏览器</a>的数据，比如我的用户名为<strong>Jon</strong>。如果用的是<strong>XP</strong>，那么就找到<strong>C:\Documents and Settings\Jon\Application Data\360se\data\ico</strong>文件夹；如果是<strong>Win7</strong>，那么就找到<strong>C:\Users\Jon\AppData\Roaming\360se\data\ico</strong>文件夹。这里是<a href="http://se.360.cn/" target="_blank">360浏览器</a>缓存网站<strong>favicon.ico</strong>的地方，把<strong>ico</strong>文件夹清空。</p>
<h5><a href="http://ie.sogou.com/" target="_blank">搜狗浏览器</a></h5>
<p>同样也要找<strong>Application Data</strong>，比如我的用户名为<strong>Jon</strong>。如果用的是<strong>XP</strong>，那么就找到<strong>C:\Documents and Settings\Jon\Application Data\SogouExplorer\FavIcon</strong>文件夹；如果是<strong>Win7</strong>，那么就找到<strong>C:\Users\Jon\AppData\Roaming\SogouExplorer\FavIcon</strong>文件夹。这里是<a href="http://ie.sogou.com/" target="_blank">搜狗浏览器</a>缓存网站<strong>favicon.ico</strong>的地方，把<strong>FavIcon</strong>文件夹清空。</p>
<h5><a href="http://www.maxthon.cn/" target="_blank">傲游浏览器</a></h5>
<p>我使用的是<strong>傲游浏览器2</strong>，把它安装到了<strong>D:\Maxthon2</strong>目录下，那么在这个目录下找到名为<strong>Favicons</strong>的文件夹，这里是<a href="http://www.maxthon.cn/" target="_blank">傲游浏览器</a>缓存网站<strong>favicon.ico</strong>的地方，把<strong>Favicons</strong>文件夹清空。</p>
<h4>favicon.ico格式不对</h4>
<p>最好使用专业的Icon制作软件，可以在<a href="/blog/soft/free-icon-tools/" target="_blank">《免费的图标制作工具》</a>一文中找一些使用。要想知道自己的图标文件格式是否正确，可以先下载其它网站的Icon来对比下。比如可以下载<a href="http://www.google.com/" target="_blank">Google</a>的<strong>favicon.ico</strong>文件，地址为：<a href="http://www.google.com/favicon.ico" target="_blank">http://www.google.com/favicon.ico</a>。把自己的<strong>favicon.ico</strong>和<a href="http://www.google.com/" target="_blank">Google</a>的<strong>favicon.ico</strong>放在一起，开启文件浏览的缩略图模式。看下面的图片，可以正确显示的就是正确格式，不能显示的就是错误格式。在下图中<strong>favicon-1.ico</strong>、<strong>favicon-2.ico</strong>都能正确显示，是正确的格式，而<strong>favicon-3.ico</strong>的格式错误，显示不正确。</p>
<p class="img"><img src="/blog/img/10/favicon-disappear.png" alt="favicon.ico" width="355" height="124" /></p>
<p>一般网站用的<strong>favicon.ico</strong>的尺寸为<strong>16×16</strong>就可以了，</p>
<p>如果通过以上的方法<strong>favicon.ico</strong>仍然显示不了，那、那、那，那我也就没有办法了。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/favicon-ico-disappear/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>用document.referrer找到当前流量的来源页面</title>
		<link>http://julabs.me/blog/document-referrer/</link>
		<comments>http://julabs.me/blog/document-referrer/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 04:02:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[referrer]]></category>
		<category><![CDATA[来源]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=315</guid>
		<description><![CDATA[在前端开发中可以使用document.referrer来获得前流量的来源参考页，也就是说可以用这个来获得是从哪个页面跳到本页面的。另外如果是在同一个域名下也可以使用windoww.opener对象去获取源页面的地址，如下面代码： var referrer = window.opener.location.href; Document.Referrer由于各种原因可能会丢失，相关的原因和解决办法可以参考《Document.Referrer丢失的几个原因》一文。]]></description>
			<content:encoded><![CDATA[<p>在前端开发中可以使用<strong>document.referrer</strong>来获得前流量的来源参考页，也就是说可以用这个来获得是从哪个页面跳到本页面的。另外如果是在同一个域名下也可以使用<strong>windoww.opener</strong>对象去获取源页面的地址，如下面代码：</p>
<pre><code class="javascript">var referrer = window.opener.location.href;
</code></pre>
<p><strong>Document.Referrer</strong>由于各种原因可能会丢失，相关的原因和解决办法可以参考<a href="http://www.imkevinyang.com/2010/01/document-referrer%E4%B8%A2%E5%A4%B1%E7%9A%84%E5%87%A0%E4%B8%AA%E5%8E%9F%E5%9B%A0.html" target="_blank">《Document.Referrer丢失的几个原因》</a>一文。</p>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/document-referrer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>表格排序代码</title>
		<link>http://julabs.me/blog/table-sort/</link>
		<comments>http://julabs.me/blog/table-sort/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 14:34:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[排序]]></category>
		<category><![CDATA[表格]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=290</guid>
		<description><![CDATA[这里的代码是根据《JavaScript高级程序设计》第12章里面的示例重新整合的，关于Array的sort的用法可以看下《JavaScript高级程序设计》第12章，也可以看下《JavaScript sort()方法》。 下面是详细代码和注释： /** * 表格排序 */ var sortTable = { /** * 转换函数 * 可以将 String 类型的变量转成 Int,Float,Date 的格式 * @param {String} v 原来的值 * @param {String} tp 值类型 int,float,date,默认为 string */ convert:function(v,tp){ switch(tp){ case 'int': return parseInt(v); case &#8230; <a href="http://julabs.me/blog/table-sort/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这里的代码是根据<a href="http://book.douban.com/subject/1869705/" target="_blank">《JavaScript高级程序设计》</a>第12章里面的示例重新整合的，关于<code>Array</code>的<strong>sort</strong>的用法可以看下<a href="http://book.douban.com/subject/1869705/" target="_blank">《JavaScript高级程序设计》</a>第12章，也可以看下<a href="http://www.w3school.com.cn/js/jsref_sort.asp" target="_blank">《JavaScript sort()方法》</a>。</p>
<p>下面是详细代码和注释：</p>
<pre><code class="javascript">/**
 * 表格排序
 */
var sortTable = {
	/**
	 * 转换函数
	 * 可以将 String 类型的变量转成 Int,Float,Date 的格式
	 * @param {String} v 原来的值
	 * @param {String} tp 值类型 int,float,date,默认为 string
	 */
	convert:function(v,tp){

		switch(tp){
			case 'int':
				return parseInt(v);
			case 'float':
				return parseFloat(v);
			case "date":
				// IE6 只认 yyyy/mm/dd hh:mm:ss的格式
				return new Date(Date.parse(v.replace(/\-/g,'/')));
			default:
				return v.toString().toLowerCase();
		}
	},

	/**
	 * 对比两个行
	 * @requires sortTable.convert
	 * @param {Int} ic 排序要参照的表格序号
	 * @param {String} dt 值类型 int,float,date,默认为 string
	 */
	compareTrs:function(ic,dt){

		/**
		 * 返回一个新的对比函数
		 * @requires sortTable.convert
		 * @param {Object} r1 第一行
		 * @param {Object} r2 第二行
		 */
		return function(r1,r2){
			var v1 , v2;
			// 如果节点拥有 data-sort 属性
			// 则根据 data-sort 属性进行排序
			if(r1.cells[ic].getAttribute('data-sort')){
				v1 = sortTable.convert(r1.cells[ic].getAttribute('data-sort'),dt);
				v2 = sortTable.convert(r2.cells[ic].getAttribute('data-sort'),dt);
			}else{
				// 如果节点没有 data-sort 属性
				// 则根据节点的 nodeValue 值进行排序
				v1 = sortTable.convert(r1.cells[ic].firstChild.nodeValue,dt);
				v2 = sortTable.convert(r2.cells[ic].firstChild.nodeValue,dt);
			}
			// 默认降序排列
			if(v1 &gt; v2){
				return -1;
			}else if(v1 &lt; v2){
				return 1;
			}else{
				return 0;
			}

		};
	},

	/**
	 * 表格排序函数
	 * 这个表格要有 thead 和 tbody
	 * @requires sortTable.compareTrs
	 * @param {String} tid 要排序的表格 ID
	 * @param {Int} ic 排序要参照的表格序号
	 * @param {String} tp 值类型 int,float,date,默认为 string
	 */
	sortTr:function(tid,ic,dt){
		var tb = document.getElementById(tid), // 获得表格 table
		bd = tb.tBodies[0], // 获得表格的tbody
		trs = bd.rows, // 获得表格 tbody 下的行集合
		arr = [], // 用于存储 tr 行集合的列表
		i=l=trs.length, // 获得 tr 行集合的个数
		fg = document.createDocumentFragment(), // 临时片断
		st=tb.getAttribute('data-sort');

		// 将 tr 行存储到 arr 中
		while(i--){
			arr[i] = trs[i];
		}
		// st 可能为 0 或者 NaN
		if(st!=null &amp;&amp; (parseInt(st)==ic)){
			// 如果表格当前的排序号和 ic 相等
			// 表明已经按照这个属性排序过了
			// 反排序就可以了
			arr.reverse();
		}else{
			arr.sort(sortTable.compareTrs(ic,dt));
			tb.setAttribute('data-sort',ic);
		}

		for(i=0;i&lt;l;i++){
			fg.appendChild(arr[i]);
		}

		bd.appendChild(fg);

		tb.setAttribute('data-sort',ic);

		tb = bd = trs = arr = i = l = fg = null;

	}
};</code></pre>
<p><span id="more-290"></span></p>
<p>下面是代码的使用示例，记住要排序的表格必需拥有<code>tbody</code>这个元素，当点击<code>thead</code>里面的<code>th</code>时，<code>tbody</code>中的行就根据相应的列进行排序。注意我把触发行为的代码放在表格<code>thead</code>中的<code>th</code>里了。</p>
<pre><code class="html">&lt;table id=&quot;oTable&quot;&gt;
	&lt;thead&gt;
		&lt;tr&gt;
			&lt;th onclick=&quot;sortTable.sortTr('oTable',0,'date')&quot;&gt;时间&lt;/th&gt;
			&lt;th onclick=&quot;sortTable.sortTr('oTable',1,'string')&quot;&gt;姓名&lt;/th&gt;
			&lt;th onclick=&quot;sortTable.sortTr('oTable',2,'int')&quot;&gt;年龄&lt;/th&gt;
		&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;!--td data-sort=&quot;March 12, 2001 19:25:03&quot;&gt;2001 03 12&lt;/td--&gt;
			&lt;td data-sort=&quot;2001-03-12&quot;&gt;2001 03 12&lt;/td&gt;
			&lt;td&gt;jon&lt;/td&gt;
			&lt;td&gt;54&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td data-sort=&quot;2001-11-12&quot;&gt;2001 11 12&lt;/td&gt;
			&lt;td&gt;amy&lt;/td&gt;
			&lt;td&gt;32&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td data-sort=&quot;1983-08-16&quot;&gt;1983 08 16&lt;/td&gt;
			&lt;td&gt;tom&lt;/td&gt;
			&lt;td&gt;56&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td data-sort=&quot;2007-06-14&quot;&gt;2007 06 14&lt;/td&gt;
			&lt;td&gt;jim&lt;/td&gt;
			&lt;td&gt;24&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td data-sort=&quot;1998-07-16&quot;&gt;1998 07 16&lt;/td&gt;
			&lt;td&gt;Lucy&lt;/td&gt;
			&lt;td&gt;18&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/table-sort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在非IE中实现mouseenter和mouseleave和的功能</title>
		<link>http://julabs.me/blog/not-ie-mouseenter-mouseleave/</link>
		<comments>http://julabs.me/blog/not-ie-mouseenter-mouseleave/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 08:10:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[mouse]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=284</guid>
		<description><![CDATA[IE下的mouseenter和mouseleave方法的好处我就不多说了，关于compareDocumentPosition方法的详细解释请参考《跨浏览器的 mouseenter mouseleave 以及 compareDocumentPosition》，在这里我只给出在非IE中实现这两种功能的简易方法。 下面是模拟IE下的mouseenter和mouseleave功能代码，里面也加上了详细的注释。 /** * 只在非IE中使用 * 模拟 IE 中 mouseenter 和 mouseleave 的效果 * @param {Event} e 发生的事件 * @param {Function} fun 触发的行为 */ var hover = function(e,fun){ /** * 因为这个函数只在非IE的浏览器中使用 * 所以可以使用 e.relatedTarget * 来获得与事件的目标节点相关的节点 &#8230; <a href="http://julabs.me/blog/not-ie-mouseenter-mouseleave/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><abbr title="Internet Explorer">IE</abbr>下的<code>mouseenter</code>和<code>mouseleave</code>方法的好处我就不多说了，关于<code>compareDocumentPosition</code>方法的详细解释请参考<a href="http://www.cnblogs.com/_franky/archive/2010/05/01/1725624.html" target="_blank">《跨浏览器的 mouseenter mouseleave 以及 compareDocumentPosition》</a>，在这里我只给出在非<abbr title="Internet Explorer">IE</abbr>中实现这两种功能的简易方法。</p>
<p>下面是模拟<abbr title="Internet Explorer">IE</abbr>下的<code>mouseenter</code>和<code>mouseleave</code>功能代码，里面也加上了详细的注释。</p>
<pre><code class="javascript">/**
 * 只在非IE中使用
 * 模拟 IE 中 mouseenter 和 mouseleave 的效果
 * @param {Event} e 发生的事件
 * @param {Function} fun 触发的行为
 */
var hover = function(e,fun){
	/**
	 * 因为这个函数只在非IE的浏览器中使用
	 * 所以可以使用 e.relatedTarget
	 * 来获得与事件的目标节点相关的节点
	 */
	var t = e.relatedTarget,

	// 获得触发此事件的节点
	t2 = e.target;

	/**
	 * 如果当前的节点与触发此事件的节点为同一节点
	 * 并且事件的目标节点不是当前节点的子节点
	 * 则触发行为
	 */
	if(this == t2 &amp;&amp; t &amp;&amp; !(this.compareDocumentPosition(t) == 20)){
		fun.call(this);
	}
	t = t2 = null;
}
</code></pre>
<p>上面的代码看似很多，但去除注释后代码就非常少了。继续说这个函数的用法，设有如下的<abbr title="Document Object Model">DOM</abbr>结构：</p>
<p><span id="more-284"></span></p>
<pre><code class="html">&lt;ul id=&quot;my_id&quot;&gt;
&lt;li&gt;1&lt;/li&gt;
&lt;li&gt;2&lt;/li&gt;
&lt;li&gt;3&lt;/li&gt;
&lt;/ul&gt;
</code></pre>
<p>样式<abbr title="Cascading Style Sheets">CSS</abbr>代码如下：</p>
<pre><code class="css">ul{
	width:200px;
	margin:0;
	padding:10px 0;
	background:#2883DE;
	list-style:none;
	line-height:30px;
	text-align:center;
	color:#FFF;
}
li{
	margin:10px;
	padding:0;
	background:#3728DE;
}
</code></pre>
<p>使用函数<code>hover</code>的<abbr title="JavaScript">JS</abbr>代码如下：</p>
<pre><code class="javascript">window.onload = function(){
	var my_id = document.getElementById('my_id');

	var ul_enter = function(){
		alert('鼠标进入UL');
	}

	var ul_leave = function(){
		alert('鼠标离开UL');
	}

	/**
	 * 用 my_id.onmouseenter!==undefined 来判断
	 * 浏览器支不支持 mouseenter 和 mouseleave 的方法
	 * 注意一定要用 “!==”来判断，而不能用“!=”
	 * 在非 IE 中，my_id.onmouseenter 为 undefined
	 * 在 IE 中，my_id.onmouseenter 为 null 或者为一个 function
	 * Opera 也支持 attachEvent 方法
	 * 但是 Opera 没有 mouseenter 和 mouseleave 的功能
	 */
	if(my_id.onmouseenter!==undefined){
		my_id.attachEvent('onmouseenter',ul_enter);

		my_id.attachEvent('onmouseleave',ul_leave);
	}else{
		my_id.addEventListener('mouseover',function(e){
			//ul_enter();
			hover.call(this,e,ul_enter);
		},false);

		my_id.addEventListener('mouseout',function(e){
			//ul_leave();
			hover.call(this,e,ul_leave);
		},false);
	}

};
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/not-ie-mouseenter-mouseleave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS渲染开销真地非常大</title>
		<link>http://julabs.me/blog/css-is-greatest-cost/</link>
		<comments>http://julabs.me/blog/css-is-greatest-cost/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 15:57:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[前端]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://julabs.me/blog/?p=269</guid>
		<description><![CDATA[《高性能网站建设进阶指南》中说处理CSS是最大的开销，我起先认为有点言过其实，最近才发现真是真理。 近期做的一个页面，要显示近200多行数据，每行数据里面有11个单元格，而每行的最后两个单元格中还嵌套有表格。这个页面突然最近两天变地非常慢，而且在IE6下尤为明显。刚开始以为是JavaScript的问题，就一直在这方面做优化。为了让页面看起来快点，我甚至用了分时分段创建DOM的做法，但情况仍然没有明显地好转。后来才发现其实创建DOM的过程是非常快的，而慢就慢在了渲染上面。我把CSS文件移除后页面变地非常快，最终在CSS文件中一句句地排查，终于找到了罪魁祸首：背景图片（background-image）。 原来设计要为每个单元格增加一个1像素的边框，并且每个单元格有固定的宽度，而加了一个边框的单元格在不同的浏览器下面它们最终的宽度就不一样。为了兼容我去掉了边框，改用了设置一像素平铺背景来模拟边框。表格有200多行，每行连子表格共有17个单元格，合在一起有3,4000个单元格，每个单元格都有平铺的小背景，不慢才怪！ 这件事给我的教训很大，以前对CSS的认识不足，只关注JavaScript，现在要重新认识CSS了。 《高性能网站建设进阶指南》中给出了几条编写高效CSS选择符的要点： 避免使用通配符：除了传统意义上的通配选择符外，Hyatt把相邻兄弟选择符、子选择符、后代选择符和属性选择符都归纳到了“通配符”分类下，他仅推荐使用ID、类、和标签选择符。 不要限定ID选择符；对于div#idsel这样的选择符，应该改成#idsel，因为在页面里一个指定的ID只能对应一个元素，没有必要再添加其它限定符。 不要限定类选择符：不要用具体的限定类选择符，如li.mystyle，改成.list-mystyle会更好些 让规则越具体越好：如ul li a这样的，最好是创建一个像.list-link这样的类。 避免使用后代选择符：通常使用后代选择符的开销是最高的，在有条件的情况下可以用子选择符代替。这一条对IE6无用，IE6不支持子选择符。 避免使用标签和子选择符：如果有像#myid > li > a这样的选择符，可以改成一个类，如.myid-link。 质疑子选择符的所有用途：再次提醒检查所有使用子选择符的地方，然后尽可能用具体的类取代它。 依靠继承：了解哪些属性可能通过继承来获取，避免对这些属性重复指定规则，可以参考《Full property table》。 这些要点有很多不现实的地方，因为子选择符在实际操作中是必须要用到的，但是我们可以在达到效果的基础上利用这些要点来优化CSS代码。 这里有两篇Jon Sykes的文章，里面列出了不同规则对于渲染速度的影响，可以参考下： Testing CSS Performance Testing CSS Performance (pt 2) 此外，还在网上收集了一些CSS优化的规则，也列出来： 十六进制的颜色值对位数与大小写：建议用#FFFFFF，而不要用简写#fff，因为十六进制的颜色值默认标准是大写及6位数标注，在未知情况下不希望冒险而降低了渲染的效率。 用display与visibility隐藏的差异：建议用display:none来隐藏元素，display隐藏对象不保留物理空间，visibility为隐藏对象保留占据的物理空间。当浏览器渲染被占据的物理空间时，会有所消耗资源。 border:none;与border:0;的区别：建议用border:none;，和display与visibility的关系类似，分别不保留与保留空间。更多的是border:0;尽管可以隐藏掉边框，但它会为你保留border-color/border-style的使用权。 不宜过小的背景图片平铺：不赞成宽高8px以下的平铺背景图片。 IE的滤镜：不建议使用IE的滤镜，不仅消耗资源，也有兼容问题。]]></description>
			<content:encoded><![CDATA[<p><a href="http://book.douban.com/subject/4719162/" target="_blank">《高性能网站建设进阶指南》</a>中说<strong>处理CSS是最大的开销</strong>，我起先认为有点言过其实，最近才发现真是真理。</p>
<p>近期做的一个页面，要显示近200多行数据，每行数据里面有11个单元格，而每行的最后两个单元格中还嵌套有表格。这个页面突然最近两天变地非常慢，而且在<abbr title="Internet Explorer 6">IE6</abbr>下尤为明显。刚开始以为是<strong>JavaScript</strong>的问题，就一直在这方面做优化。为了让页面看起来快点，我甚至用了分时分段创建<abbr title="Document Object Model">DOM</abbr>的做法，但情况仍然没有明显地好转。后来才发现其实创建<abbr title="Document Object Model">DOM</abbr>的过程是非常快的，而慢就慢在了渲染上面。我把<abbr title="Cascading Style Sheets">CSS</abbr>文件移除后页面变地非常快，最终在<abbr title="Cascading Style Sheets">CSS</abbr>文件中一句句地排查，终于找到了罪魁祸首：<strong>背景图片（background-image）</strong>。</p>
<p>原来设计要为每个单元格增加一个1像素的边框，并且每个单元格有固定的宽度，而加了一个边框的单元格在不同的浏览器下面它们最终的宽度就不一样。为了兼容我去掉了边框，改用了设置一像素平铺背景来模拟边框。表格有200多行，每行连子表格共有17个单元格，合在一起有3,4000个单元格，每个单元格都有平铺的小背景，不慢才怪！</p>
<p>这件事给我的教训很大，以前对<abbr title="Cascading Style Sheets">CSS</abbr>的认识不足，只关注<strong>JavaScript</strong>，现在要重新认识<abbr title="Cascading Style Sheets">CSS</abbr>了。</p>
<p><a href="http://book.douban.com/subject/4719162/" target="_blank">《高性能网站建设进阶指南》</a>中给出了几条编写高效<abbr title="Cascading Style Sheets">CSS</abbr>选择符的要点：</p>
<ul>
<li><strong>避免使用通配符</strong>：除了传统意义上的通配选择符外，Hyatt把相邻兄弟选择符、子选择符、后代选择符和属性选择符都归纳到了“通配符”分类下，他仅推荐使用ID、类、和标签选择符。</li>
<li><strong>不要限定ID选择符</strong>；对于<code>div#idsel</code>这样的选择符，应该改成<code>#idsel</code>，因为在页面里一个指定的ID只能对应一个元素，没有必要再添加其它限定符。</li>
<li><strong>不要限定类选择符</strong>：不要用具体的限定类选择符，如<code>li.mystyle</code>，改成<code>.list-mystyle</code>会更好些</li>
<li><strong>让规则越具体越好</strong>：如<code>ul li a</code>这样的，最好是创建一个像<code>.list-link</code>这样的类。</li>
<li><strong>避免使用后代选择符</strong>：通常使用后代选择符的开销是最高的，在有条件的情况下可以用子选择符代替。这一条对<abbr title="Internet Explorer 6">IE6</abbr>无用，<abbr title="Internet Explorer 6">IE6</abbr>不支持子选择符。</li>
<li><strong>避免使用标签和子选择符</strong>：如果有像<code>#myid > li > a</code>这样的选择符，可以改成一个类，如<code>.myid-link</code>。</li>
<li><strong>质疑子选择符的所有用途</strong>：再次提醒检查所有使用子选择符的地方，然后尽可能用具体的类取代它。</li>
<li><strong>依靠继承</strong>：了解哪些属性可能通过继承来获取，避免对这些属性重复指定规则，可以参考<a href="http://www.w3.org/TR/CSS21/propidx.html" target="_blank">《Full property table》</a>。</li>
</ul>
<p>这些要点有很多不现实的地方，因为子选择符在实际操作中是必须要用到的，但是我们可以在达到效果的基础上利用这些要点来优化<abbr title="Cascading Style Sheets">CSS</abbr>代码。</p>
<p>这里有两篇<a href="http://blog.archive.jpsykes.com/index.html" target="_blank">Jon Sykes</a>的文章，里面列出了不同规则对于渲染速度的影响，可以参考下：</p>
<ul>
<li><a href="http://blog.archive.jpsykes.com/151/testing-css-performance/index.html" target="_blank">Testing CSS Performance</a></li>
<li><a href="http://blog.archive.jpsykes.com/152/testing-css-performance-pt-2/index.html" target="_blank">Testing CSS Performance (pt 2)</a></li>
</ul>
<p>此外，还在网上收集了一些<abbr title="Cascading Style Sheets">CSS</abbr>优化的规则，也列出来：</p>
<ul>
<li><strong>十六进制的颜色值对位数与大小写</strong>：建议用<code>#FFFFFF</code>，而不要用简写<code>#fff</code>，因为十六进制的颜色值默认标准是大写及6位数标注，在未知情况下不希望冒险而降低了渲染的效率。</li>
<li><strong>用display与visibility隐藏的差异</strong>：建议用<code>display:none</code>来隐藏元素，<code>display</code>隐藏对象不保留物理空间，<code>visibility</code>为隐藏对象保留占据的物理空间。当浏览器渲染被占据的物理空间时，会有所消耗资源。</li>
<li><strong>border:none;与border:0;的区别</strong>：建议用<code>border:none;</code>，和<code>display</code>与<code>visibility</code>的关系类似，分别不保留与保留空间。更多的是<code>border:0;</code>尽管可以隐藏掉边框，但它会为你保留<code>border-color/border-style</code>的使用权。</li>
<li><strong>不宜过小的背景图片平铺</strong>：不赞成宽高8px以下的平铺背景图片。</li>
<li><strong>IE的滤镜</strong>：不建议使用IE的滤镜，不仅消耗资源，也有兼容问题。</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://julabs.me/blog/css-is-greatest-cost/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

