<?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>行骏-IT Player &#187; 前端事儿</title>
	<atom:link href="http://www.movinghorse.cn/category/%e5%89%8d%e7%ab%af%e4%ba%8b%e5%84%bf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.movinghorse.cn</link>
	<description>Front End Engineer</description>
	<lastBuildDate>Fri, 09 Jul 2010 13:25:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>innerHTML和cloneNode表现的很不好</title>
		<link>http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/</link>
		<comments>http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 13:14:03 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=298</guid>
		<description><![CDATA[有时候需要把表单里的元素复制出来，这里有两个方法，一是先去innerHTML，然后在innerHTML到其他的地方；二是cloneNode(true)出来到其他地方，但是这个两个方法在各个浏览器仅仅是对普通的表单的元素都是支持不完善的，甚至IE自己的系列都有变化。 以下是支持列表，yes表示会把值复制出来，no表示不会。其实还有包括表单元素的自定义属性，事件等也是各有千秋，我实在是懒得列举。 innerHTML IE6 IE7 IE8 FF Chrome input[text] yes yes yes no no input[checkbox] yes yes no no no input[radio] yes yes no no no select yes yes yes no no textarea yes yes yes no no cloneNode IE6 IE7 IE8 FF Chrome input[text] yes yes yes yes yes input[checkbox] no no no yes [...]]]></description>
			<content:encoded><![CDATA[<p>有时候需要把表单里的元素复制出来，这里有两个方法，一是先去innerHTML，然后在innerHTML到其他的地方；二是cloneNode(true)出来到其他地方，但是这个两个方法在各个浏览器仅仅是对普通的表单的元素都是支持不完善的，甚至IE自己的系列都有变化。</p>
<p>以下是支持列表，yes表示会把值复制出来，no表示不会。其实还有包括表单元素的自定义属性，事件等也是各有千秋，我实在是懒得列举。</p>
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td width="138">innerHTML</td>
<td width="72">IE6</td>
<td width="72">IE7</td>
<td width="72">IE8</td>
<td width="72">FF</td>
<td width="88">Chrome</td>
</tr>
<tr>
<td>input[text]</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>input[checkbox]</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>input[radio]</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>select</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>textarea</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
</tr>
</table>
</p>
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td width="138">cloneNode</td>
<td width="72">IE6</td>
<td width="72">IE7</td>
<td width="72">IE8</td>
<td width="72">FF</td>
<td width="88">Chrome</td>
</tr>
<tr>
<td>input[text]</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>input[checkbox]</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>input[radio]</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>yes</td>
<td>yes</td>
</tr>
<tr>
<td>select</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>no</td>
<td>no</td>
</tr>
<tr>
<td>textarea</td>
<td>yes</td>
<td>yes</td>
<td>yes</td>
<td>no</td>
<td>no</td>
</tr>
</table>
<p>解决上面的最保险的方法是对每一个元素类似这样:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> aClone <span style="color: #339933;">=</span> dClone.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'SELECT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> aSelect	 <span style="color: #339933;">=</span> dSelect.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'SELECT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> aClone.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">&amp;&amp;</span> aClone.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> aSelect.<span style="color: #660066;">length</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> aClone.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		aClone<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">selectedIndex</span> <span style="color: #339933;">=</span> aSelect<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">selectedIndex</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>随即，附送美图一张：<br />
<a href="http://www.movinghorse.cn/wp-content/uploads/2010-outing.jpg"><img class="alignnone size-medium wp-image-301" title="2010-outing" src="http://www.movinghorse.cn/wp-content/uploads/2010-outing-300x63.jpg" alt="" width="300" height="63" /></a><br />
点击小图看大图，这次outing最欢畅的就是住五星，很豪华很奢侈！</p>
<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2010. |
<a href="http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/">Permalink</a> |
<a href="http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/&title=innerHTML和cloneNode表现的很不好">del.icio.us</a>
<br/>
Post tags: <a href="http://www.movinghorse.cn/tag/%e5%89%8d%e7%ab%af/" rel="tag">前端</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2010/07/09/innerhtml-clonenode-bad/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Function function Object instanceof</title>
		<link>http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/</link>
		<comments>http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/#comments</comments>
		<pubDate>Fri, 07 May 2010 14:33:49 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=260</guid>
		<description><![CDATA[看怿飞的与 Function 和 Object 相关的有趣代码，据说此人也叫圆心，公布下答案： function Foo&#40;&#41; &#123;&#125;; var foo = new Foo&#40;&#41;; alert&#40;foo instanceof Foo&#41;; // true alert&#40;foo instanceof Object&#41;; // true alert&#40;foo instanceof Function&#41;; // false alert&#40;Foo instanceof Function&#41;; // true alert&#40;Foo instanceof Object&#41;; // true 先上图： 以上这张图杂乱无章，其实我不太看懂，那先看下下面这些例子： 1: Function 和 function alert&#40;Function&#41;; //function Function() { // [native code] //} alert&#40;typeof Function&#41;; //function [...]]]></description>
			<content:encoded><![CDATA[<p>看<a href="http://www.planabc.net/" target="_blank">怿飞</a>的<a title="http://www.planabc.net/2010/05/06/interesting_code_associated_with_function_and_object/" href="http://www.planabc.net/2010/05/06/interesting_code_associated_with_function_and_object/" target="_blank">与 Function 和 Object 相关的有趣代码</a>，据说此人也叫<a href="http://www.planabc.net/" target="_blank">圆心</a>，公布下答案：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> Foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> foo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>foo <span style="color: #000066; font-weight: bold;">instanceof</span> Foo<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>foo <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>foo <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// false</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>Foo <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>Foo <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span></pre></div></div>

<p>先上图：</p>
<p><a href="http://www.movinghorse.cn/wp-content/uploads/javascript_object_layout.jpg"><img class="alignnone size-full wp-image-261" title="javascript_object_layout" src="http://www.movinghorse.cn/wp-content/uploads/javascript_object_layout.jpg" alt="" width="611" height="760" /></a></p>
<p>以上这张图杂乱无章，其实我不太看懂，那先看下下面这些例子：</p>
<p>1: Function 和 function</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//function Function() {</span>
    <span style="color: #006600; font-style: italic;">//  [native code]</span>
    <span style="color: #006600; font-style: italic;">//}</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//function</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">Function</span> <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// true</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> fun<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> fun<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//function</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>fun.<span style="color: #660066;">constructor</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>fun <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>fun <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span></pre></div></div>

<p>Function系统内置的function，用户定义的 function 都由它创建。并且他们都是&#8221;继承&#8221;于Object的.<br />
2: function 和 Object</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//function</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #660066;">constructor</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">Class</span> <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">Class</span> <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//object</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> c1 <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> c1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">//object</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>c1.<span style="color: #660066;">constructor</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>c1 <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>c1 <span style="color: #000066; font-weight: bold;">instanceof</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//false</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>c1 <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> c1.__proto__<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//ie下为undefined firefox为object</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>c1.__proto__ <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//ie下为flase firefox为true</span></pre></div></div>

<p>function 是 Function 的一个实例，是继承与Object的，在具有Object对象的特征之外，还具有<br />
1) 可以进行 new 操作，来模拟一些面向对象的功能， new 操作返回的是一个 object 对象。它是构造函数和Object对象的实例。<br />
2) new Class() 操作的三个步骤<br />
a) var c1 = new Object 对象<br />
b) 新建的 c1 复制 原来 function Class 的所有属性和方法<br />
c) c1.__proto__ = Class.prototype<br />
3) 在c1中，把this 指向c1<br />
//ie 中 看不到__proto__,不过应该有相应的隐藏值</p>
<p>3: 关于javascript中instanceof</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">function</span> class1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> class2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    class2.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> class3<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    class3.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> class4<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    class4.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class3<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> class5<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    class5.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class4<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class4<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//测试正常的继承关系</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//false</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
&nbsp;
    class3.<span style="color: #660066;">prototype</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> class5<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//改变继承关系</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//测试改变后的继承关系</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//false</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//false</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true  仍然是true</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>obj <span style="color: #000066; font-weight: bold;">instanceof</span> class1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//true  仍然是true</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> _proto <span style="color: #339933;">=</span> obj.__proto__<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>_proto<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_proto <span style="color: #339933;">==</span> class1.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class1&quot;</span><span style="color: #009900;">&#41;</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>_proto <span style="color: #339933;">==</span> class2.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class2&quot;</span><span style="color: #009900;">&#41;</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>_proto <span style="color: #339933;">==</span> class3.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class3&quot;</span><span style="color: #009900;">&#41;</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>_proto <span style="color: #339933;">==</span> class4.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class4&quot;</span><span style="color: #009900;">&#41;</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>_proto <span style="color: #339933;">==</span> class5.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class5&quot;</span><span style="color: #009900;">&#41;</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>_proto <span style="color: #339933;">==</span> Object.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;unknow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>_proto.<span style="color: #660066;">constructor</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            _proto <span style="color: #339933;">=</span> _proto.__proto__<span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span></pre></div></div>

