﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-普若伽门的黑白</title><link>http://www.cnblogs.com/x116/</link><description>十年磨一剑</description><language>zh-cn</language><lastBuildDate>Sat, 20 Mar 2010 08:52:29 GMT</lastBuildDate><pubDate>Sat, 20 Mar 2010 08:52:29 GMT</pubDate><ttl>60</ttl><item><title>身份证号码的规则及验证原理</title><link>http://www.cnblogs.com/x116/articles/1540119.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Thu, 06 Aug 2009 02:28:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1540119.html</guid><description><![CDATA[<p>阅读: 34 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-08-06 10:28 <a href="http://www.cnblogs.com/x116/articles/1540119.html" target="_blank">原文链接</a></p><span  style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; ">
<div><font face="幼圆" size="3">【身份证号码的规则】</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">1、15位身份证号码组成：</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">ddddddyymmddxxs共15位，其中：</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">dddddd为6位的地方代码，根据这6位可以获得该身份证号所在地。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">yy为2位的年份代码，是身份证持有人的出身年份。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">mm为2位的月份代码，是身份证持有人的出身月份。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">dd为2位的日期代码，是身份证持有人的出身日。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">这6位在一起组成了身份证持有人的出生日期。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">xx为2位的顺序码，这个是随机数。</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">s为1位的性别代码，奇数代表男性，偶数代表女性。</font></div>
<div>&nbsp;</div>
<div><font face="幼圆" size="3">2、18位身份证号码组成：</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">ddddddyyyymmddxxsp共18位，其中：</font></div>
<div><font face="幼圆" color="#ff00ff" size="3">其他部分都和15位的相同。年份代码由原来的2位升级到4位。最后一位为校验位。</font></div>
<div><font face="幼圆" color="#0000ff" size="3">校验规则是：</font><font face="幼圆" size="3"><br />
<font color="#0000ff">（1）十七位数字本体码加权求和公式&nbsp;<br />
S = Sum(Ai * Wi), i = 0, ... , 16 ，先对前17位数字的权求和&nbsp;<br />
Ai:表示第i位置上的身份证号码数字值&nbsp;<br />
Wi:表示第i位置上的加权因子&nbsp;<br />
Wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2&nbsp;<br />
</font></font><font face="幼圆" color="#0000ff" size="3">（2）计算模&nbsp;<br />
Y = mod(S, 11)&nbsp;<br />
</font><font face="幼圆" size="3"><font color="#0000ff">（3）通过模得到对应的校验码&nbsp;<br />
Y: 0 1 2 3 4 5 6 7 8 9 10&nbsp;<br />
校验码: 1 0 X 9 8 7 6 5 4 3 2</font><br />
</font></div>
<div>
<p><font face="幼圆" size="3">也就是说，如果得到余数为1则最后的校验位p应该为对应的0.如果校验位不是，则该身份证号码不正确。以下为js版本的校验实例。</font></p>
</div>
<p style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; line-height: 19px; "><code><span style="color: #000000; "><span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">script</span>&nbsp;<span style="color: #ff0000; ">language</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"javascript"</span><span style="color: #0000cc; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">&lt;</span><span style="color: #0000cc; ">!</span><span style="color: #0000cc; ">-</span><span style="color: #0000cc; ">-</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;powers<span style="color: #0000cc; ">=</span><span style="color: #0000ff; ">new</span><span style="color: #ff0000; ">Array</span><span style="color: #0000cc; ">(</span><span style="color: #ff00ff; ">"7"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"9"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"10"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"5"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"8"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"4"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"2"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"1"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"6"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"3"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"7"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"9"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"10"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"5"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"8"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"4"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"2"</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;parityBit<span style="color: #0000cc; ">=</span><span style="color: #0000ff; ">new</span>&nbsp;<span style="color: #ff0000; ">Array</span><span style="color: #0000cc; ">(</span><span style="color: #ff00ff; ">"1"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"0"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"X"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"9"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"8"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"7"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"6"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"5"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"4"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"3"</span><span style="color: #0000cc; ">,</span><span style="color: #ff00ff; ">"2"</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;sex<span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"male"</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验身份证号码的主调用<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">function</span>&nbsp;validId<span style="color: #0000cc; ">(</span>obj<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;_id<span style="color: #0000cc; ">=</span>obj<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">value</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">""</span><span style="color: #0000cc; ">)</span><span style="color: #0000ff; ">return</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;_valid<span style="color: #0000cc; ">=</span><span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">length</span><span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>15<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_valid<span style="color: #0000cc; ">=</span>validId15<span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><span style="color: #0000ff; ">else</span>&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">length</span><span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>18<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_valid<span style="color: #0000cc; ">=</span>validId18<span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span><span style="color: #0000cc; ">!</span>_valid<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">alert</span><span style="color: #0000cc; ">(</span><span style="color: #ff00ff; ">"身份证号码有误,请检查!"</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;obj<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">focus</span><span style="color: #0000cc; ">(</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//设置性别<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;sexSel<span style="color: #0000cc; ">=</span><span style="color: #ff0000; ">document</span><span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">getElementById</span><span style="color: #0000cc; ">(</span><span style="color: #ff00ff; ">"sex"</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;<span style="color: #ff0000; ">options</span><span style="color: #0000cc; ">=</span>sexSel<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">options</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">for</span><span style="color: #0000cc; ">(</span><span style="color: #0000ff; ">var</span>&nbsp;i<span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">options</span><span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">length</span><span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span><span style="color: #ff0000; ">options</span><span style="color: #0000cc; ">[</span>i<span style="color: #0000cc; ">]</span><span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">value</span><span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>sex<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">options</span><span style="color: #0000cc; ">[</span>i<span style="color: #0000cc; ">]</span><span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">selected</span><span style="color: #0000cc; ">=</span><span style="color: #0000ff; ">true</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">break</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span>&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验18位的身份证号码<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">function</span>&nbsp;validId18<span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_id<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">+</span><span style="color: #ff00ff; ">""</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;_num<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>0<span style="color: #0000cc; ">,</span>17<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;_parityBit<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>17<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;_power<span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">for</span><span style="color: #0000cc; ">(</span><span style="color: #0000ff; ">var</span>&nbsp;i<span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">&lt;</span>&nbsp;17<span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验每一位的合法性<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>_num<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">&lt;</span><span style="color: #ff00ff; ">'0'</span><span style="color: #0000cc; ">|</span><span style="color: #0000cc; ">|</span>_num<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">&gt;</span><span style="color: #ff00ff; ">'9'</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">break</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><span style="color: #0000ff; ">else</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//加权<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_power<span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">=</span><span style="color: #ff0000; ">parseInt</span><span style="color: #0000cc; ">(</span>_num<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">*</span><span style="color: #ff0000; ">parseInt</span><span style="color: #0000cc; ">(</span>powers<span style="color: #0000cc; ">[</span>i<span style="color: #0000cc; ">]</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//设置性别<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>16<span style="color: #0000cc; ">&amp;</span><span style="color: #0000cc; ">&amp;</span><span style="color: #ff0000; ">parseInt</span><span style="color: #0000cc; ">(</span>_num<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">%</span>2<span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sex<span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"female"</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><span style="color: #0000ff; ">else</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sex<span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"male"</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//取模<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;mod<span style="color: #0000cc; ">=</span><span style="color: #ff0000; ">parseInt</span><span style="color: #0000cc; ">(</span>_power<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">%</span>11<span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>parityBit<span style="color: #0000cc; ">[</span>mod<span style="color: #0000cc; ">]</span><span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>_parityBit<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">true</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验15位的身份证号码<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">function</span>&nbsp;validId15<span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_id<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">+</span><span style="color: #ff00ff; ">""</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">for</span><span style="color: #0000cc; ">(</span><span style="color: #0000ff; ">var</span>&nbsp;i<span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">&lt;</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">length</span><span style="color: #0000cc; ">;</span>i<span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">+</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验每一位的合法性<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">&lt;</span><span style="color: #ff00ff; ">'0'</span><span style="color: #0000cc; ">|</span><span style="color: #0000cc; ">|</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">charAt</span><span style="color: #0000cc; ">(</span>i<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">&gt;</span><span style="color: #ff00ff; ">'9'</span><span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">break</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;year<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>6<span style="color: #0000cc; ">,</span>2<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;month<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>8<span style="color: #0000cc; ">,</span>2<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;day<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>10<span style="color: #0000cc; ">,</span>2<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">var</span>&nbsp;sexBit<span style="color: #0000cc; ">=</span>_id<span style="color: #0000cc; ">.</span><span style="color: #ff0000; ">substr</span><span style="color: #0000cc; ">(</span>14<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验年份位<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>year<span style="color: #0000cc; ">&lt;</span><span style="color: #ff00ff; ">'01'</span><span style="color: #0000cc; ">|</span><span style="color: #0000cc; ">|</span>year&nbsp;<span style="color: #0000cc; ">&gt;</span><span style="color: #ff00ff; ">'90'</span><span style="color: #0000cc; ">)</span><span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验月份<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>month<span style="color: #0000cc; ">&lt;</span><span style="color: #ff00ff; ">'01'</span><span style="color: #0000cc; ">|</span><span style="color: #0000cc; ">|</span>month&nbsp;<span style="color: #0000cc; ">&gt;</span><span style="color: #ff00ff; ">'12'</span><span style="color: #0000cc; ">)</span><span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//校验日<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>day<span style="color: #0000cc; ">&lt;</span><span style="color: #ff00ff; ">'01'</span><span style="color: #0000cc; ">|</span><span style="color: #0000cc; ">|</span>day&nbsp;<span style="color: #0000cc; ">&gt;</span><span style="color: #ff00ff; ">'31'</span><span style="color: #0000cc; ">)</span><span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">false</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//设置性别<br />
</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">if</span><span style="color: #0000cc; ">(</span>sexBit<span style="color: #0000cc; ">%</span>2<span style="color: #0000cc; ">=</span><span style="color: #0000cc; ">=</span>0<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sex<span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"female"</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><span style="color: #0000ff; ">else</span><span style="color: #0000cc; ">{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sex<span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"male"</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000ff; ">return</span>&nbsp;<span style="color: #0000ff; ">true</span><span style="color: #0000cc; ">;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">}</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff9900; ">//--&gt;<br />
</span><br />
<span style="color: #0000cc; ">&lt;</span><span style="color: #0000cc; ">/</span><span style="color: #ff0000; ">script</span><span style="color: #0000cc; ">&gt;</span><br />
<span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">input</span>&nbsp;<span style="color: #ff0000; ">type</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"text"</span>&nbsp;<span style="color: #ff0000; ">onblur</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"validId(this)"</span>&nbsp;<span style="color: #ff0000; ">maxlength</span><span style="color: #0000cc; ">=</span>18&nbsp;<span style="color: #ff0000; ">size</span><span style="color: #0000cc; ">=</span>18<span style="color: #0000cc; ">&gt;</span><br />
<span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">select</span>&nbsp;<span style="color: #ff0000; ">id</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"sex"</span><span style="color: #0000cc; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">option</span>&nbsp;<span style="color: #ff0000; ">value</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"male"</span><span style="color: #0000cc; ">&gt;</span>男<span style="color: #0000cc; ">&lt;</span><span style="color: #0000cc; ">/</span><span style="color: #ff0000; ">option</span><span style="color: #0000cc; ">&gt;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc; ">&lt;</span><span style="color: #ff0000; ">option</span>&nbsp;<span style="color: #ff0000; ">value</span><span style="color: #0000cc; ">=</span><span style="color: #ff00ff; ">"female"</span><span style="color: #0000cc; ">&gt;</span>女<span style="color: #0000cc; ">&lt;</span><span style="color: #0000cc; ">/</span><span style="color: #ff0000; ">option</span><span style="color: #0000cc; ">&gt;</span></span></code></p>
</span><img src="http://www.cnblogs.com/x116/aggbug/1540119.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1540119.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1540119.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>[摘抄]领悟 JavaScript 中的面向对象</title><link>http://www.cnblogs.com/x116/articles/1459205.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Mon, 18 May 2009 03:00:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1459205.html</guid><description><![CDATA[<p>阅读: 11 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-05-18 11:00 <a href="http://www.cnblogs.com/x116/articles/1459205.html" target="_blank">原文链接</a></p><span style="font-family: Tahoma; font-size: 12px; line-height: 18px; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">【搜自网络，还给网络】</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br />
JavaScript 是面向对象的。但是不少人对这一点理解得并不全面。<br />
<br />
在 JavaScript 中，对象分为两种。一种可以称为&#8220;普通对象&#8221;，就是我们所普遍理解的那些：数字、日期、用户自定义的对象（如：{}）等等。<br />
<br />
还有一种，称为&#8220;方法对象&#8221;，就是我们通常定义的 function。你可能觉得奇怪：方法就是方法，怎么成了对象了？但是在 JavaScript 中，方法的确是被当成对象来处理的。下面是一个简单的例子：<br />
</p>
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=function%20func()%20%7Balert('Hello!')%3B%7D%0Aalert(func.toString())%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">&#160;func()&#160;{alert(</span><span class="string" style="color: blue; ">'Hello!'</span><span style="color: black; ">);}&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">alert(func.toString());&#160;&#160;</span></li>
</ol>
</div>
<br />
在这个例子中，func 虽然是作为一个方法定义的，但它自身却包含一个 toString 方法，说明 func 在这里是被当成一个对象来处理的。更准确的说，func 是一个&#8220;方法对象&#8221;。下面是例子的继续：<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=func.name%20%3D%20%E2%80%9CI%20am%20func.%E2%80%9D%3B%0Aalert(func.name)%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span style="color: black; ">func.name&#160;=&#160;&#8220;I&#160;am&#160;func.&#8221;;&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">alert(func.name);&#160;&#160;</span></li>
</ol>
</div>
<br />
我们可以任意的为 func 设置属性，这更加证明了 func 就是一个对象。那么方法对象和普通对象的区别在哪里呢？首先方法对象当然是可以执行的，在它后面加上一对括号，就是执行这个方法对象了。<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=func()%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span style="color: black; ">func();&#160;&#160;</span></span></li>
</ol>
</div>
<br />
所以，方法对象具有二重性。一方面它可以被执行，另一方面它完全可以被当成一个普通对象来使用。这意味着什么呢？这意味着方法对象是可以完全独立于其他对象存在的。这一点我们可以同 Java 比较一下。在 Java 中，方法必须在某一个类中定义，而不能单独存在。而 JavaScript 中就不需要。<br />
<br />
方法对象独立于其他方法，就意味着它能够被任意的引用和传递。下面是一个例子：<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=function%20invoke(f)%20%7B%0A%20%20%20%20f()%3B%0A%7D%0Ainvoke(func)%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">&#160;invoke(f)&#160;{&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">&#160;&#160;&#160;&#160;f();&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">}&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">invoke(func);&#160;&#160;</span></li>
</ol>
</div>
<br />
将一个方法对象 func 传递给另一个方法对象 invoke，让后者在适当的时候执行 func。这就是所谓的&#8220;回调&#8221;了。另外，方法对象的这种特殊性，也使得 this 关键字不容易把握。这方面相关文章不少，这里不赘述了。<br />
<br />
除了可以被执行以外，方法对象还有一个特殊的功用，就是它可以通过 new 关键字来创建普通对象。<br />
<br />
话说每一个方法对象被创建时，都会自动的拥有一个叫 prototype 的属性。这个属性并无什么特别之处，它和其他的属性一样可以访问，可以赋值。不过当我们用 new 关键字来创建一个对象的时候，prototype 就起作用了：它的值（也是一个对象）所包含的所有属性，都会被复制到新创建的那个对象上去。下面是一个例子：<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=func.prototype.name%3D%E2%80%9Dprototype%20of%20func%E2%80%9D%3B%0Avar%20f%20%3D%20new%20func()%3B%0Aalert(f.name)%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span style="color: black; ">func.prototype.name=&#8221;prototype&#160;of&#160;func&#8221;;&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">var</span><span style="color: black; ">&#160;f&#160;=&#160;</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;func();&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">alert(f.name);&#160;&#160;</span></li>
</ol>
</div>
<br />
执行的过程中会弹出两个对话框，后一个对话框表示 f 这个新建的对象从 func.prototype 那里拷贝了 name 属性。而前一个对话框则表示 func 被作为方法执行了一遍。你可能会问了，为什么这个时候要还把 func 执行一遍呢？其实这个时候执行 func，就是起&#8220;构造函数&#8221;的作用。为了形象的说明，我们重新来一遍：<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=function%20func()%20%7B%0A%20%20%20%20this.name%3D%E2%80%9Dname%20has%20been%20changed.%E2%80%9D%0A%7D%0Afunc.prototype.name%3D%E2%80%9Dprototype%20of%20func%E2%80%9D%3B%0Avar%20f%20%3D%20new%20func()%3B%0Aalert(f.name)%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">&#160;func()&#160;{&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">&#160;&#160;&#160;&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">this</span><span style="color: black; ">.name=&#8221;name&#160;has&#160;been&#160;changed.&#8221;&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">}&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">func.prototype.name=&#8221;prototype&#160;of&#160;func&#8221;;&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">var</span><span style="color: black; ">&#160;f&#160;=&#160;</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;func();&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">alert(f.name);&#160;&#160;</span></li>
</ol>
</div>
<br />
你就会发现 f 的 name 属性不再是"prototype of func"，而是被替换成了"name has been changed"。这就是 func 这个对象方法所起到的&#8220;构造函数&#8221;的作用。所以，在 JavaScript 中，用 new 关键字创建对象是执行了下面三个步骤的：<br />
<ol style="font-size: 1em; line-height: 1.4em; margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
    <li style="font-size: 1em; margin-top: 0px; margin-right: 0px; margin-bottom: 0.25em; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">创建一个新的普通对象；</li>
    <li style="font-size: 1em; margin-top: 0px; margin-right: 0px; margin-bottom: 0.25em; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">将方法对象的 prototype 属性的所有属性复制到新的普通对象中去。</li>
    <li style="font-size: 1em; margin-top: 0px; margin-right: 0px; margin-bottom: 0.25em; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">以新的普通对象作为上下文来执行方法对象。</li>
