<?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>FoxLing - 前端开发 &#187; FoxLing</title>
	<atom:link href="http://foxling.org/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://foxling.org</link>
	<description>不积跬步 无以至千里</description>
	<lastBuildDate>Mon, 05 Jul 2010 16:43:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>在Eclipse里使用ANT合并压缩JS&amp;CSS</title>
		<link>http://foxling.org/js-ajax-dom/in-eclipse-use-ant-concat-compress/</link>
		<comments>http://foxling.org/js-ajax-dom/in-eclipse-use-ant-concat-compress/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:38:08 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[Aptana]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=674</guid>
		<description><![CDATA[Aptana 是一款基于Eclipse的免费开源的软件，非常方便地编写 html, css, js, 有丰富完善的代码提示，包括大部分的 JS 框架的提示，比如 prototype/dojo/jquery/yui 等，相当方便。
由于工作开发环境是 JAVA，于是我用 Eclipse 安装了Aptana 的插件。
ANT，是 Apache 的一个开源项目，用于自动化调用程序完成项目的编译，打包，测试等。
Eclipse 内置了Ant，可以很方便地对JS, CSS进行压缩合并处理。
比如 js, css 文件都放在 web_assets 目录下，那么目录结构如下：

web_assets
    +-- ant-build  //存放ant build xml 配置文件
        +-- js.build.xml //处理 js 的配置文件
    +-- js  //最终的js文件
    [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aptana.org/">Aptana</a> 是一款基于Eclipse的免费开源的软件，非常方便地编写 html, css, js, 有丰富完善的代码提示，包括大部分的 JS 框架的提示，比如 prototype/dojo/jquery/yui 等，相当方便。<br />
由于工作开发环境是 JAVA，于是我用 <a href="http://eclipse.org/">Eclipse</a> 安装了Aptana 的插件。</p>
<p>ANT，是 Apache 的一个开源项目，用于自动化调用程序完成项目的编译，打包，测试等。<br />
Eclipse 内置了Ant，可以很方便地对JS, CSS进行压缩合并处理。</p>
<p>比如 js, css 文件都放在 web_assets 目录下，那么目录结构如下：</p>
<pre>
web_assets
    +-- ant-build  <span style="color:#999;">//存放ant build xml 配置文件</span>
        +-- js.build.xml <span style="color:#999;">//处理 js 的配置文件</span>
    +-- js  <span style="color:#999;">//最终的js文件</span>
    +-- lib  <span style="color:#999;">//其它依赖的程序</span>
    +-- src  <span style="color:#999;">//源文件</span>
</pre>
<p><span id="more-674"></span></p>
<p>lib目录下有yuicompressor.jar, 用 <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> 压缩 JavaScript 和 CSS</p>
<p>ant-bild/js.build.xml 文件内容如下：</p>
<pre>
&lt;project name="js.build" default="clean" basedir="../"&gt;
    &lt;description&gt;js.build for ANT&lt;/description&gt;
    &lt;property name="src" location="src" /&gt;
    &lt;property name="build" location="build" /&gt;
    &lt;property name="target" location="js" /&gt;
    &lt;property name="lib" location="lib"/&gt;
    &lt;property name="charset" value="utf-8"/&gt;

    &lt;target name="init"&gt;
        &lt;mkdir dir="${build}"/&gt;
    &lt;/target&gt;

    &lt;target name="concat" depends="init"&gt;
        &lt;concat destfile="${build}/core.js" encoding="${charset}" outputencoding="${charset}"&gt;
        	&lt;path path="${src}/core.js" /&gt;
		&lt;path path="${src}/dialog.js" /&gt;
        &lt;/concat&gt;
        &lt;replaceregexp match="@DEBUG@" replace="" flags="g" byline="true" file="${build}/core.js" encoding="${charset}" /&gt;
    &lt;/target&gt;

    &lt;target name="compress" depends="concat"&gt;
        &lt;java jar="${lib}/yuicompressor.jar" fork="true"&gt;
            &lt;arg line="--type js --charset utf-8 ${build}/core.js -o ${target}/core.js"/&gt;
        &lt;/java&gt;

    &lt;/target&gt;

    &lt;target name="clean" depends="compress"&gt;
        &lt;delete dir="${build}"/&gt;
    &lt;/target&gt;

&lt;/project&gt;
</pre>
<p>这个 ant 配置文件要经过4个流程：</p>
<ol>
<li>target init 进行初始化处理，创建一个目录build，用于暂存文件；</li>
<li>target concat 合并两个 js 文件，放到 build 目录下；</li>
<li>target compress 调用 Yui Compressor 对合并后的 js 进行压缩</li>
<li>target clean 进行清理动作，删除生成的 build 目录</li>
</ol>
<p>ANT标签和属性解释：</p>
<ul>
<li>project 的 default 对应某个 target 的 name 值，表示默认执行哪个步骤；</li>
<li>target 的 depends 对应其他某些 target 的 name 属性，表示依赖性；</li>
<li>${name} 可以引用 property 中定义的值。</li>
<li>mkdir 标签创建一个目录</li>
<li>replaceregexp, 正则表达式替换，将DEBUG标识替换为空，在正式环境不处理DEBUG信息</li>
<li>注意设置文件的 encoding 属性，否则可能有乱码情况</li>
</ul>
<p>关于ANT的详细文档，请看官方手册：<a href="http://ant.apache.org/manual/">http://ant.apache.org/manual/</a></p>
<p>在 Eclipse 里右击这个文件，选择 Run As -> ANT Build<br />
即可以控制台看到信息：</p>
<pre>
Buildfile: D:\eclipse\workspace\JS-Test\web_assets\ant-build\build.xml
init:
concat:
compress:
clean:
   [delete] Deleting directory D:\eclipse\workspace\JS-Test\web_assets\build
BUILD SUCCESSFUL
Total time: 875 milliseconds
</pre>
<p>这时候 js 目录就生成了合并压缩后的 core.js 文件，相当方便。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/in-eclipse-use-ant-concat-compress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>异步脚本加载 JS Loader</title>
		<link>http://foxling.org/js-ajax-dom/async-loading-js/</link>
		<comments>http://foxling.org/js-ajax-dom/async-loading-js/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 15:03:37 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=653</guid>
		<description><![CDATA[JS会阻塞其它页面资源的下载，通过对JS的异步加载可以解决这个问题，加快页面内容的呈现速度。获得更好的体验。
使用script标签加载
通过firebug查看各种资源加载状态，当test.js下载完毕后，图片才开始下载。

猛击测试页面block.html
使用JSLoader异步加载JS
当使用异步加载方式加载JS时，test.js与图片同时加载，加快了页面的呈现：

猛击测试页面js-loader
JSLoader
JSLoader.load(url, [fun1], [funN]);
参数：
url 要加载的JS的地址
fun 依赖该JS执行的函数
使用示例：

JSLoader.load('test.js', function(){
    document.getElementById('test').innerHTML = test;
});

猛击这里下载JSLoader.js

JSLoader源码：

var JSLoader = function(){

	var scripts = {};

	function getScript(url){
		var script = scripts[url];
		if (!script){
			script = {loaded:false, funs:[]};
			scripts[url] = script;
			add(script, url);
		}
		return script;
	}

	function run(script){
		var funs = script.funs,
			len = funs.length,
			i = 0;

		for (; i &#60; len; i++){
			var fun = funs.pop();
			fun();
		}
	}

	function add(script, url){
		var scriptdom = document.createElement('script');
		scriptdom.type = 'text/javascript';
		scriptdom.loaded = false;
		scriptdom.src [...]]]></description>
			<content:encoded><![CDATA[<p>JS会阻塞其它页面资源的下载，通过对JS的异步加载可以解决这个问题，加快页面内容的呈现速度。获得更好的体验。</p>
<h3>使用script标签加载</h3>
<p>通过firebug查看各种资源加载状态，当test.js下载完毕后，图片才开始下载。<br />
<img src="http://foxling.org/wp-content/uploads/2010/06/script-block.png" alt="" title="JS将阻塞其它资源下载" width="600" height="113" class="aligncenter size-full wp-image-654" /></p>
<p><a href="/examples/2010/06/js-loader/block.html">猛击测试页面block.html</a></p>
<h3>使用JSLoader异步加载JS</h3>
<p>当使用异步加载方式加载JS时，test.js与图片同时加载，加快了页面的呈现：<br />
<img src="http://foxling.org/wp-content/uploads/2010/06/sync-load.png" alt="" title="异步方式加载JS" width="600" height="130" class="aligncenter size-full wp-image-655" /></p>
<p><a href="/examples/2010/06/js-loader/">猛击测试页面js-loader</a></p>
<h3>JSLoader</h3>
<p>JSLoader.load(url, [fun1], [funN]);<br />
参数：<br />
url 要加载的JS的地址<br />
fun 依赖该JS执行的函数</p>
<p>使用示例：</p>
<pre>
JSLoader.load('test.js', function(){
    document.getElementById('test').innerHTML = test;
});
</pre>
<p><a href="/examples/2010/06/js-loader/jsloader.js">猛击这里下载JSLoader.js</a></p>
<p><span id="more-653"></span></p>
<p>JSLoader源码：</p>
<pre>
var JSLoader = function(){

	var scripts = {};

	function getScript(url){
		var script = scripts[url];
		if (!script){
			script = {loaded:false, funs:[]};
			scripts[url] = script;
			add(script, url);
		}
		return script;
	}

	function run(script){
		var funs = script.funs,
			len = funs.length,
			i = 0;

		for (; i &lt; len; i++){
			var fun = funs.pop();
			fun();
		}
	}

	function add(script, url){
		var scriptdom = document.createElement('script');
		scriptdom.type = 'text/javascript';
		scriptdom.loaded = false;
		scriptdom.src = url;

		scriptdom.onload = function(){
			scriptdom.loaded = true;
			run(script);
			scriptdom.onload = scriptdom.onreadystatechange = null;
		};

		//for ie
		scriptdom.onreadystatechange = function(){
			if ((scriptdom.readyState === 'loaded' ||
					scriptdom.readyState === 'complete') &#038;&#038; !scriptdom.loaded) {

				run(script);
				scriptdom.onload = scriptdom.onreadystatechange = null;
			}
		};

		document.getElementsByTagName('head')[0].appendChild(scriptdom);
	}

	return {
		load: function(url){
			var arg = arguments,
				len = arg.length,
				i = 1,
				script = getScript(url),
				loaded = script.loaded;

			for (; i &lt; len; i++){
				var fun = arg[i];
				if (typeof fun === 'function'){
					if (loaded) {
						fun();
					}else{
						script.funs.push(fun);
					}
				}
			}
		}
	};
}();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/async-loading-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>宇轩出浴照一枚</title>
		<link>http://foxling.org/life/my-son/</link>
		<comments>http://foxling.org/life/my-son/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:59:27 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[生活]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=642</guid>
		<description><![CDATA[
刚洗完澡的轩轩，最喜欢打电话和玩手机了，经常一个人跑到电话旁拿起听筒叽哩哇啦地说个不停。
]]></description>
			<content:encoded><![CDATA[<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0006-600x398.jpg" alt="" title="DSC_0006" width="600" height="398" class="aligncenter size-medium wp-image-643" /></p>
<p>刚洗完澡的轩轩，最喜欢打电话和玩手机了，经常一个人跑到电话旁拿起听筒叽哩哇啦地说个不停。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/life/my-son/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>贫民大光圈定焦镜头-AF 50mm 1.8D</title>
		<link>http://foxling.org/life/my-lens/</link>
		<comments>http://foxling.org/life/my-lens/#comments</comments>
		<pubDate>Mon, 03 May 2010 14:35:05 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[生活]]></category>
		<category><![CDATA[摄影]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=566</guid>
		<description><![CDATA[当初买了D5000又换成D90，就是因为D90能折腾更多的镜头；生命在于折腾~
定焦无弱旅，一直想买个定焦玩一下，看看成像的效果和大光圈，而 50mm 1.8D 应该是最便宜的定焦大光圈镜头了。
前天在论坛看到有网友要卖，了解了一下情况，赶紧拿下了，今天收到货一看，好东西，保养得太好了，跟新的一样。（他也说基本上没怎么用，在防潮箱里）
有了两个镜头，赶紧给它来了几张写真：
NIKKOR AF 50mm 1.8D




50mm 1.8D 试拍
试用了一下发现，景深的确很浅，适合拍糖水片，1.8的光圈下，会比较虚，所以还是缩两档较好。
定焦镜头，还需要多多使用，了解构图技巧。















下面是我的套机头 NIKKOR AF-S 18-105 VR





]]></description>
			<content:encoded><![CDATA[<p>当初买了D5000又换成D90，就是因为D90能折腾更多的镜头；生命在于折腾~<br />
定焦无弱旅，一直想买个定焦玩一下，看看成像的效果和大光圈，而 50mm 1.8D 应该是最便宜的定焦大光圈镜头了。<br />
前天在论坛看到有网友要卖，了解了一下情况，赶紧拿下了，今天收到货一看，好东西，保养得太好了，跟新的一样。（他也说基本上没怎么用，在防潮箱里）<br />
有了两个镜头，赶紧给它来了几张写真：</p>
<h3>NIKKOR AF 50mm 1.8D</h3>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0057-600x398.jpg" alt="" title="AF 50mm 1.8D" width="600" height="398" class="aligncenter size-medium wp-image-575" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0056-600x398.jpg" alt="" title="AF 50mm 1.8D" width="600" height="398" class="aligncenter size-medium wp-image-574" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0054-600x398.jpg" alt="" title="AF 50mm 1.8D" width="600" height="398" class="aligncenter size-medium wp-image-572" /></p>
<p><span id="more-566"></span></p>
<h3>50mm 1.8D 试拍</h3>
<p>试用了一下发现，景深的确很浅，适合拍糖水片，1.8的光圈下，会比较虚，所以还是缩两档较好。<br />
定焦镜头，还需要多多使用，了解构图技巧。</p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0002-21-600x398.jpg" alt="" title="DSC_0002-2" width="600" height="398" class="aligncenter size-medium wp-image-625" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00201-600x903.jpg" alt="" title="DSC_0020" width="600" height="903" class="aligncenter size-medium wp-image-635" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00181-600x903.jpg" alt="" title="DSC_0018" width="600" height="903" class="aligncenter size-medium wp-image-634" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00161-600x903.jpg" alt="" title="DSC_0016" width="600" height="903" class="aligncenter size-medium wp-image-633" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00131-600x398.jpg" alt="" title="DSC_0013" width="600" height="398" class="aligncenter size-medium wp-image-632" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00121-600x903.jpg" alt="" title="DSC_0012" width="600" height="903" class="aligncenter size-medium wp-image-631" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00111-600x903.jpg" alt="" title="DSC_0011" width="600" height="903" class="aligncenter size-medium wp-image-630" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00371-600x398.jpg" alt="" title="DSC_0037" width="600" height="398" class="aligncenter size-medium wp-image-637" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00291-600x762.jpg" alt="" title="DSC_0029" width="600" height="762" class="aligncenter size-medium wp-image-636" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0011-21-600x398.jpg" alt="" title="DSC_0011-2" width="600" height="398" class="aligncenter size-medium wp-image-629" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0010-21-600x398.jpg" alt="" title="DSC_0010-2" width="600" height="398" class="aligncenter size-medium wp-image-628" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0009-600x398.jpg" alt="" title="DSC_0009" width="600" height="398" class="aligncenter size-medium wp-image-627" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_00041-600x903.jpg" alt="" title="DSC_0004" width="600" height="903" class="aligncenter size-medium wp-image-626" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/CSC_00461-600x398.jpg" alt="" title="CSC_0046" width="600" height="398" class="aligncenter size-medium wp-image-624" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0023-600x395.jpg" alt="" title="DSC_0023" width="600" height="395" class="aligncenter size-medium wp-image-618" /></p>
<h3>下面是我的套机头 NIKKOR AF-S 18-105 VR</h3>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0053-600x398.jpg" alt="" title="AF-S 18-105 VR" width="600" height="398" class="aligncenter size-medium wp-image-571" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0052-600x398.jpg" alt="" title="AF-S 18-105 VR" width="600" height="398" class="aligncenter size-medium wp-image-570" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0051-600x398.jpg" alt="" title="AF-S 18-105 VR" width="600" height="398" class="aligncenter size-medium wp-image-569" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0050-600x398.jpg" alt="" title="AF-S 18-105 VR" width="600" height="398" class="aligncenter size-medium wp-image-568" /></p>
<p><img src="http://foxling.org/wp-content/uploads/2010/05/DSC_0049-600x398.jpg" alt="" title="AF-S 18-105 VR" width="600" height="398" class="aligncenter size-medium wp-image-567" /></p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/life/my-lens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>嘀咕怪兽宣传片</title>
		<link>http://foxling.org/favorite/digu-com/</link>
		<comments>http://foxling.org/favorite/digu-com/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 03:50:01 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[收藏夹]]></category>
		<category><![CDATA[嘀咕]]></category>
		<category><![CDATA[嘀咕网]]></category>
		<category><![CDATA[宣传片]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=559</guid>
		<description><![CDATA[
嘀咕宣传片，感觉节奏快了点，不过挺有创意。
我在嘀咕：@Foxling，欢迎跟随交流。
]]></description>
			<content:encoded><![CDATA[<p><object id="digu-monster" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="576" height="460" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://foxling.org/wp-content/uploads/2010/04/digu_monster.swf" /><param name="loop" value="false" /><embed id="digu-monster" type="application/x-shockwave-flash" width="576" height="460" loop="false" src="http://foxling.org/wp-content/uploads/2010/04/digu_monster.swf"></embed></object></p>
<p><a href="http://digu.com">嘀咕</a>宣传片，感觉节奏快了点，不过挺有创意。</p>
<p>我在嘀咕：<a href="http://digu.com/foxling">@Foxling</a>，欢迎跟随交流。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/favorite/digu-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>js在IE下获取background-position的问题</title>
		<link>http://foxling.org/js-ajax-dom/get-background-position-fix/</link>
		<comments>http://foxling.org/js-ajax-dom/get-background-position-fix/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 14:30:31 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>
		<category><![CDATA[backgroundPosition]]></category>
		<category><![CDATA[IE Bug]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=538</guid>
		<description><![CDATA[通过 jQuery 获取 background-position 的值时，在 IE 中返回 undefined
通过测试，发现无论是写在样式表中，还是写在元素style属性里，在 IE ( 6, 7, 8 ) 里获取background-position的值时，均返回undefined。
针对IE的这个bug，写了如下方法获取background-position的值：
请忽略getCSS方法，这是一个简易的获取css的方法，并不完善，了解不同浏览器获取CSS的方法

var getCSS = function(){
	var rdashAlpha = /-([a-z])/ig,
		fcamelCase = function( all, letter ) {
			return letter.toUpperCase();
		};
	return function(el, name){
		if (typeof el === 'string') el = document.getElementById(el);

		var cssValue,
			camelCase = name.replace(rdashAlpha, fcamelCase);

		if (el.currentStyle){
			cssValue = el.currentStyle[camelCase];
		}else if(window.getComputedStyle){
			cssValue = window.getComputedStyle(el,null)[camelCase];
		}
		return cssValue;
	};
}();

var getBackgroundPosition = function (){
	var s = getCSS(document.body, [...]]]></description>
			<content:encoded><![CDATA[<p>通过 jQuery 获取 background-position 的值时，在 IE 中返回 undefined<br />
通过测试，发现无论是写在样式表中，还是写在元素style属性里，在 IE ( 6, 7, 8 ) 里获取background-position的值时，均返回undefined。</p>
<p>针对IE的这个bug，写了如下方法获取background-position的值：<br />
请忽略getCSS方法，这是一个简易的获取css的方法，并不完善，<a href="http://foxling.org/js-ajax-dom/javascript-get-attribute-css/">了解不同浏览器获取CSS的方法</a></p>
<pre>
var getCSS = function(){
	var rdashAlpha = /-([a-z])/ig,
		fcamelCase = function( all, letter ) {
			return letter.toUpperCase();
		};
	return function(el, name){
		if (typeof el === 'string') el = document.getElementById(el);

		var cssValue,
			camelCase = name.replace(rdashAlpha, fcamelCase);

		if (el.currentStyle){
			cssValue = el.currentStyle[camelCase];
		}else if(window.getComputedStyle){
			cssValue = window.getComputedStyle(el,null)[camelCase];
		}
		return cssValue;
	};
}();

var getBackgroundPosition = function (){
	var s = getCSS(document.body, 'background-position') === undefined;
	return function(el){
		if (s){
			return getCSS(el, 'background-positionX') + ' ' + getCSS(el, 'background-positionY');
		}else{
			return getCSS(el, 'background-position');
		}
	};
}();
</pre>
<p><a href="/examples/2010/04/get-background-position/" class="view-example">猛击DEMO可以看到效果</a></p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/get-background-position-fix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Math.PI与++运算符</title>
		<link>http://foxling.org/js-ajax-dom/js-constant/</link>
		<comments>http://foxling.org/js-ajax-dom/js-constant/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 07:50:33 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>
		<category><![CDATA[Math.PI]]></category>
		<category><![CDATA[Readonly]]></category>
		<category><![CDATA[常量]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=528</guid>
		<description><![CDATA[遇到一道题目：

var a = Math.PI++, b = ++Math.PI;
alert(a);
alert(b);
alert(Math.PI);

不加思索的写下：
3.14
4.14
3.14
后来经常提醒才想到Math.PI是常量，修改一个常量的值，会抛出错误。
而上面的操作中，b = ++Math.PI 可以理解为将Math.PI递增加1，并且赋值给变量 b;
这时候开始迟疑了：
 在javascript中，给常量赋值是否会抛出错误呢？

复制代码执行一下，奇怪了，的确和我刚开始不加思索的结果那样，并没有抛出错误。
为什么在javascript中可以对常量进行这样的计算呢？
翻开ECMAScript规范：
This property has the attributes { DontEnum, DontDelete, ReadOnly }
继续找到 ReadOnly 定义：
The property is a read-only property. Attempts by ECMAScript code to write to the property will be ignored. (Note, however, that in some cases the value of a property with the ReadOnly attribute [...]]]></description>
			<content:encoded><![CDATA[<p>遇到一道题目：</p>
<pre>
var a = Math.PI++, b = ++Math.PI;
alert(a);
alert(b);
alert(Math.PI);
</pre>
<p>不加思索的写下：<br />
3.14<br />
4.14<br />
3.14</p>
<p>后来经常提醒才想到Math.PI是常量，修改一个常量的值，会抛出错误。<br />
而上面的操作中，<code>b = ++Math.PI</code> 可以理解为将Math.PI递增加1，并且赋值给变量 b;<br />
这时候开始迟疑了：<br />
 在javascript中，给常量赋值是否会抛出错误呢？<br />
<span id="more-528"></span></p>
<p><a href="/examples/2010/04/readonly.html" class="view-example">复制代码执行一下</a>，奇怪了，的确和我刚开始不加思索的结果那样，并没有抛出错误。<br />
为什么在javascript中可以对常量进行这样的计算呢？</p>
<p><a href="http://bclary.com/2004/11/07/#a-15.8.1.6">翻开ECMAScript规范</a>：</p>
<blockquote><p>This property has the attributes { DontEnum, DontDelete, ReadOnly }</p></blockquote>
<p>继续找到 <a href="http://bclary.com/2004/11/07/#a-8.6.1">ReadOnly</a> 定义：</p>
<blockquote><p>The property is a read-only property. Attempts by ECMAScript code to write to the property will be ignored. (Note, however, that in some cases the value of a property with the ReadOnly attribute may change over time because of actions taken by the host environment; therefore &#8220;ReadOnly&#8221; does not mean &#8220;constant and unchanging&#8221;!)</p></blockquote>
<p>对该属性的写入将被忽略。<br />
既然写入被忽略了，那 <code>b = ++Math.PI</code> 为什么是4.14而不是3.14呢。</p>
<p><a href="http://bclary.com/2004/11/07/#a-11.4.4">继续翻看++运算符</a></p>
<blockquote><p>
The production UnaryExpression : ++ UnaryExpression is evaluated as follows:<br />
1. Evaluate UnaryExpression.<br />
2. Call GetValue(Result(1)).<br />
3. Call ToNumber(Result(2)).<br />
4. Add the value 1 to Result(3), using the same rules as for the + operator (see 11.6.3).<br />
5. Call PutValue(Result(1), Result(4)).<br />
6. Return Result(4).
</p></blockquote>
<p>看来并不是给 Math.PI 加上 1 再赋值给 b<br />
而是在Result(3)上加上1，在第5步时，赋值给Math.PI(被忽略)<br />
第6步，返回第4步的值。而不是返回Math.PI</p>
<p>现在，对于开头出现的结果不再感到迷惑了。<br />
遇到问题，不仅仅是需要了解他的正确结果，最好是能了解正确结果是如何得来的。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/js-constant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>浏览器本地存储(1)</title>
		<link>http://foxling.org/js-ajax-dom/broswer-local-storage/</link>
		<comments>http://foxling.org/js-ajax-dom/broswer-local-storage/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:23:34 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>
		<category><![CDATA[globalStorage]]></category>
		<category><![CDATA[localStorage]]></category>
		<category><![CDATA[sessionStorage]]></category>
		<category><![CDATA[WebStorage]]></category>
		<category><![CDATA[本地存储]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=519</guid>
		<description><![CDATA[浏览器存储方式主要下面几种：

Cookie4096字节；缺点：存储量小，请求头附带cookie带来性能问题。
Flash Share Object默认支持100k，跨浏览器存储最好的方式，毕竟现在没有安装flash插件的用户是很少的；缺点：需要加载一个swf文件，个别用户不支持flash。有一个基于jQuery的插件叫 jStore ，就是通过Flash Share Object实现的。
IE的 UserData最少也能支持640k，IE8后已经支持DOM Storage；缺点：IE only。
DOM Storage默认支持5M存储量；缺点：IE7，IE6不支持。
Google Gears功能最强；缺点：但需要安装软件，而且，安装的用户是较少的。

这里主要学习 IE 的 UserData 和 DOM Storage

DOM Storage
支持：Firefox, Chrome, Opera, Safari, IE8+
关于Web Storage的w3c文档，请移步 http://dev.w3.org/html5/webstorage/
DOM Storage 分为两种， sessionStorage 和 localStorage，顾名思义，sessionStorage是指在当前窗口会话中持续保存的数据，哪怕你在不同的网站中跳转也不会清除，但关闭窗口后就没了；localStorage是在本地永久存储的。
方法：

key(index) 根据索引获取值
getItem(key) 获取 key 的值
setItem(key, data) 设置 key 的值
removeItem(key) 删除 key
clear() 清除所有的key

属性：

length 当前存储的个数

IE UserData
支持：IE5+
关于UserData更详细的文档，请看http://msdn.microsoft.com/en-us/library/ms531424.aspx
通过给 xml 或者 html 标签添加 behavior 来支持 userData
例如：
&#60;input style="behavior:url('#default#userData')" id="userData"&#62;
或者，通过脚本来设置：
object.style.behavior = "url('#default#userData')"
object.addBehavior ("#default#userData")
方法：

getAttribute() [...]]]></description>
			<content:encoded><![CDATA[<h3>浏览器存储方式主要下面几种：</h3>
<ul>
<li>Cookie<br />4096字节；缺点：存储量小，请求头附带cookie带来性能问题。</li>
<li>Flash Share Object<br />默认支持100k，跨浏览器存储最好的方式，毕竟现在没有安装flash插件的用户是很少的；缺点：需要加载一个swf文件，个别用户不支持flash。<br />有一个基于jQuery的插件叫 <a href="http://eric.garside.name/docs.html?p=jstore">jStore</a> ，就是通过Flash Share Object实现的。</li>
<li>IE的 UserData<br />最少也能支持640k，IE8后已经支持DOM Storage；缺点：IE only。</li>
<li>DOM Storage<br />默认支持5M存储量；缺点：IE7，IE6不支持。</li>
<li>Google Gears<br />功能最强；缺点：但需要安装软件，而且，安装的用户是较少的。</li>
</ul>
<p>这里主要学习 IE 的 UserData 和 DOM Storage<br />
<span id="more-519"></span></p>
<h3>DOM Storage</h3>
<p>支持：Firefox, Chrome, Opera, Safari, IE8+<br />
关于Web Storage的w3c文档，请移步 <a href="http://dev.w3.org/html5/webstorage/">http://dev.w3.org/html5/webstorage/</a><br />
DOM Storage 分为两种， sessionStorage 和 localStorage，顾名思义，sessionStorage是指在当前窗口会话中持续保存的数据，哪怕你在不同的网站中跳转也不会清除，但关闭窗口后就没了；localStorage是在本地永久存储的。</p>
<p>方法：</p>
<ul>
<li>key(index) 根据索引获取值</li>
<li>getItem(key) 获取 key 的值</li>
<li>setItem(key, data) 设置 key 的值</li>
<li>removeItem(key) 删除 key</li>
<li>clear() 清除所有的key</li>
</ul>
<p>属性：</p>
<ul>
<li>length 当前存储的个数</li>
</ul>
<h3>IE UserData</h3>
<p>支持：IE5+<br />
关于UserData更详细的文档，请看<a href="http://msdn.microsoft.com/en-us/library/ms531424.aspx">http://msdn.microsoft.com/en-us/library/ms531424.aspx</a><br />
通过给 xml 或者 html 标签添加 behavior 来支持 userData<br />
例如：<br />
<code>&lt;input style="behavior:url('#default#userData')" id="userData"&gt;</code><br />
或者，通过脚本来设置：<br />
<code>object.style.behavior = "url('#default#userData')"</code><br />
<code>object.addBehavior ("#default#userData")</code></p>
<p>方法：</p>
<ul>
<li>getAttribute()  获取指定的属性值。</li>
<li>load(object)  从 userData 存储区载入存储的对象数据。</li>
<li>removeAttribute()  移除对象的指定属性。</li>
<li>save(object)  将对象数据存储到一个 userData 存储区。</li>
<li>setAttribute()  设置指定的属性值。</li>
</ul>
<p>属性：</p>
<ul>
<li>expires  设置或者获取 userData behavior 保存数据的失效日期，不设置则为永久。</li>
<li>XMLDocument 获取 XML 的引用。</li>
</ul>
<h3>兼容的解决方法</h3>
<p>这是我写的一个通用的本地存储的插件，缺点：数据不能跨浏览器，比如在IE里保存的，只能在IE里读取：<br />
测试通过的浏览器：IE6, IE7, IE8, Firefox, Chrome, Safari, Opera</p>
<p>支持的方法：</p>
<ul>
<li>get(key) 读取key的值</li>
<li>set(key, value) 设置key的值</li>
<li>del(key) 删除key</li>
<li>support 检测是否支持本地存储</li>
</ul>
<p>使用示例：<br />
<code>if ( Storage.support() ) Storage.set('username', 'foxling');</code></p>
<p><a href="/examples/2010/04/localStorage/index.html" class="view-example">Demo猛击这里</a></p>
<pre>
var Storage = function(win, doc){
		var hasSupport = true,
			store = win.localStorage,
			STORE_NAME = 'localstorage',
			obj,
			support = function (){ return hasSupport },
			error = function(){ throw new Error("don't support localStorage") };

		if (store &#038;&#038; store.getItem){
			obj = {
				set : function(key, value){
					return store.setItem(key, value);
				},
				get : function(key){
					return store.getItem(key);
				},
				del : function(key){
					return store.removeItem(key);
				}
			};
		}else{
			store = doc.documentElement;
			try{
				store.addBehavior('#default#userdata');
				store.save(STORE_NAME);
			}catch(e){
				hasSupport = false;
			}
			if (hasSupport){
				obj = {
					set : function(key, value){
						store.setAttribute(key, value);
						store.save(STORE_NAME);
					},
					get : function(key){
						store.load(STORE_NAME);
						return store.getAttribute(key);
					},
					del : function(key){
						store.removeAttribute(key);
						store.save(STORE_NAME);
					}
				};

			}
		}
		if (!obj){
			obj = {
				set:error,
				get:error,
				del:error
			};
		}
		obj.support = support;
		return obj;
	}(window, document);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/broswer-local-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Array 性能测试</title>
		<link>http://foxling.org/js-ajax-dom/javascript-array-performance/</link>
		<comments>http://foxling.org/js-ajax-dom/javascript-array-performance/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 14:00:57 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[JS/AJAX/DOM]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://foxling.eblhost.com/?p=500</guid>
		<description><![CDATA[array.push优化

原生的方法arr.push()
通过arr[arr.length]直接赋值
把方法二写成一个函数方便调用

测试结果请猛击这里：
/examples/2010/03/array-performance/push.html
测试结果：

给arr[arr.length]直接赋值比push方法快
函数调用增加了开销，特别是在IE6和opera下表现明显
Chrome应该是做了优化，相差不大

待续(也许) =，=&#8230;&#8230;.
]]></description>
			<content:encoded><![CDATA[<h3>array.push优化</h3>
<ul>
<li>原生的方法arr.push()</li>
<li>通过arr[arr.length]直接赋值</li>
<li>把方法二写成一个函数方便调用</li>
</ul>
<p>测试结果请猛击这里：<br />
<a href="/examples/2010/03/array-performance/push.html">/examples/2010/03/array-performance/push.html</a></p>
<p>测试结果：</p>
<ul>
<li>给arr[arr.length]直接赋值比push方法快</li>
<li>函数调用增加了开销，特别是在IE6和opera下表现明显</li>
<li>Chrome应该是做了优化，相差不大</li>
</ul>
<p>待续(也许) =，=&#8230;&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/js-ajax-dom/javascript-array-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>京东商城的快递状态查询服务有待完善</title>
		<link>http://foxling.org/ued/360buy-express/</link>
		<comments>http://foxling.org/ued/360buy-express/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 15:36:44 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[杂七杂八]]></category>
		<category><![CDATA[用户体验]]></category>

		<guid isPermaLink="false">http://foxling.org/?p=507</guid>
		<description><![CDATA[在京东给老爸买了一套罗技的键鼠套装。
第二天登录网站查询看到的货运状态是：
送货方式：EMS
承 运 人：京东
货运单号：2249457148 点击查询
承运人电话：020-28809135
“点击查询”的链接是http://www.ems.com.cn/
事实上，这个单号在ems网站是查询不了的，ems页面提示，单号是13位。
于是想到，京东应该是有很多家快递商合作的，但这里的状态显示却相当地不人性化。
应该针对不同的单号，显示各家快递的网站以及查询网址的链接，如果可以的话，直接从对方网站读取状态信息。（淘宝就做得不错）
之后，到了京东的投诉中心提了一条关于这个货运状态的建议，
客服回复：	您好,因快递输入回执较慢，还请您稍后查询，为您带来的不便还请您见谅！
这客服回答也太敷衍了事..对京东的印象减分了~
对于网上购物来说，物流状态应该是相当基础的一项服务，从技术角度来说，也是不难实现的。
小细节，好体验。

&#8212;&#8212;-2009-4-11更新&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
今天在京东网站看到物流状态这一块貌似改版了：

不错的改进，如果再能读出快递的相关状态，并给出快递公司的网站链接，就更好了！
]]></description>
			<content:encoded><![CDATA[<p>在京东给老爸买了一套罗技的键鼠套装。<br />
第二天登录网站查询看到的货运状态是：</p>
<p>送货方式：EMS<br />
承 运 人：京东<br />
货运单号：2249457148 点击查询<br />
承运人电话：020-28809135</p>
<p>“点击查询”的链接是http://www.ems.com.cn/<br />
事实上，这个单号在ems网站是查询不了的，ems页面提示，单号是13位。<br />
于是想到，京东应该是有很多家快递商合作的，但这里的状态显示却相当地不人性化。<br />
应该针对不同的单号，显示各家快递的网站以及查询网址的链接，如果可以的话，直接从对方网站读取状态信息。（淘宝就做得不错）</p>
<p>之后，到了京东的投诉中心提了一条关于这个货运状态的建议，<br />
客服回复：	您好,因快递输入回执较慢，还请您稍后查询，为您带来的不便还请您见谅！<br />
这客服回答也太敷衍了事..对京东的印象减分了~</p>
<p>对于网上购物来说，物流状态应该是相当基础的一项服务，从技术角度来说，也是不难实现的。<br />
小细节，好体验。</p>
<p><span id="more-507"></span><br />
&#8212;&#8212;-2009-4-11更新&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
今天在京东网站看到物流状态这一块貌似改版了：<br />
<img src="http://foxling.org/wp-content/uploads/2010/04/360buy_express.gif" alt="" title="360buy物流状态" width="600" height="243" class="alignnone size-full wp-image-511" /><br />
不错的改进，如果再能读出快递的相关状态，并给出快递公司的网站链接，就更好了！</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/ued/360buy-express/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