<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2010. |
<a href="http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/">Permalink</a> |
<a href="http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/#comments">4 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/&title=Function function Object instanceof">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2010/05/07/function-function-object-instanceof/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>五种开源协议(GPL,LGPL,BSD,MIT,Apache)</title>
		<link>http://www.movinghorse.cn/2010/04/02/open-source/</link>
		<comments>http://www.movinghorse.cn/2010/04/02/open-source/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 15:14:27 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=251</guid>
		<description><![CDATA[什么是许可协议？ 什么是许可，当你为你的产品签发许可，你是在出让自己的权利，不过，你仍然拥有版权和专利（如果申请了的话），许可的目的是，向使用你产品的人提供一定的权限。 不管产品是免费向公众分发，还是出售，制定一份许可协议非常有用，否则，对于前者，你相当于放弃了自己所有的权利，任何人都没有义务表明你的原始作者身份，对于后者，你将不得不花费比开发更多的精力用来逐个处理用户的授权问题。 而开源许可协议使这些事情变得简单，开发者很容易向一个项目贡献自己的代码，它还可以保护你原始作者的身份，使你至少获得认可，开源许可协议还可以阻止其它人将某个产品据为己有。以下是开源界的 5 大许可协议。 GNU GPL GNU General Public Licence (GPL) 有可能是开源界最常用的许可模式。GPL 保证了所有开发者的权利，同时为使用者提供了足够的复制，分发，修改的权利： 可自由复制 你可以将软件复制到你的电脑，你客户的电脑，或者任何地方。复制份数没有任何限制。 可自由分发 在你的网站提供下载，拷贝到U盘送人，或者将源代码打印出来从窗户扔出去（环保起见，请别这样做）。 可以用来盈利 你可以在分发软件的时候收费，但你必须在收费前向你的客户提供该软件的 GNU GPL 许可协议，以便让他们知道，他们可以从别的渠道免费得到这份软件，以及你收费的理由。 可自由修改 如果你想添加或删除某个功能，没问题，如果你想在别的项目中使用部分代码，也没问题，唯一的要求是，使用了这段代码的项目也必须使用 GPL 协议。 需要注意的是，分发的时候，需要明确提供源代码和二进制文件，另外，用于某些程序的某些协议有一些问题和限制，你可以看一下 @PierreJoye 写的 Practical Guide to GPL Compliance 一文。使用 GPL 协议，你必须在源代码代码中包含相应信息，以及协议本身。 GNU LGPL GNU 还有另外一种协议，叫做 LGPL （Lesser General Public Licence），它对产品所保留的权利比 GPL 少，总的来说，LGPL 适合那些用于非 GPL 或非开源产品的开源类库或框架。因为 GPL 要求，使用了 GPL 代码的产品必须也使用 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.movinghorse.cn/wp-content/uploads/opensourceubuntu.jpg"><img class="alignnone size-full wp-image-252" title="open-source-ubuntu" src="http://www.movinghorse.cn/wp-content/uploads/opensourceubuntu.jpg" alt="" width="500" height="333" /></a></p>
<h3>什么是许可协议？</h3>
<p>什么是许可，当你为你的产品签发许可，你是在出让自己的权利，不过，你仍然拥有版权和专利（如果申请了的话），许可的目的是，向使用你产品的人提供一定的权限。</p>
<p>不管产品是免费向公众分发，还是出售，制定一份许可协议非常有用，否则，对于前者，你相当于放弃了自己所有的权利，任何人都没有义务表明你的原始作者身份，对于后者，你将不得不花费比开发更多的精力用来逐个处理用户的授权问题。</p>
<p>而<a href="http://en.wikipedia.org/wiki/Open-source_license" target="_blank">开源许可协议</a>使这些事情变得简单，开发者很容易向一个项目贡献自己的代码，它还可以保护你原始作者的身份，使你至少获得认可，开源许可协议还可以阻止其它人将某个产品据为己有。以下是开源界的 5 大许可协议。</p>
<h3>GNU GPL</h3>
<p><a href="http://www.opensource.org/licenses/gpl-2.0.php" target="_blank">GNU General Public Licence</a> (GPL) 有可能是开源界最常用的许可模式。GPL 保证了所有开发者的权利，同时为使用者提供了足够的复制，分发，修改的权利：</p>
<ul>
<li><strong>可自由复制</strong><br />
你可以将软件复制到你的电脑，你客户的电脑，或者任何地方。复制份数没有任何限制。</li>
<li><strong>可自由分发</strong><br />
在你的网站提供下载，拷贝到U盘送人，或者将源代码打印出来从窗户扔出去（环保起见，请别这样做）。</li>
<li><strong>可以用来盈利</strong><br />
你可以在分发软件的时候收费，但你必须在收费前向你的客户提供该软件的 GNU GPL 许可协议，以便让他们知道，他们可以从别的渠道免费得到这份软件，以及你收费的理由。</li>
<li><strong>可自由修改</strong><br />
如果你想添加或删除某个功能，没问题，如果你想在别的项目中使用部分代码，也没问题，唯一的要求是，使用了这段代码的项目也必须使用 GPL 协议。</li>
</ul>
<p>需要注意的是，分发的时候，需要明确提供源代码和二进制文件，另外，用于某些程序的某些协议有一些问题和限制，你可以看一下 <a href="http://www.twitter.com/PierreJoye" target="_blank">@PierreJoye</a> 写的 <a href="http://www.softwarefreedom.org/resources/2008/compliance-guide.html" target="_blank">Practical Guide to GPL Compliance</a> 一文。使用 GPL 协议，你必须在源代码代码中包含相应信息，以及协议本身。</p>
<h4>GNU LGPL</h4>
<p>GNU 还有另外一种协议，叫做 LGPL （<a href="http://www.opensource.org/licenses/lgpl-2.1.php" target="_blank">Lesser General Public Licence</a>），它对产品所保留的权利比 GPL 少，总的来说，LGPL 适合那些用于非 GPL 或非开源产品的开源类库或框架。因为 GPL 要求，使用了 GPL 代码的产品必须也使用 GPL 协议，开发者不允许将 GPL 代码用于商业产品。LGPL 绕过了这一限制。</p>
<h3>BSD</h3>
<p>BSD 在软件分发方面的限制比别的开源协议（如 GNU GPL）要少。该协议有多种版本，最主要的版本有两个，新 BSD 协议与简单 BSD 协议，这两种协议经过修正，都和 GPL 兼容，并为开源组织所认可。</p>
<p>新 BSD 协议（3条款协议）在软件分发方面，除需要包含一份版权提示和免责声明之外，没有任何限制。另外，该协议还禁止拿开发者的名义为衍生产品背书，但简单 BSD 协议删除了这一条款。</p>
<h3>MIT</h3>
<p><a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">MIT 协议</a>可能是几大开源协议中最宽松的一个，核心条款是：</p>
<p>该软件及其相关文档对所有人免费，可以任意处置，包括使用，复制，修改，合并，发表，分发，再授权，或者销售。唯一的限制是，软件中必须包含上述版权和许可提示。</p>
<p>这意味着：</p>
<ul>
<li>你可以自由使用，复制，修改，可以用于自己的项目。</li>
<li>可以免费分发或用来盈利。</li>
<li>唯一的限制是必须包含许可声明。</li>
</ul>
<p>MIT 协议是所有开源许可中最宽松的一个，除了必须包含许可声明外，再无任何限制。</p>
<h3>Apache</h3>
<p>Apache 协议 2.0 和别的开源协议相比，除了为用户提供版权许可之外，还有专利许可，对于那些涉及专利内容的开发者而言，该协议最适合（<a href="http://www.howstuffworks.com/question492.htm" target="_blank">这里有一篇文章阐述这个问题</a>）。</p>
<p>Apache 协议还有以下需要说明的地方:</p>
<ul>
<li><strong>永久权利</strong><br />
一旦被授权，永久拥有。</li>
<li><strong>全球范围的权利</strong><br />
在一个国家获得授权，适用于所有国家。假如你在美国，许可是从印度授权的，也没有问题。</li>
<li><strong>授权免费，且无版税</strong><br />
前期，后期均无任何费用。</li>
<li><strong>授权无排他性</strong><br />
任何人都可以获得授权</li>
<li><strong>授权不可撤消</strong><br />
一旦获得授权，没有任何人可以取消。比如，你基于该产品代码开发了衍生产品，你不用担心会在某一天被禁止使用该代码。</li>
</ul>
<p>分发代码方面包含一些要求，主要是，要在声明中对参与开发的人给予认可并包含一份许可协议原文。</p>
<h3>Creative Commons</h3>
<p>Creative Commons (CC) 并非严格意义上的开源许可，它主要用于设计。Creative Commons 有多种协议，每种都提供了相应授权模式，CC 协议主要包含 4 种基本形式：</p>
<ul>
<li><strong>署名权</strong><br />
必须为原始作者署名，然后才可以修改，分发，复制。</li>
<li><strong>保持一致</strong><br />
作品同样可以在 CC 协议基础上修改，分发，复制。</li>
<li><strong>非商业</strong><br />
作品可以被修改，分发，复制，但不能用于商业用途。但商业的定义有些模糊，比如，有的人认为非商业用途指的是不能销售，有的认为是甚至不能放在有广告的网站，也有人认为非商业的意思是非盈利。</li>
<li><strong>不能衍生新作品</strong><br />
你可以复制，分发，但不能修改，也不能以此为基础创作自己的作品。</li>
</ul>
<p>这些许可形式可以结合起来用，其中最严厉的组合是“署名，非商用，不能衍生新作品”，意味着，你可以分享作品，但不能改动或以此盈利，而且必须为原作者署名。在这种许可模式下，原始作者对作品还拥有完全的控制权，而最宽松的组合是“署名”，意味着，只要为原始作者署名了，就可以自由处置。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<strong>因为在此之前，我用了国内的一些开源程序，但是呢这些程序都是需要商业授权的，不知道能不能免费的自己搭建起来给企业用。比如说shopex，康盛的产品， PHPCMS等等。。。。<br />
如果真用了，他们会找上门来问你要版权么？ </strong></p>
<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2010. |
<a href="http://www.movinghorse.cn/2010/04/02/open-source/">Permalink</a> |
<a href="http://www.movinghorse.cn/2010/04/02/open-source/#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2010/04/02/open-source/&title=五种开源协议(GPL,LGPL,BSD,MIT,Apache)">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2010/04/02/open-source/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>争论：为什么Firefox的Javascript速度无法超越其它浏览器</title>
		<link>http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/</link>
		<comments>http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 15:13:16 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=246</guid>
		<description><![CDATA[有道 &#8220;Firefox在速度上暂时落后于chrome safari和opera。原因并不是Mozilla技术差，而是因为其他浏览器支持的javascript，只是Firefox的一个子集，有很多东西，被其他浏览器忽略了。 1)只有Firefox支持E4X： E4X是一个javascript的附加标准，用于在javascript里简便快速的操作XML。有多方便？ 2) 只有Firefox在逐步实现ECMAScript5: ECMAScript5是下一代javascript标准，目前的Firefox已经包含了很多ECMAScript5的特性，而其他浏览器似乎并没有公布相关的计划。ECMAScript5是一个已经发布了的标准，和遥遥无期的HTML5比起来，实现ECMAScript5要务实得多。 3) Firefox在javascript和html的交互上更加优化： HTML中部分属性，只有Firefox才能通过js去调用，其他浏览器只能写成静态html标签,目前浏览器脚本速度测试用的都是1999年的标准。10年前的标准不可能永远用下去。先实现标准，再进行速度优化，这才是正道。相信脚踏实地的Firefox可以走得更远。&#8221; 有说法： 1.HTML5不是遥遥无期，只是未到主流开发者使用。 话说DIV+CSS都不知道流行多少年了，但是好多网站还是用Table。也不怪得浏览器中IE使用率其高，因为Javascript 还不是用户浏览一般网站的核心障碍，开得舒心就行了，所以你们开发者就想着怎么给IE6 hack。是不是DIV+CSS？是不是XHTML Strict？是不是HTML5？关用户什么事。 应用比技术更重要一点。有了Gmail、Google Wave才用得着高速的Js解释功能，没有网银的话还是IE、Windows的世界。 2.为什么IE总是慢于其他浏览器：美国有多少人要求浏览器默认关闭javascript，再看看中国人，他妈连javascript是什么都不知道。 3.美国有多少人要求浏览器默认关闭javascript，再看看中国人，他妈连javascript是什么都不知道。 © 行骏 for 行骏-IT Player, 2010. &#124; Permalink &#124; 2 comments &#124; Add to del.icio.us Post tags: Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<div id="attachment_248" class="wp-caption alignnone" style="width: 235px"><a href="http://www.movinghorse.cn/wp-content/uploads/firefox-chrome-ie.png"><img class="size-full wp-image-248" title="firefox-chrome-ie" src="http://www.movinghorse.cn/wp-content/uploads/firefox-chrome-ie.png" alt="firefox-chrome-ie" width="225" height="207" /></a><p class="wp-caption-text">firefox-chrome-ie</p></div>
<p>有道 &#8220;Firefox在速度上暂时落后于chrome safari和opera。原因并不是Mozilla技术差，而是因为其他浏览器支持的javascript，只是Firefox的一个子集，有很多东西，被其他浏览器忽略了。<br />
<strong> 1)只有Firefox支持E4X：</strong><br />
E4X是一个javascript的附加标准，用于在javascript里简便快速的操作XML。有多方便？<br />
<strong> 2) 只有Firefox在逐步实现ECMAScript5:</strong><br />
ECMAScript5是下一代javascript标准，目前的Firefox已经包含了很多ECMAScript5的特性，而其他浏览器似乎并没有公布相关的计划。ECMAScript5是一个已经发布了的标准，和遥遥无期的HTML5比起来，实现ECMAScript5要务实得多。<br />
<strong> 3) Firefox在javascript和html的交互上更加优化：</strong><br />
HTML中部分属性，只有Firefox才能通过js去调用，其他浏览器只能写成静态html标签,目前浏览器脚本速度测试用的都是1999年的标准。10年前的标准不可能永远用下去。先实现标准，再进行速度优化，这才是正道。相信脚踏实地的Firefox可以走得更远。&#8221;</p>
<p>有说法：</p>
<p>1.HTML5不是遥遥无期，只是未到主流开发者使用。<br />
话说DIV+CSS都不知道流行多少年了，但是好多网站还是用Table。也不怪得浏览器中IE使用率其高，因为Javascript 还不是用户浏览一般网站的核心障碍，开得舒心就行了，所以你们开发者就想着怎么给IE6 hack。是不是DIV+CSS？是不是XHTML Strict？是不是HTML5？关用户什么事。<br />
应用比技术更重要一点。有了Gmail、Google Wave才用得着高速的Js解释功能，没有网银的话还是IE、Windows的世界。</p>
<p>2.<strong>为什么IE总是慢于其他浏览器：</strong>美国有多少人要求浏览器默认关闭javascript，再看看中国人，他妈连javascript是什么都不知道。</p>
<p>3.美国有多少人要求浏览器默认关闭javascript，再看看中国人，他妈连javascript是什么都不知道。</p>
<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2010. |
<a href="http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/">Permalink</a> |
<a href="http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/&title=争论：为什么Firefox的Javascript速度无法超越其它浏览器">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2010/03/05/why-firefox-javascript-speed-slow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>正则性能</title>
		<link>http://www.movinghorse.cn/2010/02/23/regular-expression/</link>
		<comments>http://www.movinghorse.cn/2010/02/23/regular-expression/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 04:36:43 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=207</guid>
		<description><![CDATA[1 2 3 var r = /^\w+?([\.]?[a-zA-Z0-9\-]+)*?@[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]+$/; var s = r.test&#40;'asdfasdfasdfasdfasdfasdfasdfasdfasdsdffgggasdfa'&#41;; alert&#40;s&#41;; 这个正则表达式导致浏览器死掉，包括chrome。 先记录在这，回头看看正则的实现，感觉好像是和编译原理有关的东西，可惜大学时的这堂课没有学好啊！ © 行骏 for 行骏-IT Player, 2010. &#124; Permalink &#124; One comment &#124; Add to del.icio.us Post tags: Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<div id="attachment_219" class="wp-caption alignnone" style="width: 510px"><a href="http://www.movinghorse.cn/wp-content/uploads/c728354.jpg"><img src="http://www.movinghorse.cn/wp-content/uploads/c728354.jpg" alt="正则表达式" title="正则表达式" width="500" height="307" class="size-full wp-image-219" /></a><p class="wp-caption-text">正则表达式</p></div>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^\w+?([\.]?[a-zA-Z0-9\-]+)*?@[a-zA-Z0-9]+([-.][a-zA-Z0-9]+)*\.[a-zA-Z]+$/</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> r.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'asdfasdfasdfasdfasdfasdfasdfasdfasdsdffgggasdfa'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这个正则表达式导致浏览器死掉，包括chrome。<br />
先记录在这，回头看看正则的实现，感觉好像是和编译原理有关的东西，可惜大学时的这堂课没有学好啊！</p>
<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2010. |
<a href="http://www.movinghorse.cn/2010/02/23/regular-expression/">Permalink</a> |
<a href="http://www.movinghorse.cn/2010/02/23/regular-expression/#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2010/02/23/regular-expression/&title=正则性能">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2010/02/23/regular-expression/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>javascript区别对象和数组</title>
		<link>http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/</link>
		<comments>http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 15:39:20 +0000</pubDate>
		<dc:creator>行骏</dc:creator>
				<category><![CDATA[前端事儿]]></category>

		<guid isPermaLink="false">http://www.movinghorse.cn/?p=132</guid>
		<description><![CDATA[看《Javascript语言精粹》上看到的，挺有意思的，权当记录。 首先知道，我们的JavaScript中的数据很简洁的。只有 undefined, null, boolean, number,string,object。 Javascript中认为数组是一个对象，所以直接通过typeof是无法检测出是否是Array还是Object的，所以判断两者可以这样做： 1 2 3 var isArray = function&#40;value&#41;&#123; return value &#38;&#38; typeof value === 'object' &#38;&#38; value.constuctor = Array; &#125; 但是在检测从不同的敞口（window）或 （frame）里构造的数组会有问题，douglas crockford给出了如下的解决方案： 1 2 3 var isArray = function&#40;value&#41;&#123; return value &#38;&#38; typeof value === 'object' &#38;&#38; typeof value.length === 'number' &#38;&#38; typeof value === 'function' &#38;&#38; !&#40;value.propertyIsEnumerable&#40;'length'&#41;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_133" class="wp-caption alignnone" style="width: 310px"><a href="http://www.movinghorse.cn/wp-content/uploads/javascript-the-good-parts.jpg"><img class="size-full wp-image-133" title="javascript-the-good-parts" src="http://www.movinghorse.cn/wp-content/uploads/javascript-the-good-parts.jpg" alt="Javascript 语言精粹" width="300" height="400" /></a><p class="wp-caption-text">Javascript 语言精粹</p></div>
<p><strong>看《Javascript语言精粹》上看到的，挺有意思的，权当记录。</strong></p>
<p>首先知道，我们的JavaScript中的数据很简洁的。只有 undefined, null, boolean, number,string,object。</p>
<p>Javascript中认为数组是一个对象，所以直接通过typeof是无法检测出是否是Array还是Object的，所以判断两者可以这样做：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> isArray <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">return</span> value <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> value <span style="color: #339933;">===</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">&amp;&amp;</span> value.<span style="color: #660066;">constuctor</span> <span style="color: #339933;">=</span> Array<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>但是在检测从不同的敞口（window）或 （frame）里构造的数组会有问题，douglas crockford给出了如下的解决方案：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> isArray <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">return</span> value <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> value <span style="color: #339933;">===</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> value.<span style="color: #660066;">length</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'number'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> value <span style="color: #339933;">===</span> <span style="color: #3366CC;">'function'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>value.<span style="color: #660066;">propertyIsEnumerable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'length'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>所有的建议是如果你想要深入学习一门语言的时候，一定要看权威的著作！</strong></p>
<hr />
<p><small>© 行骏 for <a href="http://www.movinghorse.cn">行骏-IT Player</a>, 2009. |
<a href="http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/">Permalink</a> |
<a href="http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/&title=javascript区别对象和数组">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.movinghorse.cn/2009/12/13/javascript-difference-between-array-and-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
