﻿<?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>BlogJava-qileilove-随笔分类-HTML5</title><link>http://www.blogjava.net/qileilove/category/50118.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 09 May 2012 06:18:01 GMT</lastBuildDate><pubDate>Wed, 09 May 2012 06:18:01 GMT</pubDate><ttl>60</ttl><item><title>如何在15分钟内掌握JavaScript面向对象编程</title><link>http://www.blogjava.net/qileilove/archive/2012/05/09/377670.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Wed, 09 May 2012 02:02:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2012/05/09/377670.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/377670.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2012/05/09/377670.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/377670.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/377670.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 导读：经常看到一些JavaScript的代码脏乱得无法理解，到处都是属性和方法，或者一个循环套着一个循环。但如果使用面向对象就能很好的理清代码，并方便理解和修改代码。如果你不希望自己的代码只有上帝理解的话，就请尽量考虑使用面向对象的模式。　　译文正文：　　到处都是属性、方法，代码极其难懂，天哪，我的程序员，你究竟在做什么？仔细看看这篇指南，让我们一起写出优雅的面向对象的JavaScript代码吧！...&nbsp;&nbsp;<a href='http://www.blogjava.net/qileilove/archive/2012/05/09/377670.html'>阅读全文</a><img src ="http://www.blogjava.net/qileilove/aggbug/377670.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2012-05-09 10:02 <a href="http://www.blogjava.net/qileilove/archive/2012/05/09/377670.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何编写可维护的面向对象JavaScript代码</title><link>http://www.blogjava.net/qileilove/archive/2012/04/28/376930.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Sat, 28 Apr 2012 02:17:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2012/04/28/376930.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/376930.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2012/04/28/376930.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/376930.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/376930.html</trackback:ping><description><![CDATA[<div><p>　　能够写出可维护的面向对象JavaScript代码不仅可以节约金钱，还能让你很受欢迎。不信？有可能你自己或者其他什么人有一天会回来重用你 的代码。如果能尽量让这个经历不那么痛苦，就可以节省不少时间。地球人都知道，时间就是金钱。同样的，你也会因为帮某人省去了头疼的过程而获得他的偏爱。 但是，在开始探索如何编写可维护的面向对象JavaScript代码之前，我们先来快速看看什么是面向对象。如果已经了解面向对象的概念了，就可以直接跳 过下一节。</p><p><strong>　　什么是面向对象？</strong></p><p>　　面向对象编程主要通过代码代表现实世界中的实质对 象。要创建对象，首先需要写一个&#8220;类&#8221;来定义。  类几乎可以代表所有的东西：账户，员工，导航菜单，汽车，植物，广告，饮料，等等。而每次要创建对象的时候，就从类实例化一个对象。换句话说，就是创建类 的实例做为对象。事实上，通常处理一个以上的同类事物时就会使用到对象。另外，只需要简单的函数式程序就可以做的很好。对象实质上是数据的容器。因此在一 个employee对象中，你可能要储存员工号，姓名，入职日期，职称，工资，资历，等等。对象也包括处理数据的函数（也叫做&#8220;方法&#8221;）。方法被用作媒介 来确保数据的完整性，以及在储存之前对数据进行转换。例如，方法可以接收任意格式的日期然后在储存之前将其转化成标准化格式。最后，类还可以继承其他的 类。继承可以让你在不同类中重复使用相同代码。例如，银行账户和音像店账户都可以继承一个基本的账户类，里面包括个人信息，开户日期，分部信息，等等。然 后每个都可以定义自己的交易或者借款处理等数据结构和方法。</p><p><strong>　　警告：JavaScript面向对象是不一样的</strong></p><p>　　在上一节中，概述了经典的面向对象编程的基本知识。说经典是因为JavaScript并不遵循这些规则。相反地，JavaScript的类是写成函数的样子，而继承则是通过原型实现的。原型继承基本上意味着使用原型属性来实现对象的继承，而不是从类继承类。</p><p>　　&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p><p>　　【2012-4-25 11：11：35 更新】：根据微博网友@高翌翔 的反馈，前文中有关&#8220;JS 面向对象&#8221;的内容不够细。现推荐《Javascript 面向对象编程》《再谈javascript面向对象编程》两篇<a target="_self"><u><strong>文章</strong></u></a>。</p><p>　　&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p><p>　　对象的实例化</p><p>　　以下是JavaScript中对象实例化的例子：</p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"><tbody><tr><td>// 定义Employee类<div number2="" index1="" alt1=""><code spaces="">&nbsp;</code><code plain="">　　</code><code color3="">function</code><code plain="">Employee(num, fname, lname) {</code></div><div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;</code><code plain="">　　　　</code><code keyword="">this</code><code plain="">.getFullName =</code><code color3="">function</code><code plain="">() {</code></div><div number4="" index3="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">　　</code><code keyword="">return</code><code plain="">fname +</code><code string="">" "</code><code plain="">+ lname;</code></div><div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">　　}</code></div><div number6="" index5="" alt1=""><code spaces="">&nbsp;</code><code plain="">　　};</code></div><div number7="" index6="" alt2=""><code spaces="">&nbsp;</code>&nbsp;</div><div number8="" index7="" alt1=""><code spaces="">&nbsp;</code><code plain="">　</code><code comments="">// 实例化Employee对象</code></div><div number9="" index8="" alt2=""><code spaces="">&nbsp;</code><code plain="">　</code><code variable="">var</code><code plain="">john =</code><code keyword="">new</code><code plain="">Employee(</code><code string="">"4815162342"</code><code plain="">,</code><code string="">"John"</code><code plain="">,</code><code string="">"Doe"</code><code plain="">);</code></div><div number10="" index9="" alt1=""><code spaces="">&nbsp;</code><code plain="">　 alert(</code><code string="">"The employee's full name is "</code><code plain="">+ john.getFullName());</code></div></td></tr></tbody></table><p>　　在这里，有三个重点需要注意：</p><p>　　1、&#8220;class&#8221;函数名的第一个字母要大写。这表明该函数的目的是被实例化而不是像一般函数一样被调用。</p><p>　　2、在实例化的时候使用了new操作符。如果省略掉new而仅仅调用函数则会产生很多问题。</p><p>　　3、因为getFullName指定给this操作符了，所以是公共可用的，但是fname和lname则不是。由Employee函数产生的闭包给了getFullName到fname和lname的入口，但同时对于其他类仍然是私有的。</p><p><strong>　　原型继承</strong></p><p>　　下面是JavaScript中原型继承的例子：</p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"><tbody><tr><td>// 定义Human类<div number2="" index1="" alt1=""><code keyword="">function</code><code plain="">Human() {</code></div><div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.setName =</code><code keyword="">function</code><code plain="">(fname, lname) {</code></div><div number4="" index3="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.fname = fname;</code></div><div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.lname = lname;</code></div><div number6="" index5="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}</code></div><div number7="" index6="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.getFullName =</code><code keyword="">function</code><code plain="">() {</code></div><div number8="" index7="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">return</code><code keyword="">this</code><code plain="">.fname +</code><code string="">" "</code><code plain="">+</code><code keyword="">this</code><code plain="">.lname;</code></div><div number9="" index8="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}</code></div><div number10="" index9="" alt1=""><code plain="">}</code></div><div number11="" index10="" alt2="">&nbsp;</div><div number12="" index11="" alt1=""><code comments="">// 定义Employee类</code></div><div number13="" index12="" alt2=""><code keyword="">function</code><code plain="">Employee(num) {</code></div><div number14="" index13="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.getNum =</code><code keyword="">function</code><code plain="">() {</code></div><div number15="" index14="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">return</code><code plain="">num;</code></div><div number16="" index15="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}</code></div><div number17="" index16="" alt2=""><code plain="">};</code></div><div number18="" index17="" alt1=""><code comments="">//让Employee继承Human类</code></div><div number19="" index18="" alt2=""><code plain="">Employee.prototype =</code><code keyword="">new</code><code plain="">Human();</code></div><div number20="" index19="" alt1="">&nbsp;</div><div number21="" index20="" alt2=""><code comments="">// 实例化Employee对象</code></div><div number22="" index21="" alt1=""><code keyword="">var</code><code plain="">john =</code><code keyword="">new</code><code plain="">Employee(</code><code string="">"4815162342"</code><code plain="">);</code></div><div number23="" index22="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">john.setName(</code><code string="">"John"</code><code plain="">,</code><code string="">"Doe"</code><code plain="">);</code></div><div number24="" index23="" alt1=""><code plain="">alert(john.getFullName() +</code><code string="">"'s employee number is "</code><code plain="">+ john.getNum());</code></div></td></tr></tbody></table><p>　　这一次，创建的Human类包含人类的一切共有属性&#8212;&#8212;我也将fname和lname放进去了，因为不仅仅是员工才有名字，所有人都有名字。然后将Human对象赋值给它的prototype属性。</p>             </div><div><p><strong>　　通过继承实现代码重用</strong></p> <p>　　在前面的例子中，原来的Employee类被分解成两个部分。所有的人类通用属性被移到了Human类中，然后让Employee继承 Human。这样的话，Human里面的属性就可以被其他的对象使用，例如Student（学生），Client（顾客），Citizen（公 民），Visitor（游客），等等。现在你可能注意到了，这是分割和重用代码很好的方式。处理Human对象时，只需要继承Human来使用已存在的属 性，而不需要对每种不同的对象都重新一一创建。除此以外，如果要添加一个&#8220;中间名字&#8221;的属性，只需要加一次，那些继承了 Human  类的就可以立马使用了。反而言之，如果我们只是想要给一个对象加&#8220;中间名字&#8221;的属性，我们就直接加在那个对象里面，而不需要在Human 类里面加。</p> <p><strong>　　1、Public（公有的）和Private（私有的）</strong></p> <p>　　接下来的主题，我想谈谈类中的公有和私有变量。根据对象中处理数据的方式不同，数据会被处理为私有的或者公有的。私有属性并不一定意味着其他人无法访问。可能只是某个方法需要用到。</p> <p><strong>　　&#9679; 只读</strong></p> <p>　　有时，你只是想要在创建对象的时候能有一个值。一旦创建，就不想要其他人再改变这个值。为了做到这点，可以创建一个私有变量，在实例化的时候给它赋值。</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <div number1="" index0="" alt2=""><code keyword="">function</code> <code plain="">Animal(type) { </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">var</code> <code plain="">data = []; </code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">data[</code><code string="">'type'</code><code plain="">] = type; </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.getType = </code><code keyword="">function</code> <code plain="">() { </code></div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">return</code> <code plain="">data[</code><code string="">'type'</code><code plain="">]; </code></div> <div number6="" index5="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">} </code></div> <div number7="" index6="" alt2=""><code plain="">} </code></div> <div number8="" index7="" alt1="">&nbsp;</div> <div number9="" index8="" alt2=""><code keyword="">var</code> <code plain="">fluffy = </code><code keyword="">new</code> <code plain="">Animal(</code><code string="">'dog'</code><code plain="">); </code></div> <div number10="" index9="" alt1=""><code plain="">fluffy.getType(); </code><code comments="">// 返回 'dog'</code></div></td></tr></tbody></table> <p>　　在这个例子中，Animal类中创建了一个本地数组data。当  Animal对象被实例化时，传递了一个type的值并将该值放置在data数组中。因为它是私有的，所以该值无法被覆盖（Animal函数定义了它的范 围）。一旦对象被实例化了，读取type值的唯一方式是调用getType方法。因为getType是在Animal中定义的，因此凭借Animal产生 的闭包，getType可以进到data中。这样的话，虽可以读到对象的类型却无法改变。</p> <p>　　有一点非常重要，就是当对象被继承时，&#8220;只读&#8221;技术就无法运用。在执行继承后，每个实例化的对象都会共享那些只读变量并覆盖其值。最简单的解决办法是将类中的只读变量转换成公共变量。但是你必须保持它们是私有的，你可以使用Philippe在评论中提到的技术。</p> <p><strong>　　&#9679; Public（公有）</strong></p> <p>　　当然也有些时候你想要任意读写某个属性的值。要实现这一点，需要使用this操作符。</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <div number1="" index0="" alt2=""><code keyword="">function</code> <code plain="">Animal() { </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.mood = </code><code string="">''</code><code plain="">; </code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;</code><code plain="">} </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;</code><code keyword="">var</code> <code plain="">fluffy = </code><code keyword="">new</code> <code plain="">Animal(); </code></div> <div number6="" index5="" alt1=""><code spaces="">&nbsp;</code><code plain="">fluffy.mood = </code><code string="">'happy'</code><code plain="">; </code></div> <div number7="" index6="" alt2=""><code spaces="">&nbsp;</code><code plain="">fluffy.mood; </code><code comments="">// 返回 'happy</code></div></td></tr></tbody></table> <p>　　这次Animal类公开了一个叫mood的属性，可以被随意读写。同样地，你还可以将函数指定给公有的属性，例如之前例子中的getType函数。只是要注意不要给getType赋值，不然的话你会毁了它的。</p> <p><strong>　　完全私有</strong></p> <p>　　最后，可能你发现你需要一个完全私有化的本地变量。这样的话，你可以使用与第一个例子中一样的模式而不需要创建公有方法。</p> <p> </p>    <div> <div number1="" index0="" alt2=""><code color3="">function</code> <code plain="">Animal() { </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code variable="">var</code> <code plain="">secret = </code><code string="">"You'll never know!"</code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;</code><code plain="">} </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;</code><code variable="">var</code> <code plain="">fluffy = </code><code keyword="">new</code> <code plain="">Animal();</code></div></div></div><div><p><strong>　　2、写灵活的API</strong></p> <p>　　既然我们已经谈到类的创建，为了保持与产品需求变化同步，我们需要保持代码不过时。如果你已经做过某些项目或者是长期维护过某个产品，那么你就 应该知道需求是变化的。这是一个不争的事实。如果你不是这么想的话，那么你的代码在还没有写之前就将注定荒废。可能你突然就需要将选项卡中的内容弄成动画 形式，或是需要通过Ajax调用来获取数据。尽管准确预测未来是不大可能，但是却完全可以将代码写灵活以备将来不时之需。</p> <p><strong>　　&#9679; Saner参数列表</strong></p> <p>　　在设计参数列表的时候可以让代码有前瞻性。参数列表是让别人实现你代码的主要接触点，如果没有设计好的话，是会很有问题的。你应该避免下面这样的参数列表：</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <div> <div number1="" index0="" alt2=""><code keyword="">function</code> <code plain="">Person(employeeId, fname, lname, tel, fax, email, email2, dob) { </code></div> <div number2="" index1="" alt1=""><code plain="">};</code></div></div></td></tr></tbody></table> <p>　　这个类十分脆弱。如果在你发布代码后想要添加一个中间名参数，因为顺序问题，你不得不在列表的最后往上加。这让工作变得尴尬。如果你没有为每个参数赋值的话，将会十分困难。例如：</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td>var ara = new Person(1234, "Ara", "Pehlivanian", "514-555-1234", null, null, null, "1976-05-17"); </td></tr></tbody></table> <p>　　操作参数列表更整洁也更灵活的方式是使用这个模式：</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td>function Person(employeeId, data) { };</td></tr></tbody></table> <p>　　有第一个参数因为这是必需的。剩下的就混在对象的里面，这样才可以灵活运用。</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td> <div> <div number1="" index0="" alt2=""><code keyword="">var</code> <code plain="">ara = </code><code keyword="">new</code> <code plain="">Person(1234, { </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">fname: </code><code string="">"Ara"</code><code plain="">, </code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">lname: </code><code string="">"Pehlivanian"</code><code plain="">, </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">tel: </code><code string="">"514-555-1234"</code><code plain="">, </code></div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">dob: </code><code string="">"1976-05-17"</code></div> <div number6="" index5="" alt1=""><code spaces="">&nbsp;</code><code plain="">});</code></div></div></td></tr></tbody></table></td></tr></tbody></table> <p>　　这个模式的漂亮之处在于它即方便阅读又高度灵活。注意到fax, email和email2完全被忽略了。不仅如此，对象是没有特定顺序的，因此哪里方便就在哪里添加一个中间名参数是非常容易的：</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <div> <div number1="" index0="" alt2=""><code variable="">var</code> <code plain="">ara = </code><code keyword="">new</code> <code plain="">Person(</code><code value="">1234</code><code plain="">, { </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">fname: </code><code string="">"Ara"</code><code plain="">, </code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">mname: </code><code string="">"Chris"</code><code plain="">, </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">lname: </code><code string="">"Pehlivanian"</code><code plain="">, </code></div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">tel: </code><code string="">"514-555-1234"</code><code plain="">, </code></div> <div number6="" index5="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">dob: </code><code string="">"1976-05-17"</code></div> <div number7="" index6="" alt2=""><code spaces="">&nbsp;</code><code plain="">});</code></div></div></td></tr></tbody></table> <p>　　类里面的代码不重要，因为里面的值可以通过索引来访问：</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td>function Person(employeeId, data) {<br />&nbsp; this.fname = data['fname'];<br />&nbsp;};</td></tr></tbody></table> <p>　　如果data['fname'] 返回一个值，那么他就被设定好了。否则的话，没被设定好，也没有什么损失。</p></div><div><strong>　&#9679; 让代码可嵌入</strong> <p>　　随着时间流逝，产品需求可能对你类的行为有更多的要求。而该行为却与你类的核心功能没有半毛钱关系。也有可能是类的唯一一种实现，好比在一个选 项卡的面板获取另一个选项卡的外部数据时，将这个选项卡面板中的内容变灰。你可能想把这些功能放在类的里面，但是它们不属于那里。选项卡条的责任在于管理 选项卡。动画和获取数据是完全不同的两码事，也必须与选项卡条的代码分开。唯一一个让你的选项卡条不过时而又将那些额外的功能排除在外的方法是，允许将行 为嵌入到代码当中。换句话说，通过创建事件，让它们在你的代码中与关键时刻挂钩，例如onTabChange, afterTabChange,  onShowPanel,  afterShowPanel等等。那样的话，他们可以轻易地与你的onShowPanel事件挂钩，写一个将面板内容变灰的处理器，这样就皆大欢喜了。 JavaScript库让你可以足够容易地做到这一点，但是你自己写也不那么难。下面是使用YUI 3的一个例子。</p> <p> </p><table style="border-bottom: #999 1px solid; border-left: #999 1px solid; background-color: #dddddd; width: 98%; font-size: 12px; border-top: #999 1px solid; border-right: #999 1px solid" align="center"> <tbody> <tr> <td> <div number1="" index0="" alt2=""><code plain="">&lt;script type=</code><code string="">"text/javascript"</code> <code plain="">src=</code><code string="">"http://yui.yahooapis.com/combo?3.2.0/build/yui/yui-min.js"</code><code plain="">&gt;&lt;/script&gt; </code></div> <div number2="" index1="" alt1=""><code spaces="">&nbsp;</code><code plain="">&lt;script type=</code><code string="">"text/javascript"</code><code plain="">&gt; </code></div> <div number3="" index2="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">YUI().</code><code keyword="">use</code><code plain="">(</code><code string="">'event'</code><code plain="">, </code><code color3="">function</code> <code plain="">(Y) { </code></div> <div number4="" index3="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number5="" index4="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code color3="">function</code> <code plain="">TabStrip() { </code></div> <div number6="" index5="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.showPanel = </code><code color3="">function</code> <code plain="">() { </code></div> <div number7="" index6="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.fire(</code><code string="">'onShowPanel'</code><code plain="">); </code></div> <div number8="" index7="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number9="" index8="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">// 展现面板的代码 </code></div> <div number10="" index9="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number11="" index10="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code keyword="">this</code><code plain="">.fire(</code><code string="">'afterShowPanel'</code><code plain="">); </code></div> <div number12="" index11="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}; </code></div> <div number13="" index12="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}; </code></div> <div number14="" index13="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number15="" index14="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">// 让TabStrip有能力激发常用事件 </code></div> <div number16="" index15="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">Y.augment(TabStrip, Y.EventTarget); </code></div> <div number17="" index16="" alt2=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number18="" index17="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code variable="">var</code> <code plain="">ts = </code><code keyword="">new</code> <code plain="">TabStrip(); </code></div> <div number19="" index18="" alt2=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number20="" index19="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">// 给TabStrip的这个实例创建常用时间处理器 </code></div> <div number21="" index20="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">ts.on(</code><code string="">'onShowPanel'</code><code plain="">, </code><code color3="">function</code> <code plain="">() { </code></div> <div number22="" index21="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">//在展示面板之前要做的事 </code></div> <div number23="" index22="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}); </code></div> <div number24="" index23="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">ts.on(</code><code string="">'onShowPanel'</code><code plain="">, </code><code color3="">function</code> <code plain="">() { </code></div> <div number25="" index24="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">//在展示面板之前要做的其他事 </code></div> <div number26="" index25="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}); </code></div> <div number27="" index26="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">ts.on(</code><code string="">'afterShowPanel'</code><code plain="">, </code><code color3="">function</code> <code plain="">() { </code></div> <div number28="" index27="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code comments="">//在展示面板之后要做的事 </code></div> <div number29="" index28="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">}); </code></div> <div number30="" index29="" alt1=""><code spaces="">&nbsp;</code>&nbsp;</div> <div number31="" index30="" alt2=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">ts.showPanel(); </code></div> <div number32="" index31="" alt1=""><code spaces="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code plain="">});</code></div></td></tr></tbody></table> <p>　　这个例子有一个简单的 TabStrip  类，其中有个showPanel方法。这个方法激发两个事件，onShowPanel和afterShowPanel。这个能力是通过用 Y.EventTarget扩大类来实现的。一旦做成，我们就实例化了一个TabStrip对象，并将一堆处理器都分配给它。这是用来处理实例的唯一行为 而又能避免混乱当前类的常用代码。</p> <p><strong>　　总结</strong></p> <p>　　如果你打算重用代码，无论是在同一网页，同一网站还是跨项目操作，考虑一下在类里面将其打包和组织起来。面向对象JavaScript很自然地 帮助实现更好的代码组织以及代码重用。除此以外，有点远见的你可以确保代码具有足够的灵活性，可以在你写完代码后持续使用很长时间。编写可重用的不过时 JavaScript代码可以节省你，你的团队还有你公司的时间和金钱。这绝对能让你大受欢迎。</p></div><img src ="http://www.blogjava.net/qileilove/aggbug/376930.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2012-04-28 10:17 <a href="http://www.blogjava.net/qileilove/archive/2012/04/28/376930.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>深入了解HTML5</title><link>http://www.blogjava.net/qileilove/archive/2011/11/18/364194.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Fri, 18 Nov 2011 02:11:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2011/11/18/364194.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/364194.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2011/11/18/364194.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/364194.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/364194.html</trackback:ping><description><![CDATA[<div><a href="http://www.comsharp.com/GetKnowledge/zh-CN/It_News_K701.aspx">http://www.comsharp.com/GetKnowledge/zh-CN/It_News_K701.aspx</a></div><img src ="http://www.blogjava.net/qileilove/aggbug/364194.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2011-11-18 10:11 <a href="http://www.blogjava.net/qileilove/archive/2011/11/18/364194.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>再来 10 个新鲜的 HTML5 教程</title><link>http://www.blogjava.net/qileilove/archive/2011/11/15/363884.html</link><dc:creator>顺其自然EVO</dc:creator><author>顺其自然EVO</author><pubDate>Tue, 15 Nov 2011 15:46:00 GMT</pubDate><guid>http://www.blogjava.net/qileilove/archive/2011/11/15/363884.html</guid><wfw:comment>http://www.blogjava.net/qileilove/comments/363884.html</wfw:comment><comments>http://www.blogjava.net/qileilove/archive/2011/11/15/363884.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/qileilove/comments/commentRss/363884.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/qileilove/services/trackbacks/363884.html</trackback:ping><description><![CDATA[<div><div id="OSChina_News_23168" textcontent=""  newstype2"="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 24px; font-size: 10.5pt; overflow-x: hidden; overflow-y: hidden; font-family: Verdana, Simsun, sans-serif; text-align: left; background-color: #ffffff; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">HTML5 火吗？看看 oschina 三天两头的 xx 个 xxx 就知道了。本文为你推荐最新的 10 个 HTML5 相关的教程，或许能启发你项目中的思路。</p><hr style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><h3><a rel="nofollow" href="http://www.script-tutorials.com/html5-canvas-creating-your-own-paint-program/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">1. HTML5 canvas &#8211; Creating own Paint program</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">Canvas 是 HTML5 里非常重要的一部分，特别是在游戏开发中必不可少。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132100_BX7o.jpg" alt="HTML5 canvas &#8211; Creating own Paint program" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://aerotwist.com/lab/creating-particles-with-three-js/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">2. Creating Particles with Three.js</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">此教程中介绍如何使用&nbsp;<a href="http://www.oschina.net/p/threejs" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">Three.js</a>&nbsp;这个 js 三位模型库。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132114_5kRC.jpg" alt="Creating Particles with Three.js" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://tutorialzine.com/2011/06/beautiful-portfolio-html5-jquery/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">3. Making a Beautiful HTML5 Portfolio</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">讲述如何使用 HTML5 创建 Web 相册，基于&nbsp;<a href="http://www.oschina.net/p/jquery" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">jQuery</a>&nbsp;和&nbsp;<a href="http://www.oschina.net/p/quicksand" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">Quicksand</a>&nbsp;插件。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132127_hmkD.jpg" alt="Making a Beautiful HTML5 Portfolio" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://tympanus.net/codrops/2011/11/09/interactive-html5-typography/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">4. Interactive Typography Effects with HTML5</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">如果你想创建自己的交互式banner，那就阅读这篇文章吧<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132135_UJKf.jpg" alt="Interactive Typography Effects with HTML5" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://www.html5rocks.com/en/tutorials/webaudio/intro/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">5. Getting Started with Web Audio API</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">HTML5 的 Web Audio API 入门<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132144_1OTE.jpg" alt="Getting Started with Web Audio API" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://www.netmagazine.com/tutorials/create-mobile-version-snake-html5-canvas-and-javascript" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">6. Mobile Snake</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">创建一个移动版的贪吃蛇，使用 HTML5 Canvas 和 JavaScript 技术<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132150_CqIp.jpg" alt="Mobile Snake" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://thinkvitamin.com/code/html5/create-vector-masks-using-the-html5-canvas/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">7. Create Vector Masks using the HTML5 Canvas</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">创建非规则的图像<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132152_LxRf.jpg" alt="Create Vector Masks using the HTML5 Canvas" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">8. Create a Drawing App with HTML5 Canvas and JavaScript</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">使用 HTML5 Canvas 创建一个画图程序<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132154_91GJ.jpg" alt="Create a Drawing App with HTML5 Canvas and JavaScript" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://blogs.msdn.com/b/eternalcoding/archive/2011/06/13/html-5-vs-silverlight-5.aspx" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">9. HTML 5 &amp; Silverlight 5</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">展示 HTML5 和 Sliverlight 5 技术<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132200_Ni1B.jpg" alt="HTML 5 &amp; Silverlight 5" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p><h3><a rel="nofollow" href="http://www.lostdecadegames.com/how-to-make-a-simple-html5-canvas-game/" target="_blank" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">10. How to make a simple HTML5 Canvas game</a></h3><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; text-indent: 2em; ">开发一个简单的 HTML5 Canvas 游戏<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><img src="http://static.oschina.net/uploads/img/201111/15132207_0rHo.jpg" alt="How to make a simple HTML5 Canvas game" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 600px; " /></p></div><div style="padding-top: 3px; padding-bottom: 3px; padding-left: 10px; margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; text-align: left; color: #666666; font-size: 13px; line-height: 22px; border-left-width: 10px; border-left-style: solid; border-left-color: #ccffcc; font-family: Verdana, Simsun, sans-serif; ">本站文章除注明转载外，均为本站原创或编译<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " />欢迎任何形式的转载，但请务必注明出处，尊重他人劳动共创开源社区<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " />转载请注明：文章转载自：<strong style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">开源中国社区</strong>&nbsp;[<a href="http://www.oschina.net/" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #333333; outline-width: 0px; outline-style: initial; outline-color: initial; ">http://www.oschina.net</a>]<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " />本文标题：再来 10 个新鲜的 HTML5 教程<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " />本文地址：<a href="http://www.oschina.net/news/23168/10-fresh-html5-tutorials" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #333333; outline-width: 0px; outline-style: initial; outline-color: initial; ">http://www.oschina.net/news/23168/10-fresh-html5-tutorials</a><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /><span id="attention_it2" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://www.oschina.net/news/23168/10-fresh-html5-tutorials" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #3e62a6; outline-width: 0px; outline-style: initial; outline-color: initial; ">收藏此资讯</a></span></div></div><img src ="http://www.blogjava.net/qileilove/aggbug/363884.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/qileilove/" target="_blank">顺其自然EVO</a> 2011-11-15 23:46 <a href="http://www.blogjava.net/qileilove/archive/2011/11/15/363884.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>