</ol>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">对于&#8220;new func()&#8221;这样的语句，可以描述为&#8220;从 func 创建一个新对象&#8221;。总之，prototype 这个属性的唯一特殊之处，就是在创建新对象的时候了。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br />
那么我们就可以利用这一点。比如有两个方法对象 A 和 B，既然从 A 创建的新对象包含了所有 A.prototype 的属性，那么我将它赋给 B.prototype，那么从 B 创建的新对象不也有同样的属性了？写成代码就是这样：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&#160;</p>
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=A.prototype.hello%20%3D%20function()%7Balert('Hello!')%3B%7D%0AB.prototype%20%3D%20new%20A()%3B%0Anew%20B().hello()%3B" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; background-color: #ffffff; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span style="color: black; ">A.prototype.hello&#160;=&#160;</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">(){alert(</span><span class="string" style="color: blue; ">'Hello!'</span><span style="color: black; ">);}&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">B.prototype&#160;=&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;A();&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;B().hello();&#160;&#160;</span></span></li>
</ol>
</div>
<br />
这就是 JavaScript 的所谓&#8220;继承&#8221;了，其实质就是属性的拷贝，这里利用了 prototype 来实现。如果不用 prototype，那就用循环了，效果是一样的。所谓&#8220;多重继承&#8221;，自然就是到处拷贝了。<br />
<br />
JavaScript 中面向对象的原理，就是上面这些了。自始至终我都没提到&#8220;类&#8221;的概念，因为 JavaScript 本来就没有&#8220;类&#8221;这个东西。面向对象可以没有类吗？当然可以。先有类，然后再有对象，这本来就不合理，因为类本来是从对象中归纳出来的，先有对象再有类，这才合理。像下面这样的：<br />
<br />
<div class="dp-highlighter" style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 12px; background-color: transparent; width: 97%; overflow-x: auto; overflow-y: auto; margin-left: 9px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; ">
<div class="bar">
<div class="tools" style="padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: black; font-weight: bold; "><span class="hilite1" style="background-color: #ffff00; ">Js</span>代码&#160;<embed src="http://www.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=var%20o%20%3D%20%7B%7D%3B%20%2F%2F%20%E6%88%91%E5%8F%91%E7%8E%B0%E4%BA%86%E4%B8%80%E4%B8%AA%E4%B8%9C%E8%A5%BF%E3%80%82%0Ao.eat%20%3D%20function()%7Breturn%20%22I%20am%20eating.%22%7D%20%20%2F%2F%20%E6%88%91%E5%8F%91%E7%8E%B0%E5%AE%83%E4%BC%9A%E5%90%83%EF%BC%9B%0Ao.sleep%20%3D%20function()%7Breturn%20%22ZZZzzz...%22%7D%20%20%2F%2F%20%E6%88%91%E5%8F%91%E7%8E%B0%E5%AE%83%E4%BC%9A%E7%9D%A1%EF%BC%9B%0Ao.talk%20%3D%20function()%7Breturn%20%22Hi!%22%7D%20%2F%2F%20%E6%88%91%E5%8F%91%E7%8E%B0%E5%AE%83%E4%BC%9A%E8%AF%B4%E8%AF%9D%EF%BC%9B%0Ao.think%20%3D%20function()%7Breturn%20%22Hmmm...%22%7D%20%2F%2F%20%E6%88%91%E5%8F%91%E7%8E%B0%E5%AE%83%E8%BF%98%E4%BC%9A%E6%80%9D%E8%80%83%E3%80%82%0A%0Avar%20Human%20%3D%20new%20Function()%3B%20%2F%2F%20%E6%88%91%E5%86%B3%E5%AE%9A%E7%BB%99%E5%AE%83%E8%B5%B7%E5%90%8D%E5%8F%AB%E2%80%9C%E4%BA%BA%E2%80%9D%E3%80%82%0AHuman.prototype%20%3D%20o%3B%20%2F%2F%20%E8%BF%99%E4%B8%AA%E4%B8%9C%E8%A5%BF%E5%B0%B1%E4%BB%A3%E8%A1%A8%E4%BA%86%E6%89%80%E6%9C%89%E2%80%9C%E4%BA%BA%E2%80%9D%E7%9A%84%E6%A6%82%E5%BF%B5%E3%80%82%0A%0Avar%20h%20%3D%20new%20Human()%3B%20%2F%2F%20%E5%BD%93%E6%88%91%E5%8F%91%E7%8E%B0%E5%85%B6%E4%BB%96%E5%90%8C%E5%AE%83%E4%B8%80%E6%A0%B7%E7%9A%84%E4%B8%9C%E8%A5%BF%EF%BC%8C%0Aalert(h.talk())%20%2F%2F%20%E6%88%91%E5%B0%B1%E7%9F%A5%E9%81%93%E5%AE%83%E4%B9%9F%E6%98%AF%E2%80%9C%E4%BA%BA%E2%80%9D%E4%BA%86%EF%BC%81" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></div>
</div>
<ol start="1" class="dp-c" style="font-size: 1em; line-height: 1.4em; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #d1d7dc; border-right-color: #d1d7dc; border-bottom-color: #d1d7dc; border-left-color: #d1d7dc; list-style-type: decimal; list-style-position: initial; list-style-image: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1px; margin-left: 0px; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; color: #2b91af; background-color: #ffffff; ">
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">var</span><span style="color: black; ">&#160;o&#160;=&#160;{};&#160;</span><span class="comment" style="color: #008200; ">//&#160;我发现了一个东西。</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">o.eat&#160;=&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">(){</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">return</span><span style="color: black; ">&#160;</span><span class="string" style="color: blue; ">"I&#160;am&#160;eating."</span><span style="color: black; ">}&#160;&#160;</span><span class="comment" style="color: #008200; ">//&#160;我发现它会吃；</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">o.sleep&#160;=&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">(){</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">return</span><span style="color: black; ">&#160;</span><span class="string" style="color: blue; ">"ZZZzzz..."</span><span style="color: black; ">}&#160;&#160;</span><span class="comment" style="color: #008200; ">//&#160;我发现它会睡；</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">o.talk&#160;=&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">(){</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">return</span><span style="color: black; ">&#160;</span><span class="string" style="color: blue; ">"Hi!"</span><span style="color: black; ">}&#160;</span><span class="comment" style="color: #008200; ">//&#160;我发现它会说话；</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">o.think&#160;=&#160;<span class="keyword" style="color: #7f0055; font-weight: bold; ">function</span><span style="color: black; ">(){</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">return</span><span style="color: black; ">&#160;</span><span class="string" style="color: blue; ">"Hmmm..."</span><span style="color: black; ">}&#160;</span><span class="comment" style="color: #008200; ">//&#160;我发现它还会思考。</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">var</span><span style="color: black; ">&#160;Human&#160;=&#160;</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;Function();&#160;</span><span class="comment" style="color: #008200; ">//&#160;我决定给它起名叫&#8220;人&#8221;。</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">Human.prototype&#160;=&#160;o;&#160;<span class="comment" style="color: #008200; ">//&#160;这个东西就代表了所有&#8220;人&#8221;的概念。</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; ">&#160;&#160;</span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; "><span style="color: black; "><span class="keyword" style="color: #7f0055; font-weight: bold; ">var</span><span style="color: black; ">&#160;h&#160;=&#160;</span><span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&#160;Human();&#160;</span><span class="comment" style="color: #008200; ">//&#160;当我发现其他同它一样的东西，</span><span style="color: black; ">&#160;&#160;</span></span></li>
    <li style="font-size: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; border-left-width: 1px; border-left-style: solid; border-left-color: #d1d7dc; background-color: #fafafa; padding-left: 10px; line-height: 18px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 38px; ">
    <p>alert(h.talk())&#160;<span class="comment">//&#160;我就知道它也是&#8220;人&#8221;了！</span>&#160;&#160;</p>
    </li>
