<?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>G法师的博客</title>
	<atom:link href="http://www.jatx.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jatx.net</link>
	<description>努力把简单的问题搞复杂 -- 我的代码之旅</description>
	<lastBuildDate>Sat, 10 Jul 2010 00:49:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[]==false之原理</title>
		<link>http://www.jatx.net/archives/124</link>
		<comments>http://www.jatx.net/archives/124#comments</comments>
		<pubDate>Sat, 10 Jul 2010 00:49:23 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.jatx.net/archives/124</guid>
		<description><![CDATA[问题来源

var a = [];

if(a) alert(&#34;true&#34;);//true

if(a == true) alert(&#34;true&#34;);//false


原理
js引擎会先计算括号内的表达式然后将结果转换为布尔值，所以
if(a) =&#62; if(!!a) =&#62; true
if(a == true) =&#62; if(Number(a) == true) =&#62; if(0 == true) =&#62; true
注: 在比较的两个值中，如果有一个是布尔类型，那么另外一个值将会先被转换为数字类型再与其比较。
参考： 双等号的比较原理
所以，下面这个就会有看起来奇怪的结果
[] == ![] //true
]]></description>
			<content:encoded><![CDATA[<p><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><meta name="generator" content="editplus" /><meta name="author" content="" /><meta name="keywords" content="" /><meta name="description" content="" />问题来源
<div>
<pre><span style="color: #0000ff">var</span> a = [];

<span style="color: #0000ff">if</span>(a) <span style="color: #0000ff">alert</span>(&quot;<span style="color: #8b0000">true</span>&quot;);<span style="color: #008000">//true</span>

<span style="color: #0000ff">if</span>(a == <span style="color: #0000ff">true</span>) <span style="color: #0000ff">alert</span>(&quot;<span style="color: #8b0000">true</span>&quot;);<span style="color: #008000">//false</span></pre>
</div>
<p></p>
<p>原理</p>
<p>js引擎会先计算括号内的表达式然后将结果转换为布尔值，所以</p>
<p><span style="color: #0000ff">if(a) <span style="color: #808080">=&gt;</span> if(!!a) <span style="color: #808080">=&gt;</span> true</span></p>
<p><span style="color: #0000ff">if(a == true) <span style="color: #808080">=&gt;</span> if(Number(a) == true) <span style="color: #808080">=&gt;</span> if(0 == true) <span style="color: #808080">=&gt;</span> true</span></p>
<p>注: 在比较的两个值中，如果有一个是布尔类型，那么另外一个值将会先被转换为数字类型再与其比较。</p>
<p>参考： <a href="http://www.jatx.net/archives/119" target="_blank">双等号的比较原理</a></p>
<p>所以，下面这个就会有看起来奇怪的结果</p>
<p>[] == ![] //true</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/124/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>超长叠代</title>
		<link>http://www.jatx.net/archives/122</link>
		<comments>http://www.jatx.net/archives/122#comments</comments>
		<pubDate>Thu, 17 Jun 2010 10:29:09 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[叠代]]></category>
		<category><![CDATA[循环]]></category>
		<category><![CDATA[超时]]></category>

		<guid isPermaLink="false">http://www.jatx.net/archives/122</guid>
		<description><![CDATA[
for(var i=0; i&#60;1000000; i++) {
    //do some thing.
}

话说以上代码很可能会被浏览器判作执行超时。
  试验了一下可以用浏览器的延时来做：

(function() {
    //do some thing.
    setTimeout(arguments.callee, 0);
})();



  这样一来CPU倒是基本没有，但是这样的代码运行过慢，所以综合一下：

&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62;
  &#60;title&#62; new document &#60;/title&#62;
  &#60;script type=&#34;text/javascript&#34;&#62;

	var interval = function(f, o) {
		var _onceRunTime [...]]]></description>
			<content:encoded><![CDATA[<div>
<pre><span style="color: #0000ff">for</span>(<span style="color: #0000ff">var</span> i=0; i&lt;1000000; i++) {
    <span style="color: #008000">//do some thing.</span>
}</pre>
</div>
<p>话说以上代码很可能会被浏览器判作执行超时。<br />
  <br />试验了一下可以用浏览器的延时来做：</p>
<div>
<pre>(<span style="color: #0000ff">function</span>() {
    <span style="color: #008000">//do some thing.</span>
    <span style="color: #0000ff">setTimeout</span>(<span style="color: #0000ff">arguments</span>.<span style="color: #0000ff">callee</span>, 0);
})();</pre>
</div>
<p></p>
<p>
  <br />这样一来CPU倒是基本没有，但是这样的代码运行过慢，所以综合一下：</p>
<div>
<pre class="source">&lt;!DOCTYPE html PUBLIC &quot;<span style="color: #8b0000">-//W3C//DTD XHTML 1.0 Transitional//EN</span>&quot; &quot;<span style="color: #8b0000">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</span>&quot;&gt;
&lt;html xmlns=&quot;<span style="color: #8b0000">http://www.w3.org/1999/xhtml</span>&quot;&gt;
 &lt;head&gt;
 &lt;meta http-equiv=&quot;<span style="color: #8b0000">Content-Type</span>&quot; content=&quot;<span style="color: #8b0000">text/html; charset=utf-8</span>&quot; /&gt;
  &lt;title&gt; <span style="color: #0000ff">new</span> <span style="color: #0000ff">document</span> &lt;/title&gt;
  &lt;script type=&quot;<span style="color: #8b0000">text/javascript</span>&quot;&gt;

	<span style="color: #0000ff">var</span> interval = <span style="color: #0000ff">function</span>(f, o) {
		<span style="color: #0000ff">var</span> _onceRunTime = 5000;<span style="color: #008000">//每5秒一个新的任务队列</span>
		<span style="color: #0000ff">var</span> i = 0;
		(<span style="color: #0000ff">function</span>() {
			<span style="color: #0000ff">var</span> _st = <span style="color: #0000ff">new</span> <span style="color: #0000ff">Date</span>().getTime();
			<span style="color: #0000ff">while</span>(<span style="color: #0000ff">true</span>) {
				<span style="color: #0000ff">if</span>(<span style="color: #0000ff">new</span> <span style="color: #0000ff">Date</span>().getTime() - _st &gt; _onceRunTime) <span style="color: #0000ff">break</span>;
				<span style="color: #0000ff">if</span>(!f.call(o, i)) <span style="color: #0000ff">return</span>;
				i++;
			}
			<span style="color: #0000ff">setTimeout</span>(<span style="color: #0000ff">arguments</span>.<span style="color: #0000ff">callee</span>, 0);
		})();
	};
	<span style="color: #0000ff">function</span> run(i) {
		<span style="color: #0000ff">document</span>.getElementById(&quot;<span style="color: #8b0000">log</span>&quot;).value = i;
		<span style="color: #0000ff">return</span> i&lt;1000000;
	}

	<span style="color: #0000ff">function</span> test() {
		interval(run, <span style="color: #0000ff">this</span>);
	}
  &lt;/script&gt;
 &lt;/head&gt;

 &lt;body&gt;
  &lt;input type=&quot;<span style="color: #8b0000">text</span>&quot; id=&quot;<span style="color: #8b0000">log</span>&quot; /&gt; &lt;button id=&quot;<span style="color: #8b0000">b</span>&quot; onclick=&quot;<span style="color: #8b0000">test();</span>&quot;&gt;start&lt;/button&gt;
 &lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p></p>
</p>
<p>注意运行时也会使浏览器无反应，不过在每一个任务队列结束时仍然有机会刷新面。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/122/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MYSQL导入与导出命令</title>
		<link>http://www.jatx.net/archives/120</link>
		<comments>http://www.jatx.net/archives/120#comments</comments>
		<pubDate>Mon, 07 Jun 2010 14:48:07 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://www.jatx.net/?p=120</guid>
		<description><![CDATA[可以备份大量数据
1，数据库备份命令
mysqldump -h localhost  -u   root   -p   --default-character-set=utf8   dbname >backup.sql
2，导入数据命令：
mysql -h localhost  -u   root   -p   --default-character-set=utf8
use dbname
source backup.sql
]]></description>
			<content:encoded><![CDATA[<p>可以备份大量数据</p>
<p>1，数据库备份命令<br />
mysqldump -h localhost  -u   root   -p   --default-character-set=utf8   dbname >backup.sql</p>
<p>2，导入数据命令：<br />
mysql -h localhost  -u   root   -p   --default-character-set=utf8<br />
use dbname<br />
source backup.sql</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/120/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>双等号的比较原理</title>
		<link>http://www.jatx.net/archives/119</link>
		<comments>http://www.jatx.net/archives/119#comments</comments>
		<pubDate>Sun, 09 May 2010 05:42:27 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[双等]]></category>
		<category><![CDATA[相等]]></category>

		<guid isPermaLink="false">http://www.jatx.net/archives/119</guid>
		<description><![CDATA[直接摘自ECMA262
章节号：11.9.3 The Abstract Equality Comparison Algorithm   
比较 x == y, 当 x 和 y 都是值的时候, 产生true或false. 这样的一个比较执行如下：

If Type(x) is the same as Type(y), then

If Type(x) is undefined, return true. 
If Type(x) is Null, return true. 
If Type(x) is Number, then

If x is NaN, return false. 
If y is NaN, return false. 
If x [...]]]></description>
			<content:encoded><![CDATA[<p>直接摘自ECMA262</p>
<p><strong>章节号：11.9.3 The Abstract Equality Comparison Algorithm</strong>   </p>
<p>比较 x == y, 当 x 和 y 都是值的时候, 产生<span style="color: blue; font-weight: bold">true</span>或<span style="color: blue; font-weight: bold">false</span>. 这样的一个比较执行如下：
<ol>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is the same as <span style="font-style: italic; color: green">Type</span>(y), then
<ol style="list-style-type: lower-alpha">
<li>If <span style="font-style: italic; color: green">Type</span>(x) is <span style="color: red; font-weight: bold">undefined</span>, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Null, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Number, then
<ol style="list-style-type: upper-roman">
<li>If x is <span style="color: red; font-weight: bold">NaN</span>, return <span style="color: blue; font-weight: bold">false</span>. </li>
<li>If y is <span style="color: red; font-weight: bold">NaN</span>, return <span style="color: blue; font-weight: bold">false</span>. </li>
<li>If x is the same Number value as y, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If x is +0 and y is −0, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If x is −0 and y is +0, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>Return <span style="color: blue; font-weight: bold">false</span>. </li>
</ol>
</li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is String, then return <span style="color: blue; font-weight: bold">true</span> if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions). Otherwise, return <span style="color: blue; font-weight: bold">false</span>. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Boolean, return <span style="color: blue; font-weight: bold">true</span> if x and y are both <span style="color: blue; font-weight: bold">true</span> or both <span style="color: blue; font-weight: bold">false</span>. Otherwise, return <span style="color: blue; font-weight: bold">false</span>. </li>
<li>Return <span style="color: blue; font-weight: bold">true</span> if x and y refer to the same object. Otherwise, return <span style="color: blue; font-weight: bold">false</span>. </li>
</ol>
</li>
<li>If x is null and y is <span style="color: red; font-weight: bold">undefined</span>, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If x is <span style="color: red; font-weight: bold">undefined</span> and y is null, return <span style="color: blue; font-weight: bold">true</span>. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Number and <span style="font-style: italic; color: green">Type</span>(y) is String, return the result of the comparison x == <span style="font-style: italic; color: green">ToNumber</span>(y). </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is String and <span style="font-style: italic; color: green">Type</span>(y) is Number,       <br />return the result of the comparison <span style="font-style: italic; color: green">ToNumber</span>(x) == y. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Boolean, return the result of the comparison <span style="font-style: italic; color: green">ToNumber</span>(x) == y. </li>
<li>If <span style="font-style: italic; color: green">Type</span>(y) is Boolean, return the result of the comparison x == <span style="font-style: italic; color: green">ToNumber</span>(y). </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is either String or Number and <span style="font-style: italic; color: green">Type</span>(y) is Object,       <br />return the result of the comparison x == <span style="font-style: italic; color: green">ToPrimitive</span>(y). </li>
<li>If <span style="font-style: italic; color: green">Type</span>(x) is Object and <span style="font-style: italic; color: green">Type</span>(y) is either String or Number,       <br />return the result of the comparison <span style="font-style: italic; color: green">ToPrimitive</span>(x) == y. </li>
<li>Return <span style="color: blue; font-weight: bold">false</span>. </li>
</ol>
<p>NOTE 1 鉴于以上相等的定义：   <br />• 可以这样强制字符串比较： &quot;&quot; + a == &quot;&quot; + b.   <br />• 可以这样强制数字比较： +a == +b.   <br />• 可以这样强制布尔值比较：!a == !b.   <br />NOTE 2 双等比较保持以下的不变式：   <br />•&#160; A != B 等价于 !(A == B).   <br />•&#160; A == B 等价于 B == A, 除了A和B求值的顺序不同   <br />NOTE 3 The equality operator is not always transitive. For example, there might be two distinct String objects, each   <br />representing the same String value; each String object would be considered equal to the String value by the == operator,   <br />but the two String objects would not be equal to each other.   <br />NOTE 4 Comparison of Strings uses a simple equality test on sequences of code unit values. There is no attempt to   <br />use the more complex, semantically oriented definitions of character or string equality and collating order defined in the   <br />Unicode specification. Therefore Strings values that are canonically equal according to the Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalised form.
<p><em>最近这部分待译</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/119/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>自定义事件之双击按键</title>
		<link>http://www.jatx.net/archives/116</link>
		<comments>http://www.jatx.net/archives/116#comments</comments>
		<pubDate>Thu, 15 Apr 2010 14:56:04 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[事件]]></category>

		<guid isPermaLink="false">http://www.jatx.net/archives/116</guid>
		<description><![CDATA[遇到这样的需求，双击按键的事件    还是直接上代码吧：    

//首先准备好常规的事件绑定函数
function addEvent(element, name, callback) {
	//标准浏览器
	if(element.addEventListener) element.addEventListener(name, callback, false);
	//IE
	else element.attachEvent(&#34;on&#34; + name, callback);
}
//双击按键绑定函数
function addDblPressEvent(element, callback) {
	var presstime = 2;//次数为2
	addEvent(element, &#34;keyup&#34;, press);
	//每次单击触发
	function press(e) {
		presstime--;
		setTimeout(reset, 300);
		if(presstime === 0) fire(e);
	}
	//恢复计数器
	function reset() {
		presstime++;
	}
	//触发双击
	function fire(e) {
		callback.call(element, e);
	}
}

//试一下
window.onload = function() {
	addDblPressEvent(document, function(e) {
		console.log(&#34;double clicked&#34;);
	});
}

]]></description>
			<content:encoded><![CDATA[<p>遇到这样的需求，双击按键的事件    <br />还是直接上代码吧：    </p>
<div>
<pre class="source"><span style="color: #008000">//首先准备好常规的事件绑定函数</span>
<span style="color: #0000ff">function</span> addEvent(element, <span style="color: #0000ff">name</span>, callback) {
	<span style="color: #008000">//标准浏览器</span>
	<span style="color: #0000ff">if</span>(element.addEventListener) element.addEventListener(<span style="color: #0000ff">name</span>, callback, <span style="color: #0000ff">false</span>);
	<span style="color: #008000">//IE</span>
	<span style="color: #0000ff">else</span> element.attachEvent(&quot;<span style="color: #8b0000">on</span>&quot; + <span style="color: #0000ff">name</span>, callback);
}
<span style="color: #008000">//双击按键绑定函数</span>
<span style="color: #0000ff">function</span> addDblPressEvent(element, callback) {
	<span style="color: #0000ff">var</span> presstime = 2;<span style="color: #008000">//次数为2</span>
	addEvent(element, &quot;<span style="color: #8b0000">keyup</span>&quot;, press);
	<span style="color: #008000">//每次单击触发</span>
	<span style="color: #0000ff">function</span> press(e) {
		presstime--;
		<span style="color: #0000ff">setTimeout</span>(reset, 300);
		<span style="color: #0000ff">if</span>(presstime === 0) fire(e);
	}
	<span style="color: #008000">//恢复计数器</span>
	<span style="color: #0000ff">function</span> reset() {
		presstime++;
	}
	<span style="color: #008000">//触发双击</span>
	<span style="color: #0000ff">function</span> fire(e) {
		callback.call(element, e);
	}
}

<span style="color: #008000">//试一下</span>
<span style="color: #0000ff">window</span>.onload = <span style="color: #0000ff">function</span>() {
	addDblPressEvent(<span style="color: #0000ff">document</span>, <span style="color: #0000ff">function</span>(e) {
		console.log(&quot;<span style="color: #8b0000">double clicked</span>&quot;);
	});
}</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/116/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>system</title>
		<link>http://www.jatx.net/archives/113</link>
		<comments>http://www.jatx.net/archives/113#comments</comments>
		<pubDate>Mon, 12 Apr 2010 13:49:47 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://www.jatx.net/?p=113</guid>
		<description><![CDATA[我忘了是否从哪里看过，或者是否是经典，仅仅是突然想到的，就是这样
]]></description>
			<content:encoded><![CDATA[<p>我忘了是否从哪里看过，或者是否是经典，仅仅是突然想到的，就是这样的<div id="attachment_114" class="wp-caption alignleft" style="width: 310px"><a href="http://www.jatx.net/wp-content/uploads/2010/04/system.JPG"><img src="http://www.jatx.net/wp-content/uploads/2010/04/system-300x187.jpg" alt="系统" title="system" width="300" height="187" class="size-medium wp-image-114" /></a><p class="wp-caption-text">系统</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/113/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>function.delay</title>
		<link>http://www.jatx.net/archives/109</link>
		<comments>http://www.jatx.net/archives/109#comments</comments>
		<pubDate>Wed, 31 Mar 2010 13:27:00 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[delay]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://www.jatx.net/archives/109</guid>
		<description><![CDATA[扩展一个函数的延时调用
Function.prototype.delay =  function(n, thisObj, args) {
    var me = this;
    args = args instanceof Array ? args : [];
    var f = function() {
        me.apply(thisObj &#124;&#124; window, args);
    };
    window.setTimeout(f, n);
}
//示例
function f() [...]]]></description>
			<content:encoded><![CDATA[<div>扩展一个函数的延时调用
<pre class="source"><span style="color: #0000ff">Function</span>.<span style="color: #0000ff">prototype</span>.delay =  <span style="color: #0000ff">function</span>(n, thisObj, args) {
    <span style="color: #0000ff">var</span> me = <span style="color: #0000ff">this</span>;
    args = args <span style="color: #0000ff">instanceof</span> <span style="color: #0000ff">Array</span> ? args : [];
    <span style="color: #0000ff">var</span> f = <span style="color: #0000ff">function</span>() {
        me.apply(thisObj || <span style="color: #0000ff">window</span>, args);
    };
    <span style="color: #0000ff">window</span>.<span style="color: #0000ff">setTimeout</span>(f, n);
}
<span style="color:#008000">//示例</span>
<span style="color: #0000ff">function</span> f() {
    alert("hi");
}
alert("两秒之后弹出");
f.delay(2000);
</pre>
</div>
<div>注意第三个是参数数组</div>
<div><em>第一次用Live Writer写日志，呵呵<br />
    <br /></em></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/109/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>各浏览器的鼠标键盘事件整理</title>
		<link>http://www.jatx.net/archives/105</link>
		<comments>http://www.jatx.net/archives/105#comments</comments>
		<pubDate>Sun, 28 Mar 2010 14:19:12 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[Browser]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[键盘事件]]></category>
		<category><![CDATA[鼠标事件]]></category>

		<guid isPermaLink="false">http://www.jatx.net/?p=105</guid>
		<description><![CDATA[这是Window XP(sp3)下的测试结果，如下表：


  Key Event
  (windows XP)
  

浏览器
一次触发
连续触发


&#160;
控制键
非控制键
控制键
非控制键


IE8/8.0.6001
keydown
    keyup
keydown
      keypress
    keyup
keydown
keydown
    keypress


FireFox/3.6.2
keydown
    keyup
keydown
      keypress
    keyup
keydown
keydown
    keypress


Chrome/4.1.249.1042
keydown
keyup 
 keydown
      keypress
  [...]]]></description>
			<content:encoded><![CDATA[<p>这是Window XP(sp3)下的测试结果，如下表：</p>
<table border="1" cellpadding="4" cellspacing="0">
<caption>
  Key Event<br />
  (windows XP)<br />
  </caption>
<tr>
<td><strong>浏览器</strong></td>
<td colspan="2"><strong>一次触发</strong></td>
<td colspan="2"><strong>连续触发</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>控制键</td>
<td>非控制键</td>
<td>控制键</td>
<td>非控制键</td>
</tr>
<tr>
<td>IE8/8.0.6001</td>
<td>keydown<br />
    keyup</td>
<td>keydown<br />
      keypress<br />
    keyup</td>
<td>keydown</td>
<td>keydown<br />
    keypress</td>
</tr>
<tr>
<td>FireFox/3.6.2</td>
<td>keydown<br />
    keyup</td>
<td>keydown<br />
      keypress<br />
    keyup</td>
<td>keydown</td>
<td>keydown<br />
    keypress</td>
</tr>
<tr>
<td>Chrome/4.1.249.1042</td>
<td>keydown<br />
keyup </td>
<td> keydown<br />
      keypress<br />
    keyup </td>
<td>keydown</td>
<td>keydown<br />
keypress</td>
</tr>
<tr>
<td>Safari/4.0.3</td>
<td>keydown<br />
keyup </td>
<td>keydown<br />
keypress<br />
keyup </td>
<td>keydown</td>
<td>keydown<br />
keypress</td>
</tr>
<tr>
<td>Opera/10.51</td>
<td>keydown<br />
keyup </td>
<td>keydown<br />
keypress<br />
keyup </td>
<td>-</td>
<td>keypress</td>
</tr>
</table>
<table border="1" cellpadding="4" cellspacing="0">
<caption>
  Mouse Event<br />
  (windows XP)<br />
  </caption>
<tr>
<td><strong>浏览器</strong></td>
<td><strong>单击</strong></td>
<td><strong>双击</strong></td>
</tr>
<tr>
<td>IE8/8.0.6001</td>
<td>mousedown<br />
      mouseup<br />
      click    </td>
<td>mousedown<br />
      mouseup<br />
      click<br />
      mouseup<br />
      dblclick    </td>
</tr>
<tr>
<td>FireFox/3.6.2</td>
<td>mousedown<br />
      mouseup<br />
      click    </td>
<td>mousedown<br />
      mouseup<br />
      click<br />
      mousedown<br />
      mouseup<br />
      click<br />
      dblclick    </td>
</tr>
<tr>
<td>Chrome/4.1.249.1042</td>
<td>mousedown<br />
mouseup<br />
click</td>
<td>mousedown<br />
mouseup<br />
click<br />
mousedown<br />
mouseup<br />
click<br />
dblclick</td>
</tr>
<tr>
<td>Safari/4.0.3</td>
<td>mousedown<br />
mouseup<br />
click</td>
<td>mousedown<br />
mouseup<br />
click<br />
mousedown<br />
mouseup<br />
click<br />
dblclick</td>
</tr>
<tr>
<td>Opera/10.51</td>
<td>mousedown<br />
mouseup<br />
click</td>
<td>mousedown<br />
mouseup<br />
click<br />
mousedown<br />
mouseup<br />
click<br />
dblclick</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/105/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>浏览器中的key event--ubuntu</title>
		<link>http://www.jatx.net/archives/100</link>
		<comments>http://www.jatx.net/archives/100#comments</comments>
		<pubDate>Sun, 21 Mar 2010 10:11:47 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[Browser]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[key event]]></category>
		<category><![CDATA[键盘事件]]></category>

		<guid isPermaLink="false">http://www.jatx.net/?p=100</guid>
		<description><![CDATA[测试了一下ubuntu中的浏览器对于键盘事件的触发情况，结果如下：


    Key Event
  (Ubuntu9.10)
  

浏览器
一次触发
连续触发


&#160;
控制键
非控制键
控制键
非控制键


FireFox/3.6
keydown
      keyup
keydown
      keypress
      keyup
-
keydown
  keypress
  keyup      


Chromium/5.0.318.0
keydown
      keyup
keydown
    keyup
-
keydown
      keyup


Opera/10.10
keydown
  [...]]]></description>
			<content:encoded><![CDATA[<p>测试了一下ubuntu中的浏览器对于键盘事件的触发情况，结果如下：</p>
<table border="1" cellpadding="4" cellspacing="0">
<caption>
    Key Event<br />
  (Ubuntu9.10)<br />
  </caption>
<tr>
<td><strong>浏览器</strong></td>
<td colspan="2"><strong>一次触发</strong></td>
<td colspan="2"><strong>连续触发</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>控制键</td>
<td>非控制键</td>
<td>控制键</td>
<td>非控制键</td>
</tr>
<tr>
<td>FireFox/3.6</td>
<td>keydown<br />
      keyup</td>
<td>keydown<br />
      keypress<br />
      keyup</td>
<td>-</td>
<td>keydown<br />
  keypress<br />
  keyup      </td>
</tr>
<tr>
<td>Chromium/5.0.318.0</td>
<td>keydown<br />
      keyup</td>
<td>keydown<br />
    keyup</td>
<td>-</td>
<td>keydown<br />
      keyup</td>
</tr>
<tr>
<td>Opera/10.10</td>
<td>keydown<br />
      keyup </td>
<td> keydown<br />
      keypress<br />
      keyup </td>
<td>-</td>
<td>keypress</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/100/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>学习canvas</title>
		<link>http://www.jatx.net/archives/95</link>
		<comments>http://www.jatx.net/archives/95#comments</comments>
		<pubDate>Fri, 19 Mar 2010 06:10:57 +0000</pubDate>
		<dc:creator>城晓</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.jatx.net/?p=95</guid>
		<description><![CDATA[&#60;canvas  是HTML5 中新加入的一个标记
功能是创建一个“画板”对象及一组供javascript使用的API
基本标签的写法是这样的
&#60;canvas width="100" height="100" id="canvas"&#62;&#60;/canvas&#62;
创建了这个对象以后我们就可以用js来在上面画东西了
首先取得这个对象的引用
var canvas = document.getElementById("canvas");
然后取得绘制对象
var ctx = canvas.getContext("2d");
现在用ctx画一条直线
先把“画笔”放到起始点（0, 0）
ctx.moveTo(0, 0);
然后画线到（50, 50）
ctx.lineTo(50, 50);
把线画出来
ctx.stroke();
就这么简单， 更多的测试看 canvas测试页
Canvas tutorial
]]></description>
			<content:encoded><![CDATA[<p>&lt;canvas  是HTML5 中新加入的一个标记<br />
功能是创建一个“画板”对象及一组供javascript使用的API<br />
基本标签的写法是这样的</p>
<p>&lt;canvas width="100" height="100" id="canvas"&gt;&lt;/canvas&gt;</p>
<p>创建了这个对象以后我们就可以用js来在上面画东西了</p>
<p>首先取得这个对象的引用</p>
<p><code>var canvas = document.getElementById("canvas");</code><br />
然后取得绘制对象<br />
<code>var ctx = canvas.getContext("2d");</code></p>
<p>现在用ctx画一条直线</p>
<p>先把“画笔”放到起始点（0, 0）</p>
<p><code>ctx.moveTo(0, 0);</code></p>
<p>然后画线到（50, 50）</p>
<p><code>ctx.lineTo(50, 50);</code></p>
<p>把线画出来<br />
<code>ctx.stroke();</code></p>
<p>就这么简单， 更多的测试看 <a href="http://www.jatx.net/pub/test/canvas.html" target="_blank">canvas测试页</a><br />
<a href="https://developer.mozilla.org/en/Canvas_tutorial">Canvas tutorial</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jatx.net/archives/95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