</ol>
</div>
</span>
<p><br />
</p><img src="http://www.cnblogs.com/x116/aggbug/1459205.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1459205.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1459205.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>Jquery 对 radio取值，checkbox取值，select取值，radio选中，checkbox选中，select选中等的精简操作</title><link>http://www.cnblogs.com/x116/articles/1454217.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Mon, 11 May 2009 07:56:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1454217.html</guid><description><![CDATA[<p>阅读: 39 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-05-11 15:56 <a href="http://www.cnblogs.com/x116/articles/1454217.html" target="_blank">原文链接</a></p><p>&nbsp;A 取值：</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. 文本框 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var value=$("#textbox_id").val();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 单选框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var value= $("input[name='sex'][checked]").val();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3. 下拉选择框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var value = $("#select_id").val();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.&nbsp;&nbsp;多选框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var value=&nbsp;&nbsp;$("#checkbox_id").attr("value");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一组多选</p>
<blockquote dir="ltr" style="margin-right: 0px">
<p>&nbsp;&nbsp;&nbsp;var str="";<br />&nbsp;&nbsp;&nbsp;$("input[name='checkboxName'][checked]").each(<br />&nbsp;&nbsp;&nbsp;&nbsp;function(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str+=this.value+","; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//或者<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//str+=$(this).val()+"," <br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;);</p></blockquote>
<p>&nbsp;B 选中或者设置值:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. 文本框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $("#textbox_id").val( value );</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2. 单选框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(" input[name= 'sex' ][value= '"+value+"' ]").attr("checked", "checked");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(" input[name= 'sex' ]").get(index).checked=true;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. 下拉选择框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$("#select_id").val(value);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$("#sel").empty(); 清除下拉列表值</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4. 多选框</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$("#checkbox_id").attr("checked",true);</p><img src="http://www.cnblogs.com/x116/aggbug/1454217.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1454217.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1454217.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>为非回调页面保存状态</title><link>http://www.cnblogs.com/x116/articles/1384416.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Thu, 05 Feb 2009 03:27:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1384416.html</guid><description><![CDATA[<p>阅读: 49 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-02-05 11:27 <a href="http://www.cnblogs.com/x116/articles/1384416.html" target="_blank">原文链接</a></p><p>&#160;&#160; &#160;[本文为摘抄，原作者：<span  style="font-family: simsun; font-size: 12px; line-height: normal; ">风谷</span>]</p>
<p>&#160;&#160; &#160;做ASP.NET开发的人都知道，控件使用ViewState保存自身的状态，并通过回调时的表单值来控制自身的行为，例如显示数据、触发事件等。在默认情况下，ViewState是通过发送到浏览器页面中的一个隐藏域（HiddenField）来进行值的传递，因此，只有在页面回调的时候才能取到ViewState中的相应值。当然，这也是ASP.NET的基本处理方式。</p>
<span  style="font-family: Simsun; font-size: 12px; line-height: normal; "><br />
　　但在某些应用上，这种处理方式可能会无法满足我们的需求。举例来说，一个典型查询页，上面会提供一些查询条件让用户选择，用户在输入查询条件之后找到自己想要的结果，然后点击相应的结果进入另一个页面（姑且称之为内容页吧），在这个页面中完成自己操作后，返回到查询页。一般情况下，我们所提供的返回功能往往是只一个到查询页的链接，那么进入重新进入这个页面时，之前所输入的查询条件都将会丢失，自然查询结果也就不会存在了。这时，如果用户需要先前的查询条件和结果，甚至是页码，就必须重复先前的查询操作去获取结果。<br />
<br />
　　上述这种情况对于一些简单的查询来说并不是很大的问题，但对于一些数据量大、查询条件复杂的情况会非常麻烦，用户不得不多次重复做一些相同的事，给使用带来了级大的不便。要如何优化这种情况呢？一些人可能会说，返回功能不要用链接，而是用脚本在客户端调用history.back()让浏览器后退一步就可以了。不错，这是一种解决办法，但是，如果在内容页里进行了一些回调，这种简单的&#8220;后退&#8221;仍旧是不合适的。那么，要怎么样做才能满足要求呢？<br />
<br />
　　先来分析一下问题，控件的状态是通过ViewState保存的，因此要还原先前用户输入的内容了，就必须在页面处理请求时加载ViewState，另外，为了完整地还原页面的状态，除了ViewState以外，还需要保存从客户端POST过来的所有表单内容。但如本文开头所说，ViewState是保存中浏览器的隐藏域里，如果不是回调就没办法取到，另外，ASP.NET也不会在非回调的情况下加载ViewState。很明显，如果要在非回调的情况下还原控件状态，有两个问题需要解决，一是要在非回调的情况下获取最后一次请求页面时ViewState和表单的内容，二是要让Page认为当前请求为回调，即Page.IsPostBack属性值为true，因为只有这样才能完整地模拟PostBack操作。<br />
<br />
　　要解决第一个问题并不复杂，我们可以把ViewState和表单的内容保存在服务端内存中，可以重载Page.SavePageStateToPersistenceMedium方法将值存入服务端内存。但重载该方法并不能直接获取表单内容，但可以通过Page.DeterminePostBackMode方法取得。这样，只要把两个变量以合适的方法放入内存就可以了。我选择的办法是用一个Pair对象保存视图和表单内容，再将它们放入Session中。当然，除了Session，还可以用HttpRuntime.Cache等。如果要加载保存在服务端内存中的内容，可以重载Page.LoadPageStateToPersistenceMedium方法。<br />
<br />
　　第二个问题就是要让Page认为当前是回调模式，即IsPostBack返回的值应为true。通过对System.Web源代码的分析，我发现当Page.DeterminePostBackMode方法返回的值不是空值时，就可以达到我们的目的，而这个方法又是可以重载的，这样问题就变得简单了。重载DeterminePostBackMode方法，若基类方法返回的值是空值，就从先前在Session中保存的状态取得上一次保存的表单值。其实关于DeterminePostBackMode方法，MSDN中的解释并不多，我也是从字面上猜测，结果对源码的分析得来的，是否合理还有待验证。<br />
<br />
　　OK，两个主要问题都解决了，接下来就可以用代码来实现。<br />
<br />
Pair _state;&#160;<br />
<br />
/// ＜summary＞&#160;<br />
/// 已重载。如果可能，从服务端内存中还原视图内容。&#160;<br />
/// ＜/summary＞&#160;<br />
/// ＜returns＞＜/returns＞&#160;<br />
protected override object LoadPageStateFromPersistenceMedium()&#160;<br />
{&#160;<br />
object state;&#160;<br />
<br />
if (_state != null)&#160;<br />
state = _state.First;&#160;<br />
else&#160;<br />
state = base.LoadPageStateFromPersistenceMedium();&#160;<br />
<br />
return state;&#160;<br />
}&#160;<br />
<br />
/// ＜summary＞&#160;<br />
/// 已重载。将当前视图内容和请求参数集合保存至服务器内存。&#160;<br />
/// ＜/summary＞&#160;<br />
/// ＜param name="state"＞＜/param＞&#160;<br />
protected override void SavePageStateToPersistenceMedium(object state)&#160;<br />
{&#160;<br />
base.SavePageStateToPersistenceMedium(state);&#160;<br />
<br />
var ps = _state;&#160;<br />
<br />
if (ps == null)&#160;<br />
{&#160;<br />
ps = new Pair(state, base.DeterminePostBackMode());&#160;<br />
Session["page_state"] = ps;&#160;<br />
}&#160;<br />
else&#160;<br />
ps.First = state;&#160;<br />
<br />
}&#160;<br />
<br />
/// ＜summary＞&#160;<br />
/// 已重载。当基类方法返回空值时，尝试从服务端内存中获取先前保存的请求参数集合。&#160;<br />
/// ＜/summary＞&#160;<br />
/// ＜returns＞＜/returns＞&#160;<br />
protected override System.Collections.Specialized.NameValueCollection DeterminePostBackMode()&#160;<br />
{&#160;<br />
var coll = base.DeterminePostBackMode();&#160;<br />
<br />
if (coll == null)&#160;<br />
{&#160;<br />
_state = Session["page_state"] as Pair;&#160;<br />
if (_state != null)&#160;<br />
coll = _state.Second as System.Collections.Specialized.NameValueCollection;&#160;<br />
}&#160;<br />
<br />
return coll;&#160;<br />
}&#160;<br />
<br />
　　以上代码的实现方法仅提供一种思路，并不是最终解决办法，因为还有许多细节的问题要考虑，并且也没有进行过广泛的应用，因此对可能造成的问题基本上是不可知的。欢迎有兴趣的人一起讨论。</span><img src="http://www.cnblogs.com/x116/aggbug/1384416.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1384416.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1384416.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>WEB应用程序的快捷键简单设计</title><link>http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Tue, 03 Feb 2009 03:28:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html</guid><description><![CDATA[<p>阅读: 56 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-02-03 11:28 <a href="http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html" target="_blank">原文链接</a></p><p>&#160;&#160;&#160;&#160;&#160;在WEB APP 里，经常考虑到某种功能使用快捷键，可是组合快捷键和F1-F12等功能键又不能直接定义使用，怎么办呢？</p>
<p>&#160;&#160; &#160; 有一些简单办法可以做到使用快捷键而不必要大费周章，</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;1。 需要使用 F2-F12等建立功能热键。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;2。需要使用 Ctrl+A ,Ctrl+B 等<br />
</p>
<p>
</p>
<div class="cnblogs_code"><img id="Code_Closed_Image_113029" onclick="this.style.display='none'; document.getElementById('Code_Closed_Text_113029').style.display='none'; document.getElementById('Code_Open_Image_113029').style.display='inline'; document.getElementById('Code_Open_Text_113029').style.display='inline';" height="16" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" width="11" align="top"><img id="Code_Open_Image_113029" style="display: none" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_113029').style.display='none'; getElementById('Code_Closed_Image_113029').style.display='inline'; getElementById('Code_Closed_Text_113029').style.display='inline';" height="16" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" align="top"><span id="Code_Closed_Text_113029" class="cnblogs_code_Collapse">Code</span><span id="Code_Open_Text_113029" style="display: none"><br />
<!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008080;">&#160;1</span>&#160;<span style="color: #0000FF;">&lt;!</span><span style="color: #FF00FF;">DOCTYPE&#160;HTML&#160;PUBLIC&#160;"-//W3C//DTD&#160;HTML&#160;4.0&#160;Transitional//EN"</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;2</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">HTML</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;3</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">HEAD</span><span style="color: #0000FF;">></span><span style="color: #000000;">&#160;&#160;<br />
</span><span style="color: #008080;">&#160;4</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">TITLE</span><span style="color: #0000FF;">></span><span style="color: #000000;">&#160;快捷键演示页面&#160;</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">TITLE</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;5</span>&#160;<span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">HEAD</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;6</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">BODY</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;7</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;">请按F2,F3,A,CTRL+B键测试</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;8</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;">F2---按键提示！</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">&#160;9</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;">F3---跳到百度！</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">10</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;">A---跳到谷歌！</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">11</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;">CTRL+B---跳到新浪！</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">p</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br />
</span><span style="color: #008080;">12</span>&#160;<span style="color: #0000FF;">&lt;</span><span style="color: #800000;">script</span><span style="color: #0000FF;">></span><span style="background-color: #F5F5F5; color: #000000;">&lt;!--</span><span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">13</span>&#160;<span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">&#160;activeHotKey()&#160;{<br />
</span><span style="color: #008080;">14</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;document.body.onkeydown&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;loadHotKey;<br />
</span><span style="color: #008080;">15</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">16</span>&#160;<span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">&#160;loadHotKey()&#160;{<br />
</span><span style="color: #008080;">17</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">初始化自定义对象hotKey</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">18</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">var</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotK&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">new</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotKey();<br />
</span><span style="color: #008080;">19</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">设置&#160;按F2&#160;F3的事件(参数自定义)</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">20</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">var</span><span style="background-color: #F5F5F5; color: #000000;">&#160;success&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotK.pF2(pressKey,</span><span style="background-color: #F5F5F5; color: #000000;">'</span><span style="background-color: #F5F5F5; color: #000000;">F2</span><span style="background-color: #F5F5F5; color: #000000;">'</span><span style="background-color: #F5F5F5; color: #000000;">)&#160;</span><span style="background-color: #F5F5F5; color: #000000;">&amp;&amp;</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotK.pF3();&#160;<br />
</span><span style="color: #008080;">21</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">设置&#160;按A&#160;Ctrl+B&#160;的事件(参数自定义)&#160;并返回事件激发点</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">22</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;success&#160;</span><span style="background-color: #F5F5F5; color: #000000;">&amp;&amp;</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotK.pA()&#160;</span><span style="background-color: #F5F5F5; color: #000000;">&amp;&amp;</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotK.pCtrlB();<br />
</span><span style="color: #008080;">23</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">24</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">25</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">26</span>&#160;<span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">定义按键事件&#160;</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">27</span>&#160;<span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">&#160;pressKey(){<br />
</span><span style="color: #008080;">28</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;alert(arguments[</span><span style="background-color: #F5F5F5; color: #000000;">0</span><span style="background-color: #F5F5F5; color: #000000;">]);<br />
</span><span style="color: #008080;">29</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">30</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">31</span>&#160;<span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">&#160;hotKey()&#160;{<br />
</span><span style="color: #008080;">32</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">f2&#160;f3</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">33</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.F2&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">113</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">34</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.F3&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">114</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">35</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">36</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">ctrl&#160;alt&#160;shift</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">37</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.CTRL&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;event.ctrlKey;<br />
</span><span style="color: #008080;">38</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.ALT&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;event.altKey;&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">39</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.SHIFT&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;event.shiftKey;<br />
</span><span style="color: #008080;">40</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">41</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">letter</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">42</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.A&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">65</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">43</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.B&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">66</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">44</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">45</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">46</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">hotKey.prototype&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;{<br />
</span><span style="color: #008080;">47</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;pF2:&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">(func,&#160;args)&#160;{<br />
</span><span style="color: #008080;">48</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">==</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.F2)&#160;{<br />
</span><span style="color: #008080;">49</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;func(args);<br />
</span><span style="color: #008080;">50</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">505</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">51</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">false</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">52</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080;">53</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">true</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">54</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;},<br />
</span><span style="color: #008080;">55</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;pF3:&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">()&#160;{</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">跳转URL</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">56</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">==</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.F3)&#160;{<br />
</span><span style="color: #008080;">57</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">505</span><span style="background-color: #F5F5F5; color: #000000;">;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">reset&#160;keyCode</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">58</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;window.location.href&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">http://www.baidu.com</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">59</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">false</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">60</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080;">61</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">true</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">62</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;},<br />
</span><span style="color: #008080;">63</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;pA:&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">()&#160;{</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">跳转URL</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">64</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">==</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.A)&#160;{<br />
</span><span style="color: #008080;">65</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">505</span><span style="background-color: #F5F5F5; color: #000000;">;&#160;</span><span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">reset&#160;keyCode</span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">66</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;window.location.href&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">http://www.g.cn</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">67</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">false</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">68</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080;">69</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">true</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">70</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;},&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">71</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;pCtrlB:&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">function</span><span style="background-color: #F5F5F5; color: #000000;">(func,&#160;args)&#160;{<br />
</span><span style="color: #008080;">72</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.CTRL&#160;</span><span style="background-color: #F5F5F5; color: #000000;">&amp;&amp;</span><span style="background-color: #F5F5F5; color: #000000;">&#160;event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">==</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">this</span><span style="background-color: #F5F5F5; color: #000000;">.B)&#160;{<br />
</span><span style="color: #008080;">73</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(func)&#160;{<br />
</span><span style="color: #008080;">74</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;func(args);<br />
</span><span style="color: #008080;">75</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">else</span><span style="background-color: #F5F5F5; color: #000000;">&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">76</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;window.location.href&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">http://www.yahoo.com.cn</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">77</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080;">78</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;event.keyCode&#160;</span><span style="background-color: #F5F5F5; color: #000000;">=</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #000000;">505</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">79</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">false</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">80</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080;">81</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">return</span><span style="background-color: #F5F5F5; color: #000000;">&#160;</span><span style="background-color: #F5F5F5; color: #0000FF;">true</span><span style="background-color: #F5F5F5; color: #000000;">;<br />
</span><span style="color: #008080;">82</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080;">83</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">84</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">85</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">86</span>&#160;<span style="background-color: #F5F5F5; color: #0000FF;">if</span><span style="background-color: #F5F5F5; color: #000000;">&#160;(window.attachEvent)&#160;{<br />
</span><span style="color: #008080;">87</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&#160;&#160;&#160;&#160;window.attachEvent(</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">onload</span><span style="background-color: #F5F5F5; color: #000000;">"</span><span style="background-color: #F5F5F5; color: #000000;">,&#160;activeHotKey);<br />
</span><span style="color: #008080;">88</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">}<br />
</span><span style="color: #008080;">89</span>&#160;<span style="background-color: #F5F5F5; color: #008000;">//</span><span style="background-color: #F5F5F5; color: #008000;">-->&lt;/script></span><span style="background-color: #F5F5F5; color: #008000;"><br />
</span><span style="color: #008080;">90</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&lt;</span><span style="background-color: #F5F5F5; color: #000000;">/</span><span style="background-color: #F5F5F5; color: #000000;">BODY></span><span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">91</span>&#160;<span style="background-color: #F5F5F5; color: #000000;">&lt;</span><span style="background-color: #F5F5F5; color: #000000;">/</span><span style="background-color: #F5F5F5; color: #000000;">HTML></span><span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">92</span>&#160;<span style="background-color: #F5F5F5; color: #000000;"><br />
</span><span style="color: #008080;">93</span>&#160;</span></div>
<p>&nbsp;</p><img src="http://www.cnblogs.com/x116/aggbug/1378548.html?type=1" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>常用的正则自定义。</title><link>http://www.cnblogs.com/x116/articles/1376576.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Thu, 15 Jan 2009 11:15:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1376576.html</guid><description><![CDATA[<p>阅读: 18 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2009-01-15 19:15 <a href="http://www.cnblogs.com/x116/articles/1376576.html" target="_blank">原文链接</a></p><p>&nbsp;</p>
<p>身份证简单位数验证：包括15位，18位数字和 18位最后一位X结尾</p>
<p>var validReg = new RegExp(/(^\d{15}$)|(^(\d{6})(19|20)?(\d{2})([01]\d)([0123]\d)(\d{3})(\d|[x|X])$)/);</p>
<img src="http://www.cnblogs.com/x116/aggbug/1376576.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1376576.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1376576.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>hotkey的简单应用。</title><link>http://www.cnblogs.com/x116/articles/1356523.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Wed, 17 Dec 2008 02:21:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1356523.html</guid><description><![CDATA[<p>阅读: 21 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2008-12-17 10:21 <a href="http://www.cnblogs.com/x116/articles/1356523.html" target="_blank">原文链接</a></p><p>1. 页面产生热键的调用方法。&#160;</p>
<p>&lt;head></p>
<p>&lt;script></p>
<p>function hotkey(eventname)</p>
<div>&#160;&#160; &#160;{</div>
<div>&#160;&#160;&#160;</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160;if(eventname.keyCode == 116 )</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160;{</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;alert("\nyou've pressed F5");</div>
<div><br />
</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;eventname.keyCode =505;// reset key code</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;return false; //return false to prevent refresh page</div>
<div>&#160;&#160; &#160; &#160; &#160; &#160; &#160;}</div>
<div><br />
</div>
<div>&#160;&#160; &#160; &#160; &#160;return &#160;true;</div>
<div>&#160;&#160; &#160;}&#160;&#160;&#160;</div>
<div><br />
</div>
<div>&#160;&#160; &#160;&lt;/script></div>
<div>&lt;/head></div>
<p>&lt;body &#160;onkeydown="return hotkey(event);"></p>
<p>2. 组合键测试</p>
<p>　　<span class="Apple-tab-span" style="white-space:pre">	</span>检测是否按键使用了 shift+ tab 则使用：</p>
<p>　　<span style="font-family: simsun; font-size: 12px; line-height: normal; ">&lt;script language="javascript"></span></p>
<span style="font-family: simsun; font-size: 12px; line-height: normal; ">　　<span class="Apple-tab-span" style="white-space:pre">	</span>function test()<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>{<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>if (event.shiftKey &amp;&amp; event.keyCode == 9)<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>{<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>alert("Shift Tab");<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>}<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>}<br />
<p>　　&lt;/script></p>
<p>　　&lt;input onkeydown="test();"></p>
<p>&#160;3. 产生组合键实用体验</p>
<p>　　<span class="Apple-tab-span" style="white-space:pre">	</span>就是按下回车后焦点移到上一个控件,而不是下一个控件</p>
<p>　　<span class="Apple-tab-span" style="white-space:pre">	</span>if(event.srcElement.type !="submit" &amp;&amp; event.srcElement.type!="textarea" &amp;&amp; event.keyCode==13)</p>
　　<span class="Apple-tab-span" style="white-space:pre">	</span>{<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>event.shiftKey;<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>　　<span class="Apple-tab-span" style="white-space:pre">	</span>event.keyCode = 9;<br />
<br />
　　<span class="Apple-tab-span" style="white-space:pre">	</span>}</span>
<p>&#160;</p><img src="http://www.cnblogs.com/x116/aggbug/1356523.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1356523.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1356523.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>KeyCode</title><link>http://www.cnblogs.com/x116/articles/1356475.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Wed, 17 Dec 2008 01:39:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1356475.html</guid><description><![CDATA[<p>阅读: 50 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2008-12-17 09:39 <a href="http://www.cnblogs.com/x116/articles/1356475.html" target="_blank">原文链接</a></p><span style="color: #FFF; font-family: Arial; font-size: 12px; line-height: 18px; ">keycode&#160;&#160;&#160; 8 = BackSpace BackSpace<br style="line-height: normal; " />
keycode&#160;&#160;&#160; 9 = Tab Tab<br style="line-height: normal; " />
keycode&#160;&#160; 12 = Clear<br style="line-height: normal; " />
keycode&#160;&#160; 13 = Enter<br style="line-height: normal; " />
keycode&#160;&#160; 16 = Shift_L<br style="line-height: normal; " />
keycode&#160;&#160; 17 = Control_L<br style="line-height: normal; " />
keycode&#160;&#160; 18 = Alt_L<br style="line-height: normal; " />
keycode&#160;&#160; 19 = Pause<br style="line-height: normal; " />
keycode&#160;&#160; 20 = Caps_Lock<br style="line-height: normal; " />
keycode&#160;&#160; 27 = Escape Escape<br style="line-height: normal; " />
keycode&#160;&#160; 32 = space space<br style="line-height: normal; " />
keycode&#160;&#160; 33 = Prior<br style="line-height: normal; " />
keycode&#160;&#160; 34 = Next<br style="line-height: normal; " />
keycode&#160;&#160; 35 = End<br style="line-height: normal; " />
keycode&#160;&#160; 36 = Home<br style="line-height: normal; " />
keycode&#160;&#160; 37 = Left<br style="line-height: normal; " />
keycode&#160;&#160; 38 = Up<br style="line-height: normal; " />
keycode&#160;&#160; 39 = Right<br style="line-height: normal; " />
keycode&#160;&#160; 40 = Down<br style="line-height: normal; " />
keycode&#160;&#160; 41 = Select<br style="line-height: normal; " />
keycode&#160;&#160; 42 = Print<br style="line-height: normal; " />
keycode&#160;&#160; 43 = Execute<br style="line-height: normal; " />
keycode&#160;&#160; 45 = Insert<br style="line-height: normal; " />
keycode&#160;&#160; 46 = Delete<br style="line-height: normal; " />
keycode&#160;&#160; 47 = Help<br style="line-height: normal; " />
keycode&#160;&#160; 48 = 0 equal braceright<br style="line-height: normal; " />
keycode&#160;&#160; 49 = 1 exclam onesuperior<br style="line-height: normal; " />
keycode&#160;&#160; 50 = 2 quotedbl twosuperior<br style="line-height: normal; " />
keycode&#160;&#160; 51 = 3 section threesuperior<br style="line-height: normal; " />
keycode&#160;&#160; 52 = 4 dollar<br style="line-height: normal; " />
keycode&#160;&#160; 53 = 5 percent<br style="line-height: normal; " />
keycode&#160;&#160; 54 = 6 ampersand<br style="line-height: normal; " />
keycode&#160;&#160; 55 = 7 slash braceleft<br style="line-height: normal; " />
keycode&#160;&#160; 56 = 8 parenleft bracketleft<br style="line-height: normal; " />
keycode&#160;&#160; 57 = 9 parenright bracketright<br style="line-height: normal; " />
keycode&#160;&#160; 65 = a A<br style="line-height: normal; " />
keycode&#160;&#160; 66 = b B<br style="line-height: normal; " />
keycode&#160;&#160; 67 = c C<br style="line-height: normal; " />
keycode&#160;&#160; 68 = d D<br style="line-height: normal; " />
keycode&#160;&#160; 69 = e E EuroSign<br style="line-height: normal; " />
keycode&#160;&#160; 70 = f F<br style="line-height: normal; " />
keycode&#160;&#160; 71 = g G<br style="line-height: normal; " />
keycode&#160;&#160; 72 = h H<br style="line-height: normal; " />
keycode&#160;&#160; 73 = i I<br style="line-height: normal; " />
keycode&#160;&#160; 74 = j J<br style="line-height: normal; " />
keycode&#160;&#160; 75 = k K<br style="line-height: normal; " />
keycode&#160;&#160; 76 = l L<br style="line-height: normal; " />
keycode&#160;&#160; 77 = m M mu<br style="line-height: normal; " />
keycode&#160;&#160; 78 = n N<br style="line-height: normal; " />
keycode&#160;&#160; 79 = o O<br style="line-height: normal; " />
keycode&#160;&#160; 80 = p P<br style="line-height: normal; " />
keycode&#160;&#160; 81 = q Q at<br style="line-height: normal; " />
keycode&#160;&#160; 82 = r R<br style="line-height: normal; " />
keycode&#160;&#160; 83 = s S<br style="line-height: normal; " />
keycode&#160;&#160; 84 = t T<br style="line-height: normal; " />
keycode&#160;&#160; 85 = u U<br style="line-height: normal; " />
keycode&#160;&#160; 86 = v V<br style="line-height: normal; " />
keycode&#160;&#160; 87 = w W<br style="line-height: normal; " />
keycode&#160;&#160; 88 = x X<br style="line-height: normal; " />
keycode&#160;&#160; 89 = y Y<br style="line-height: normal; " />
keycode&#160;&#160; 90 = z Z<br style="line-height: normal; " />
keycode&#160;&#160; 96 = KP_0 KP_0<br style="line-height: normal; " />
keycode&#160;&#160; 97 = KP_1 KP_1<br style="line-height: normal; " />
keycode&#160;&#160; 98 = KP_2 KP_2<br style="line-height: normal; " />
keycode&#160;&#160; 99 = KP_3 KP_3<br style="line-height: normal; " />
keycode 100 = KP_4 KP_4<br style="line-height: normal; " />
keycode 101 = KP_5 KP_5<br style="line-height: normal; " />
keycode 102 = KP_6 KP_6<br style="line-height: normal; " />
keycode 103 = KP_7 KP_7<br style="line-height: normal; " />
keycode 104 = KP_8 KP_8<br style="line-height: normal; " />
keycode 105 = KP_9 KP_9<br style="line-height: normal; " />
keycode 106 = KP_Multiply KP_Multiply<br style="line-height: normal; " />
keycode 107 = KP_Add KP_Add<br style="line-height: normal; " />
keycode 108 = KP_Separator KP_Separator<br style="line-height: normal; " />
keycode 109 = KP_Subtract KP_Subtract<br style="line-height: normal; " />
keycode 110 = KP_Decimal KP_Decimal<br style="line-height: normal; " />
keycode 111 = KP_Divide KP_Divide<br style="line-height: normal; " />
keycode 112 = F1<br style="line-height: normal; " />
keycode 113 = F2<br style="line-height: normal; " />
keycode 114 = F3<br style="line-height: normal; " />
keycode 115 = F4<br style="line-height: normal; " />
keycode 116 = F5<br style="line-height: normal; " />
keycode 117 = F6<br style="line-height: normal; " />
keycode 118 = F7<br style="line-height: normal; " />
keycode 119 = F8<br style="line-height: normal; " />
keycode 120 = F9<br style="line-height: normal; " />
keycode 121 = F10<br style="line-height: normal; " />
keycode 122 = F11<br style="line-height: normal; " />
keycode 123 = F12<br style="line-height: normal; " />
keycode 124 = F13<br style="line-height: normal; " />
keycode 125 = F14<br style="line-height: normal; " />
keycode 126 = F15<br style="line-height: normal; " />
keycode 127 = F16<br style="line-height: normal; " />
keycode 128 = F17<br style="line-height: normal; " />
keycode 129 = F18<br style="line-height: normal; " />
keycode 130 = F19<br style="line-height: normal; " />
keycode 131 = F20<br style="line-height: normal; " />
keycode 132 = F21<br style="line-height: normal; " />
keycode 133 = F22<br style="line-height: normal; " />
keycode 134 = F23<br style="line-height: normal; " />
keycode 135 = F24<br style="line-height: normal; " />
keycode 136 = Num_Lock<br style="line-height: normal; " />
keycode 137 = Scroll_Lock<br style="line-height: normal; " />
keycode 187 = acute grave<br style="line-height: normal; " />
keycode 188 = comma semicolon<br style="line-height: normal; " />
keycode 189 = minus underscore<br style="line-height: normal; " />
keycode 190 = period colon<br style="line-height: normal; " />
keycode 192 = numbersign apostrophe<br style="line-height: normal; " />
keycode 210 = plusminus hyphen macron<br style="line-height: normal; " />
keycode 211 =<br style="line-height: normal; " />
keycode 212 = copyright registered<br style="line-height: normal; " />
keycode 213 = guillemotleft guillemotright<br style="line-height: normal; " />
keycode 214 = masculine ordfeminine<br style="line-height: normal; " />
keycode 215 = ae AE<br style="line-height: normal; " />
keycode 216 = cent yen<br style="line-height: normal; " />
keycode 217 = questiondown exclamdown<br style="line-height: normal; " />
keycode 218 = onequarter onehalf threequarters<br style="line-height: normal; " />
keycode 220 = less greater bar<br style="line-height: normal; " />
keycode 221 = plus asterisk asciitilde<br style="line-height: normal; " />
keycode 227 = multiply division<br style="line-height: normal; " />
keycode 228 = acircumflex Acircumflex<br style="line-height: normal; " />
keycode 229 = ecircumflex Ecircumflex<br style="line-height: normal; " />
keycode 230 = icircumflex Icircumflex<br style="line-height: normal; " />
keycode 231 = ocircumflex Ocircumflex<br style="line-height: normal; " />
keycode 232 = ucircumflex Ucircumflex<br style="line-height: normal; " />
keycode 233 = ntilde Ntilde<br style="line-height: normal; " />
keycode 234 = yacute Yacute<br style="line-height: normal; " />
keycode 235 = oslash Ooblique<br style="line-height: normal; " />
keycode 236 = aring Aring<br style="line-height: normal; " />
keycode 237 = ccedilla Ccedilla<br style="line-height: normal; " />
keycode 238 = thorn THORN<br style="line-height: normal; " />
keycode 239 = eth ETH<br style="line-height: normal; " />
keycode 240 = diaeresis cedilla currency<br style="line-height: normal; " />
keycode 241 = agrave Agrave atilde Atilde<br style="line-height: normal; " />
keycode 242 = egrave Egrave<br style="line-height: normal; " />
keycode 243 = igrave Igrave<br style="line-height: normal; " />
keycode 244 = ograve Ograve otilde Otilde<br style="line-height: normal; " />
keycode 245 = ugrave Ugrave<br style="line-height: normal; " />
keycode 246 = adiaeresis Adiaeresis<br style="line-height: normal; " />
keycode 247 = ediaeresis Ediaeresis<br style="line-height: normal; " />
keycode 248 = idiaeresis Idiaeresis<br style="line-height: normal; " />
keycode 249 = odiaeresis Odiaeresis<br style="line-height: normal; " />
keycode 250 = udiaeresis Udiaeresis<br style="line-height: normal; " />
keycode 251 = ssharp question backslash<br style="line-height: normal; " />
keycode 252 = asciicircum degree<br style="line-height: normal; " />
keycode 253 = 3 sterling<br style="line-height: normal; " />
keycode 254 = Mode_switch<br style="line-height: normal; " />
<br style="line-height: normal; " />
<table style="table-layout: auto; line-height: normal; ">
     <tbody style="line-height: normal; ">
         <tr style="line-height: normal; ">
             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">
             <div class="cnt" style="font-family: Arial; word-wrap: break-word; visibility: visible !important; filter: none; font-size: 12px; word-break: normal; overflow-x: hidden; overflow-y: hidden; position: static; line-height: normal; ">
             <table cellspacing="1" cellpadding="1" width="100%" bgcolor="#999999" border="0" style="table-layout: auto; line-height: normal; ">
                 <tbody style="line-height: normal; ">
                     <tr align="center" style="line-height: normal; ">
                         <td colspan="8" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><strong style="line-height: normal; ">字母和数字键的键码值(keyCode)</strong></td>
                     </tr>
                     <tr align="center" bgcolor="#dddddd" style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                     </tr>
                     <tr align="center" style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">
                         <p style="line-height: normal; ">　　<font color="#ff0000" style="line-height: normal; ">A</font></p>
                         </td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">65</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">J</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">74</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">S</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">83</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">1</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">49</td>
                     </tr>
                     <tr align="center" style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">B</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">66</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">K</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">75</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">T</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">84</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">2</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">50</td>
                     </tr>
                     <tr align="center" style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">C</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">67</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">L</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">76</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">U</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">85</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">3</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">51</td>
                     </tr>
                     <tr align="center"  style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">D</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">68</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">M</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">77</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">V</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">86</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">4</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">52</td>
                     </tr>
                     <tr align="center"  style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">E</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">69</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">N</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">78</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">W</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">87</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">5</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">53</td>
                     </tr>
                     <tr align="center"  style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">70</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">O</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">79</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">X</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">88</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">6</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">54</td>
                     </tr>
                     <tr align="center"  style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">G</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">71</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">P</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">80</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Y</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">89</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">7</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">55</td>
                     </tr>
                     <tr align="center" style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">H</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">72</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Q</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">81</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Z</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">90</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">8</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">56</td>
                     </tr>
                     <tr align="center"  style="line-height: normal; ">
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">I</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">73</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">R</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">82</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">0</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">48</td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">9</font></td>
                         <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">57</td>
                     </tr>
                 </table>
                 <p style="line-height: normal; ">　　</p>
                 <table cellspacing="1" cellpadding="1" width="100%" bgcolor="#999999" border="0" style="table-layout: auto; line-height: normal; ">
                     <tbody style="line-height: normal; ">
                         <tr align="center"  style="line-height: normal; ">
                             <td colspan="4" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><strong style="line-height: normal; ">数字键盘上的键的键码值(keyCode)</strong></td>
                             <td colspan="4" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><strong style="line-height: normal; ">功能键键码值(keyCode)</strong></td>
                         </tr>
                         <tr align="center" bgcolor="#dddddd" style="line-height: normal; ">
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                             <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">
                             <p style="line-height: normal; ">　　<font color="#ff0000" style="line-height: normal; ">0</font></p>
                             </td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">96</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">8</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">104</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F1</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">112</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F7</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">118</td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">1</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">97</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">9</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">105</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F2</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">113</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F8</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">119</td>
                         </tr>
                         <tr align="center" style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">2</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">98</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">*</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">106</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F3</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">114</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F9</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">120</td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">3</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">99</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">+</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">107</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F4</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">115</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F10</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">121</td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">4</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">100</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Enter</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">108</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F5</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">116</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F11</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">122</td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">5</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">101</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">-</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">109</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F6</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">117</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">F12</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">123</td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">6</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">102</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">
                             <p style="line-height: normal; ">　　<font color="#ff0000" style="line-height: normal; ">.</font></p>
                             </td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">110</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                         </tr>
                         <tr align="center"  style="line-height: normal; ">
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">7</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">
                             <p style="line-height: normal; ">　　103</p>
                             </td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">/</font></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">111</td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                             <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "></td>
                         </tr>
                     </table>
                     <p style="line-height: normal; ">　　</p>
                     <table cellspacing="1" cellpadding="1" width="100%" bgcolor="#999999" border="0" style="table-layout: auto; line-height: normal; ">
                         <tbody style="line-height: normal; ">
                             <tr align="center"  style="line-height: normal; ">
                                 <td colspan="8" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><strong style="line-height: normal; ">控制键键码值(keyCode)</strong></td>
                             </tr>
                             <tr align="center" bgcolor="#dddddd" style="line-height: normal; ">
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#003399" style="line-height: normal; ">按键</font></td>
                                 <td width="10%" style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#996600" style="line-height: normal; ">键码</font></td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">BackSpace</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">8</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Esc</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">27</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Right Arrow</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">39</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">-_</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">189</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Tab</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">9</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Spacebar</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">32</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Down Arrow</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">40</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">.></font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">190</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Clear</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">12</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Page Up</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">33</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Insert</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">45</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">/?</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">191</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Enter</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">13</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Page Down</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">34</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Delete</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">46</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">`~</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">192</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Shift</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">16</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">End</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">35</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Num Lock</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">144</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">[{</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">219</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Control</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">17</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Home</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">36</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">;:</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">186</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">\|</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">220</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Alt</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">18</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Left Arrow</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">37</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">=+</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">187</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">]}</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">221</td>
                             </tr>
                             <tr align="center"  style="line-height: normal; ">
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Cape Lock</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">20</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">Up Arrow</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">38</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">,&lt;</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">188</td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; "><font color="#ff0000" style="line-height: normal; ">'"</font></td>
                                 <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; filter: none; font-size: 12px; line-height: normal; ">222<br />
                                 <br />
                                 </td>
                             </tr>
                         </table>
                         </div>
                         </td>
                     </tr>
                 </table>
                 </span>
<img src="http://www.cnblogs.com/x116/aggbug/1356475.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1356475.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1356475.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>模态窗口详细使用方法。</title><link>http://www.cnblogs.com/x116/articles/1315738.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Tue, 21 Oct 2008 03:20:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1315738.html</guid><description><![CDATA[<p>阅读: 45 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2008-10-21 11:20 <a href="http://www.cnblogs.com/x116/articles/1315738.html" target="_blank">原文链接</a></p><p>[搜自网络，还给网络]</p>
<p>1.打开窗口：<br />
var handle = window.showModalDialog(url, objects, feathers);<br />
其中：objects可以为参数（包括数组），也可以是对象。<br />
通常的用法 objects = {window} ，把父窗体的对象共享给子窗体。<br />
<br />
示例：<br />
</p>
<p>//打开模式对话框<br />
function doSelectUser(txtId) <br />
{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFeatures="dialogWidth=500px;dialogHeight=360px;center=yes;middle=yes ;help=no;status=no;scroll=no";<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var url,strReturn;<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url="selUser.aspx"; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strReturn=window.showModalDialog(url,'',strFeatures);&nbsp;&nbsp;&nbsp;</p>
<p>}</p>
<br />
<p>2.关闭子窗口：<br />
window.close();</p>
<p>3.从子窗体传参数给父窗体：<br />
window.returnValue = string;</p>
<p>3.清除缓存，防止模式窗口页面不更新的情况：<br />
&lt;META HTTP-EQUIV="pragma" CONTENT="no-cache"&gt;<br />
&lt;META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"&gt;</p>
<p>4.防止打开新窗口（如提交表单）：<br />
&lt;base target="_self"&gt;</p>
<p>5.在模式窗口使用F5刷新页面：<br />
&lt;base target="_self"&gt;<br />
&lt;body onkeydown="if (event.keyCode==116){reload.click()}"&gt;<br />
&lt;a id="reload" href="&lt;%=Request.Url%&gt;" style="display:none"&gt;&lt;/a&gt;</p>
<p>6.防止模式窗口打开的页面出现cookie丢失的情况：<br />
模式窗口打开新窗口时，仅可以使用 showModalDialog(url,window,feathers); 方法，且 objects 为 window 。<br />
<br />
7.在弹出窗口中获得或设置主窗口的任何值：<br />
打开弹出窗口时用：showModalDialog(url, window, feathers)<br />
在弹出窗口中使用 window.dialogArguments 对象（即主窗口传递过来的 window 对象集），即可以获得或者设置主窗口的值。</p>
<img src="http://www.cnblogs.com/x116/aggbug/1315738.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1315738.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1315738.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item><item><title>AJAX 异步交互 ashx</title><link>http://www.cnblogs.com/x116/articles/1312380.html</link><dc:creator>普若伽门</dc:creator><author>普若伽门</author><pubDate>Thu, 16 Oct 2008 02:05:00 GMT</pubDate><guid>http://www.cnblogs.com/x116/articles/1312380.html</guid><description><![CDATA[<p>阅读: 257 评论: 0 作者: <a href="http://www.cnblogs.com/x116/" target="_blank">普若伽门</a> 发表于 2008-10-16 10:05 <a href="http://www.cnblogs.com/x116/articles/1312380.html" target="_blank">原文链接</a></p><span  style="font-family: verdana; font-size: 10px; line-height: 15px; ">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">[搜自网络，还给网络]</p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">1、Microsoft Ajax Library的客户端架构&#160;<img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/firewolffeng/fsdfds.JPG" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<ul style="list-style-type: none; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 35px; ">
    <li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style-type: disc; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; ">MicrosoftAJAXLibrary的组成部分之一</li>
    <li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style-type: disc; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; ">负责ASP.NETAJAX框架中所有的客户端与服务器端的通信</li>
    <li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style-type: disc; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; ">其默认实现封装了XMLHttpRequest的功能
    <div style="padding-right: 5.4pt; padding-left: 5.4pt; background-image: initial; background-repeat: initial; background-attachment: initial; background-color: #e6e6e6; padding-bottom: 4px; border-left-color: windowtext; width: 95%; word-break: break-all; padding-top: 4px; ">
    <div><img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">script&#160;language</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text/javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">&#160;getXMLHttpRequest()<br />
    <img id="_85_493_Open_Image" onclick="this.style.display='none'; document.getElementById('_85_493_Open_Text').style.display='none'; document.getElementById('_85_493_Closed_Image').style.display='inline'; document.getElementById('_85_493_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;</span><span id="_85_493_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(window.XMLHttpRequest)<br />
    <img id="_118_191_Open_Image" onclick="this.style.display='none'; document.getElementById('_118_191_Open_Text').style.display='none'; document.getElementById('_118_191_Closed_Image').style.display='inline'; document.getElementById('_118_191_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_118_191_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">适用于firefox浏览器创建异步通讯对象</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">return</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">new</span><span style="color: #000000; ">&#160;window.XMLHttpRequest();<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; "><br />
    <img id="_202_490_Open_Image" onclick="this.style.display='none'; document.getElementById('_202_490_Open_Text').style.display='none'; document.getElementById('_202_490_Closed_Image').style.display='inline'; document.getElementById('_202_490_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_202_490_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">适用于IE来创建异步通讯对象，两个是不同的版本</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;progIDs&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;[&#160;</span><span style="color: #000000; ">'</span><span style="color: #000000; ">Msxml2.XMLHTTP</span><span style="color: #000000; ">'</span><span style="color: #000000; ">,&#160;</span><span style="color: #000000; ">'</span><span style="color: #000000; ">Microsoft.XMLHTTP</span><span style="color: #000000; ">'</span><span style="color: #000000; ">&#160;];<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">for</span><span style="color: #000000; ">&#160;(</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;i&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">;&#160;i&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">&#160;progIDs.length;&#160;i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)<br />
    <img id="_348_463_Open_Image" onclick="this.style.display='none'; document.getElementById('_348_463_Open_Text').style.display='none'; document.getElementById('_348_463_Closed_Image').style.display='inline'; document.getElementById('_348_463_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_348_463_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">try</span><span style="color: #000000; "><br />
    <img id="_362_439_Open_Image" onclick="this.style.display='none'; document.getElementById('_362_439_Open_Text').style.display='none'; document.getElementById('_362_439_Closed_Image').style.display='inline'; document.getElementById('_362_439_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_362_439_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;xmlHttp&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">new</span><span style="color: #000000; ">&#160;ActiveXObject(progIDs[i]);<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">return</span><span style="color: #000000; ">&#160;xmlHttp;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img id="_456_458_Open_Image" onclick="this.style.display='none'; document.getElementById('_456_458_Open_Text').style.display='none'; document.getElementById('_456_458_Closed_Image').style.display='inline'; document.getElementById('_456_458_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">catch</span><span style="color: #000000; ">&#160;(ex)&#160;</span><span id="_456_458_Open_Text"><span style="color: #000000; ">{&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">return</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">null</span><span style="color: #000000; ">;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">&#160;sendRequest()<br />
    <img id="_522_791_Open_Image" onclick="this.style.display='none'; document.getElementById('_522_791_Open_Text').style.display='none'; document.getElementById('_522_791_Closed_Image').style.display='inline'; document.getElementById('_522_791_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;</span><span id="_522_791_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;xhr&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;getXMLHttpRequest();<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;xhr.open(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">POST</span><span style="color: #000000; ">"</span><span style="color: #000000; ">,&#160;</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Handlers/RandomNumber.ashx</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">设置准备状态改变的回调函数</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;xhr.onreadystatechange&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">()<br />
    <img id="_671_770_Open_Image" onclick="this.style.display='none'; document.getElementById('_671_770_Open_Text').style.display='none'; document.getElementById('_671_770_Closed_Image').style.display='inline'; document.getElementById('_671_770_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_671_770_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">设置onReadyStateChange作为回调函数</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">将异步通讯对象作为this的上下文</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;onReadyStateChange.apply(xhr);<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;xhr.send(</span><span style="color: #0000ff; ">null</span><span style="color: #000000; ">);<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">&#160;onReadyStateChange()<br />
    <img id="_827_1423_Open_Image" onclick="this.style.display='none'; document.getElementById('_827_1423_Open_Text').style.display='none'; document.getElementById('_827_1423_Closed_Image').style.display='inline'; document.getElementById('_827_1423_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;</span><span id="_827_1423_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">异步通讯对象的readyState的5种状态</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">0&#160;－&#160;（未初始化）还没有调用send()方法</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">1&#160;－&#160;（载入）已调用send()方法，正在发送请求</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">2&#160;－&#160;（载入完成）send()方法执行完成，已经接收到全部响应内容</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">3&#160;－&#160;（交互）正在解析响应内容</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">4&#160;－&#160;（完成）响应内容解析完成，可以在客户端调用了</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(</span><span style="color: #0000ff; ">this</span><span style="color: #000000; ">.readyState&#160;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">4</span><span style="color: #000000; ">)<br />
    <img id="_1269_1420_Open_Image" onclick="this.style.display='none'; document.getElementById('_1269_1420_Open_Text').style.display='none'; document.getElementById('_1269_1420_Closed_Image').style.display='inline'; document.getElementById('_1269_1420_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_1269_1420_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">Http响应状态，值很多，但是我们只需要知道200为正常返回</span><span style="color: #008000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(</span><span style="color: #0000ff; ">this</span><span style="color: #000000; ">.status&#160;</span><span style="color: #000000; ">==</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">200</span><span style="color: #000000; ">)<br />
    <img id="_1340_1375_Open_Image" onclick="this.style.display='none'; document.getElementById('_1340_1375_Open_Text').style.display='none'; document.getElementById('_1340_1375_Closed_Image').style.display='inline'; document.getElementById('_1340_1375_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_1340_1375_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #0000ff; ">this</span><span style="color: #000000; ">.responseText);<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; "><br />
    <img id="_1388_1416_Open_Image" onclick="this.style.display='none'; document.getElementById('_1388_1416_Open_Text').style.display='none'; document.getElementById('_1388_1416_Closed_Image').style.display='inline'; document.getElementById('_1388_1416_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_1388_1416_Open_Text"><span style="color: #000000; ">{<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">throw</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">new</span><span style="color: #000000; ">&#160;Error();<br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
    <img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">script</span><span style="color: #000000; ">></span></div>
    </div>
    上例是不实用Asp.Net Ajax客户端架构，直接进行异步通讯的示例，在服务端是使用Response.Write来返回客户端数据</li>
</ul>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">2、使用Asp.Net Ajax异步通讯层</p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">Asp.Net Ajax异步通讯层主要有三个类WebRequest、WebRequestExecutor、WebRequestManager，这三个类都在Sys.Net命名空间下。</p>
<ul style="list-style-type: none; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 35px; ">
    <li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style-type: disc; padding-top: 2px; padding-right: 0px; padding-bottom: 2px; padding-left: 0px; ">WebRequest类：负责收集（存储）请求信息。
    <table cellspacing="0" cellpadding="1" width="558" summary="" border="1" style="width: 558px; height: 59px; ">
        <tr>
            <td>事件completed</td>
            <td>得到回复后触发，就是表明这个异步传输已经由服务器那边给出了回应，不管这个回应是错误的还是超时的</td>
        </tr>
        <tr>
            <td>add_completed/remove_completed</td>
            <td>添加/移除completed事件的事件处理器</td>
        </tr>
        <tr>
            <td>getResolvedUrl</td>
            <td>获得完整的URL</td>
        </tr>
        <tr>
            <td>invoke</td>
            <td>执行（发送）请求</td>
        </tr>
        <tr>
            <td>set_url(url)</td>
            <td>设置服务器响应页面/Handler的地址</td>
        </tr>
        <tr>
            <td>get_headers()</td>
            <td>得到请求的头信息集合</td>
        </tr>
        <tr>
            <td>set_body(data)</td>
            <td>设置发送到服务器的请求内容</td>
        </tr>
        <tr>
            <td>set_httpVerb(verb)</td>
            <td>设置请求所用的Http方法(Post, Get, Put,)</td>
        </tr>
        <tr>
            <td>set_timeout(time)</td>
            <td>设置超时时间</td>
        </tr>
        <tr>
            <td>
            <p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">get_executor()</p>
            </td>
            <td>得到发送请求的Executor对象</td>
        </tr>
        <tr>
            <td>set_userContext</td>
            <td>设置附加于WebRequest的对象</td>
        </tr>
    </table>
    </li>
</ul>
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background-image: initial; background-repeat: initial; background-attachment: initial; background-color: #e6e6e6; padding-bottom: 4px; border-left-color: windowtext; width: 95%; word-break: break-all; padding-top: 4px; ">
<div><img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">script&#160;language</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text/javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;webRequest&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">null</span><span style="color: #000000; ">;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">&#160;sendRequest(action)<br />
<img id="_115_512_Open_Image" onclick="this.style.display='none'; document.getElementById('_115_512_Open_Text').style.display='none'; document.getElementById('_115_512_Closed_Image').style.display='inline'; document.getElementById('_115_512_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;</span><span id="_115_512_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;ff&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;[</span><span style="color: #000000; ">1</span><span style="color: #000000; ">,&#160;</span><span style="color: #000000; ">2</span><span style="color: #000000; ">,&#160;</span><span style="color: #000000; ">3</span><span style="color: #000000; ">,&#160;</span><span style="color: #000000; ">4</span><span style="color: #000000; ">];<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">new</span><span style="color: #000000; ">&#160;Sys.Net.WebRequest();<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.set_url(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Handlers/Complex.ashx</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.get_headers()[</span><span style="color: #000000; ">"</span><span style="color: #000000; ">action</span><span style="color: #000000; ">"</span><span style="color: #000000; ">]&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;action;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.set_body(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">data=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">+</span><span style="color: #000000; ">&#160;encodeURIComponent(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Hello&#160;World!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">));<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.set_httpVerb(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">POST</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.set_timeout(</span><span style="color: #000000; ">3000</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.set_userContext(ff);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.add_completed(onCompleted);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;webRequest.invoke();<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">&#160;onCompleted(response,&#160;eventArgs)<br />
<img id="_561_1215_Open_Image" onclick="this.style.display='none'; document.getElementById('_561_1215_Open_Text').style.display='none'; document.getElementById('_561_1215_Closed_Image').style.display='inline'; document.getElementById('_561_1215_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;</span><span id="_561_1215_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">得到请求Request里面的设备上下文</span><span style="color: #008000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(response.get_webRequest().get_userContext());<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(response.get_aborted())<br />
<img id="_713_747_Open_Image" onclick="this.style.display='none'; document.getElementById('_713_747_Open_Text').style.display='none'; document.getElementById('_713_747_Closed_Image').style.display='inline'; document.getElementById('_713_747_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_713_747_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Request&#160;aborted!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(response.get_responseAvailable())<br />
<img id="_796_1092_Open_Image" onclick="this.style.display='none'; document.getElementById('_796_1092_Open_Text').style.display='none'; document.getElementById('_796_1092_Closed_Image').style.display='inline'; document.getElementById('_796_1092_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_796_1092_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">var</span><span style="color: #000000; ">&#160;statusCode&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;response.get_statusCode();<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;((statusCode&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">200</span><span style="color: #000000; ">)&#160;</span><span style="color: #000000; ">||</span><span style="color: #000000; ">&#160;(statusCode&#160;</span><span style="color: #000000; ">>=</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">300</span><span style="color: #000000; ">))<br />
<img id="_898_933_Open_Image" onclick="this.style.display='none'; document.getElementById('_898_933_Open_Text').style.display='none'; document.getElementById('_898_933_Closed_Image').style.display='inline'; document.getElementById('_898_933_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_898_933_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Error&#160;occurred!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; "><br />
<img id="_946_1088_Open_Image" onclick="this.style.display='none'; document.getElementById('_946_1088_Open_Text').style.display='none'; document.getElementById('_946_1088_Closed_Image').style.display='inline'; document.getElementById('_946_1088_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_946_1088_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(response.get_responseData());<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">&#160;response.get_xml();</span><span style="color: #008000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">&#160;response.get_object();</span><span style="color: #008000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">&#160;response.getResponseHeader(...);</span><span style="color: #008000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; ">&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(response.get_timedOut())<br />
<img id="_1132_1168_Open_Image" onclick="this.style.display='none'; document.getElementById('_1132_1168_Open_Text').style.display='none'; document.getElementById('_1132_1168_Closed_Image').style.display='inline'; document.getElementById('_1132_1168_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_1132_1168_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Request&#160;timed&#160;out!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">else</span><span style="color: #000000; "><br />
<img id="_1179_1212_Open_Image" onclick="this.style.display='none'; document.getElementById('_1179_1212_Open_Text').style.display='none'; document.getElementById('_1179_1212_Closed_Image').style.display='inline'; document.getElementById('_1179_1212_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_1179_1212_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Error&#160;occurred!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">script</span><span style="color: #000000; ">></span></div>
</div>
如上例是一个使用Microsoft Asp.Net Ajax架构来进行异步传输的例子，上例中有一个set_userContext(Object)，这个方法是设置webRequest的用户上下文，设置以后，userContext的内容不会传输到服务端(据我观察)，他将会把这个属性传到completed事件处理器中。在上例中使用到了WebRequestExecutor类，response就是WebRequestExecutor类，这个类的属性与方法如下
<table cellspacing="0" cellpadding="1" width="593" summary="" border="1" style="width: 593px; height: 59px; ">
    <tr>
        <td>abort()</td>
        <td>取消当前请求</td>
    </tr>
    <tr>
        <td>executeRequest()</td>
        <td>执行请求</td>
    </tr>
    <tr>
        <td>getAllResponseHeaders()</td>
        <td>获取回复内所有的头信息，返回值是一个集合</td>
    </tr>
    <tr>
        <td>getResponseHeader(HeaderName)</td>
        <td>获取回复内指定的头信息</td>
    </tr>
    <tr>
        <td>get_aborted()/set</td>
        <td>表示请求是否被取消</td>
    </tr>
    <tr>
        <td>get_responseAvailable()</td>
        <td>表示是否得到了正确的结果</td>
    </tr>
    <tr>
        <td>get_responseData()</td>
        <td>获得字符串形势的回复内容</td>
    </tr>
    <tr>
        <td>get_started()</td>
        <td>表示请求是否已经开始</td>
    </tr>
    <tr>
        <td>get_statusCode()</td>
        <td>表示回复状态的代码</td>
    </tr>
    <tr>
        <td>get_statusText()</td>
        <td>表示回复状态的文字</td>
    </tr>
    <tr>
        <td>get_timedOut()</td>
        <td>表示回复是否是超时状态</td>
    </tr>
    <tr>
        <td>get_xml()</td>
        <td>获得xml形式的回复内容</td>
    </tr>
    <tr>
        <td>get_webRequest()</td>
        <td>获得当前正在执行的WebRequest对象</td>
    </tr>
</table>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">在上面两个类的方法和属性说明中，get_/set_开头的是属性，属性应该有响应的get/set方法，我只标明了一部分，但是有的属性肯定是只读属性，这里我没有明确标明，也没有尝试，在实际编程中，应该很容易知道哪个是只读属性。在发送请求的函数中可以使用webRequest.get_executor()来得到WebRequestExecutor类的实例，在completed事件处理函数中，可以通过webRequestExecutor.get_webRequest得到webRequest类的实例，有点循环引用的意思。</p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; ">3、WebRequestManager类的说明</p>
<table cellspacing="0" cellpadding="1" width="593" summary="" border="1" style="width: 593px; height: 59px; ">
    <tr>
        <td>invokingRequest事件</td>
        <td>即将发出请求时触发，可用于取消某个请求</td>
    </tr>
    <tr>
        <td>completedRequest事件</td>
        <td>请求结束时触发，它早于WebRequest对象的completed事件触发</td>
    </tr>
    <tr>
        <td>defaultTimeout属性</td>
        <td>默认的超时时间</td>
    </tr>
    <tr>
        <td>defaultExecutorType</td>
        <td>默认的发送请求的Executor类型</td>
    </tr>
    <tr>
        <td>add/remove_invokingRequest(handler)</td>
        <td>添加/移除invokingRequest的事件处理器</td>
    </tr>
    <tr>
        <td>add/remove_completedRequest(handler)</td>
        <td>添加/移除completedRequest的事件处理器</td>
    </tr>
</table>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; "></p>
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background-image: initial; background-repeat: initial; background-attachment: initial; background-color: #e6e6e6; padding-bottom: 4px; border-left-color: windowtext; width: 95%; word-break: break-all; padding-top: 4px; ">
<div><img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">asp:ScriptManager&#160;ID</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">ScriptManager1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;runat</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">server</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">/></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">asp:UpdatePanel&#160;ID</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">UpdatePanel1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;runat</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">server</span><span style="color: #000000; ">"</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">ContentTemplate</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;%=</span><span style="color: #000000; ">&#160;DateTime.Now&#160;</span><span style="color: #000000; ">%>&lt;</span><span style="color: #000000; ">br&#160;</span><span style="color: #000000; ">/></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">asp:Button&#160;ID</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Button1</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;runat</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">server</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;Text</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Button</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">/></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">ContentTemplate</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">asp:UpdatePanel</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">script&#160;language</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text/javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Sys.Net.WebRequestManager.add_invokingRequest(</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">(sender,&#160;eventArgs)<br />
<img id="_409_525_Open_Image" onclick="this.style.display='none'; document.getElementById('_409_525_Open_Text').style.display='none'; document.getElementById('_409_525_Closed_Image').style.display='inline'; document.getElementById('_409_525_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_409_525_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">debugger</span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff; ">if</span><span style="color: #000000; ">&#160;(confirm(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Cancel&#160;the&#160;partial&#160;rendering?</span><span style="color: #000000; ">"</span><span style="color: #000000; ">))<br />
<img id="_481_520_Open_Image" onclick="this.style.display='none'; document.getElementById('_481_520_Open_Text').style.display='none'; document.getElementById('_481_520_Closed_Image').style.display='inline'; document.getElementById('_481_520_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_481_520_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;eventArgs.set_cancel(</span><span style="color: #0000ff; ">true</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; "><br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Sys.Net.WebRequestManager.add_completedRequest(</span><span style="color: #0000ff; ">function</span><span style="color: #000000; ">()<br />
<img id="_597_635_Open_Image" onclick="this.style.display='none'; document.getElementById('_597_635_Open_Text').style.display='none'; document.getElementById('_597_635_Closed_Image').style.display='inline'; document.getElementById('_597_635_Closed_Text').style.display='inline';" alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span id="_597_635_Open_Text"><span style="color: #000000; ">{<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;alert(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Response&#160;received!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></span><span style="color: #000000; ">);<br />
<img alt="" align="top" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">script</span><span style="color: #000000; ">></span></div>
</div>
记得UpdatePanel中有一个PageRequestManager类，这个类适用与页面级别的调用，WebRequestManager是对web请求适用，并且PageRequestManager的initializeRequest事件优先与invokingRequest事件，从名字上就可以区分出来一个是初始化事件，一个是调用请求的事件。上面这个例子有一个bug，取消请求之后要重新刷新页面才能正常的调用。这个bug我还没有找到好的方法解决。注意：在这个例子中WebRequestManager类是结合UpdatePanel使用的，能否在与WebRequest和WebRequestExecutor类结合使用，在后面的课程中有讲述</span><img src="http://www.cnblogs.com/x116/aggbug/1312380.html?type=2" width="1" height="1" alt=""/><p>评论: 0　<a href="http://www.cnblogs.com/x116/articles/1312380.html#pagedcomment" target="_blank">查看评论</a>　<a href="http://www.cnblogs.com/x116/articles/1312380.html#commentform" target="_blank">发表评论</a></p><p><a href="http://job.cnblogs.com/" target="_blank">找优秀程序员，就在博客园</a></p><hr/><p>最新新闻：<br/>· <a href="http://news.cnblogs.com/n/59229/" target="_blank">有感于“研发人员的个人培养和组织培养”</a><span style="color:gray">(2010-03-20 11:49)</span><br/>· <a href="http://news.cnblogs.com/n/59228/" target="_blank">SQL vs NoSQL：数据库并发写入性能比拼</a><span style="color:gray">(2010-03-20 11:44)</span><br/>· <a href="http://news.cnblogs.com/n/59227/" target="_blank">国内手机应用商店火拼升级：盗版困扰付费下载</a><span style="color:gray">(2010-03-20 11:31)</span><br/>· <a href="http://news.cnblogs.com/n/59226/" target="_blank">Google更新Android版地图服务</a><span style="color:gray">(2010-03-20 11:25)</span><br/>· <a href="http://news.cnblogs.com/n/59225/" target="_blank">Mozilla确认Firefox 3.6漏洞</a><span style="color:gray">(2010-03-20 11:22)</span><br/></p><p>编辑推荐：<a href="http://news.cnblogs.com/n/59093/" target="_blank">[视频]想做你的Code</a><br/></p><p>网站导航：<a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/" target="_blank">个人主页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://home.cnblogs.com/group/" target="_blank">小组</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://kb.cnblogs.com" target="_blank">知识库</a></p>]]></description></item></channel></rss>