﻿<?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-java神谕-随笔分类-Javascript</title><link>http://www.blogjava.net/javaora/category/6993.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 14:48:29 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 14:48:29 GMT</pubDate><ttl>60</ttl><item><title>Framework 与Library 和Tookit的区别</title><link>http://www.blogjava.net/javaora/archive/2006/05/05/44623.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Fri, 05 May 2006 05:22:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/05/05/44623.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/44623.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/05/05/44623.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/44623.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/44623.html</trackback:ping><description><![CDATA[
		<h2>Framework（框架）</h2>
		<p>In software development, a framework is a defined
support structure in which other project can be organized and
developed. A framework typically consists of several smaller
components; support programs, libraries, and a scripting language.
There may also be other software involved to aid in development and
meshing of the different components of a project. As you can see, dojo
could be part of a framework, but it isn't a framework in itself.<br /></p>
		<p>在软件开发中，一个框架是一个被定义的支持结构，在其中其他项目可以被组织和开发。一个框架代表性地包含需要小的组件、支持程序、类库、和一个脚本
语言。这些也可能是其他软件包括帮助开发和不同的项目组件编制。如你看到的，dojo可能是框架的一部分，但是本质上它本身不是一个框架。<br /></p>
		<h2>Library（库）</h2>
		<p>A
library is defined as a collection of related functions and subroutines
used to develop software. They are distinguished from executables in
that they are not independant programs; rather, they are "helper" code
that provide access to common functions in one easy to manage location.
After reading this you are probably saying, "Hey! dojo is a collection
of libraries!", and you would be correct; however, dojo is much more
than just a collection of libraries.<br />
库被定义为一个相关功能和被用来开发软件的子程序的集合。他们区别于执行，在其中他们不是独立的程序；更适合的，他们是“助手”代码，用来支持通过通用
成为一体的功能容易来进行管理。在读完这些，你可能说，“嗨！dojo是一个库的集合”，你可能是正确的，然而，dojo不仅仅是做为一个库的集合。<br /></p>
		<h2>Toolkit（工具）</h2>
		<p>Now on to
toolkits. A toolkit is generally used in reference to graphical user
interface (GUI) toolkits. Basically, a library that is mainly focused
on creating a GUI. Yes, dojo could also fall under this category, in
fact our name implies it. Why do we call dojo a toolkit? Certainly not
because it focuses mainly on GUI development, right? Well quite simply,
because dojo is so much more than just a collection of libraries.<br /></p>
		<p>现在说说toolkits.
一个工具通常被用在参考图形用户界面工具。基础地，一个类库主要集中在创建一个GUI。是地，dojo可被归入这个类别，实际上我们命名暗示了它，为什么
我们叫dojo是一个工具？当然不是因为它主要集中在GUI开发，正确么？很好，其实很简单，因为pojo不仅仅是一个库的集合。<br /></p>
<img src ="http://www.blogjava.net/javaora/aggbug/44623.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-05-05 13:22 <a href="http://www.blogjava.net/javaora/archive/2006/05/05/44623.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>What is dojo 什么是Dojo</title><link>http://www.blogjava.net/javaora/archive/2006/05/05/44594.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Fri, 05 May 2006 03:29:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/05/05/44594.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/44594.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/05/05/44594.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/44594.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/44594.html</trackback:ping><description><![CDATA[
		<p>
				<a href="http://dojotoolkit.org/">Dojo</a> is an Open Source DHTML toolkit written in <a href="http://dojo.jot.com/WikiHome/JavaScript" class="wikiLink">JavaScript</a>. It builds on several contributed code bases (<a aiotitle="nWidgets" href="http://nwidgets.org/">nWidgets</a>, <a href="http://burstproject.org/">Burstlib</a>, <a href="http://fm.dept-z.com/">f(m)</a>), which is why we refer to it sometimes as a "unified" toolkit. Dojo aims to solve some long-standing <a href="http://dojo.jot.com/WikiHome/historical+problems+with+DHTML" class="wikiLink">historical problems with DHTML</a> which prevented mass adoption of dynamic web application development.<br /></p>
		<p>   
Dojo是一个使用Javascript编写的开源DHTML工具。它建立于很多已捐献的代码基础（nWidgets、Burstlib、f(m)）,这
是为什么我们谈到它有时是一个"统一"的工具。Dojo致力于解决一些长期存在的伴随DHTML的历史问题，趟阻止大多数采用动态web应用程序开发。<br /><br /></p>
		<p>Dojo allows you to easily build dynamic capabilities into web pages and any other environment that supports <a href="http://dojo.jot.com/WikiHome/JavaScript" class="wikiLink">JavaScript</a>
sanely. You can use the components that Dojo provides to make your web
sites more useable, responsive, and functional  With Dojo you can build
degradeable user interfaces more easily, prototype interactive widgets
quickly, and animate transitions.  You can use the lower-level APIs and
compatibility layers from Dojo to write portable <a href="http://dojo.jot.com/WikiHome/JavaScript" class="wikiLink">JavaScript</a>
and simplify complex scripts. Dojo's event system, I/O APIs, and
generic language enhancement form the basis of a powerful programming
environment. You can use the Dojo build tools to write command-line
unit-tests for your <a href="http://dojo.jot.com/WikiHome/JavaScript" class="wikiLink">JavaScript</a>
code.  You can use the Dojo package system to make your code easier to
maintain and less platform dependent.  The Dojo build process helps you
optimize your <a href="http://dojo.jot.com/WikiHome/JavaScript" class="wikiLink">JavaScript</a> for deployment by grouping sets of files together and reuse those groups through "profiles". <br /></p>
		<p>Dojo允许你容易地建立动态性能到web页面和其他稳健支持javascript地环境中。.你可以使用Dojo支持组件，它使你的web站点更有可用行的。伴随dojo,你可以更容易地建立degradeable用户界面，迅速地原型交互饰件和动画转变。你可以使用底层地api和兼容层，从Dojo到写轻便的Javascript和简单复杂教本。Dojo的事件系统，I/O api,和泛型语言增强组成强大的程序环境的基础。 你可以使用dojo建造工具来为你的Javascript代码写命令行单元测试。你可以使用Dojo 包系统来使得你的代码更容易去维护和更少平台依赖。 Dojo建造过程帮助你优化你的Javascript为你的部署，它通过一起分组文件集合和通过"profile"重用这些组。 </p>
		<p>Dojo
does all of these things by layering capabilities onto a very small
core which provides the package system and little else. When you write
scripts with Dojo, you can include as little or as much of the
available APIs as you need to suit your needs. Dojo provides <a href="http://dojo.jot.com/WikiHome/MultiplePointsOfEntry" class="wikiLink">MultiplePointsOfEntry</a>, <a href="http://dojo.jot.com/WikiHome/InterpreterIndependence" class="wikiLink">InterpreterIndependence</a>, <a href="http://dojo.jot.com/WikiHome/ForwardLookingAPIs" class="wikiLink">ForwardLookingAPIs</a>, and focuses on <a href="http://dojo.jot.com/WikiHome/ReducingBarriersToAdoption" class="wikiLink">ReducingBarriersToAdoption</a>.<br /></p>
		<p>Dojo处理所有这些事情，通过分层能力分解成一些非常小的和核心，它支持包系统和其他更少的。单你写是使用Dojo写脚本，你可以包含作为很少或
者同样多可用的api作为你需要满足你的需要的。Dojo支持MutiplePointsOfEntry,
InterprerterIndependence, ForwardLookingAPIs,
和集中ReducingBarriersToAdoption.<br /></p>
		<p>Dojo
is being built around a single markup language that will provide
application authors with a (more) simple way of declaring and using
responsive DHTML interface components. Renderings may be made available
in several rendering contexts (such as SVG, or perhaps even the desktop
or Flash), but the markup language (<a href="http://dojo.jot.com/WikiHome/DojoML" class="wikiLink">DojoML</a>) and scripting language (JavaScript) will not change. Better yet, the <a href="http://dojo.jot.com/WikiHome/DojoML" class="wikiLink">DojoML</a> parser accepts extended HTML and SVG as valid input, and can be used to easily create <a href="http://dojo.jot.com/WikiHome/DegradeableResponsiveApplications" class="wikiLink">DegradeableResponsiveApplications</a>.<br /></p>
		<p>Dojo是一个被建造在一个单一的标记语言，它将支持应用程序作者采用一个（多个）简单方法来声明和使用作出响应的DHTML界面组件。表现在许多表现上下文(例
如：SVG，或甚至可能桌面或flash)可能被合法化,但是标记语言(DojoML)和脚本语言（Javascript）将不改变。然而更好的，
DojoML
解析器接受已扩展的HTML和SVG作为一个合法的输入，并且可以被容易的创建DegradeableResponsiveApplications.<br /></p>
<img src ="http://www.blogjava.net/javaora/aggbug/44594.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-05-05 11:29 <a href="http://www.blogjava.net/javaora/archive/2006/05/05/44594.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEC 4.1新增的几个功能</title><link>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Wed, 19 Apr 2006 14:35:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/42016.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/04/19/42016.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/42016.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/42016.html</trackback:ping><description><![CDATA[1.增加了一个图形编辑器。呵呵～～，以后简单的东西，在Eclipse中就可以编辑了！<br />2.Spring和Hibernate的自动集成<br />3.Jsp Editor，其实这个东西，我们一般是不做使用的。以前的版本出现的经常性打开很慢的情况。<br />4.UML图形<br />5.Javascript<img src ="http://www.blogjava.net/javaora/aggbug/42016.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-04-19 22:35 <a href="http://www.blogjava.net/javaora/archive/2006/04/19/42016.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MyEclipse JavaScript Debugger (MyEclipse javascript 调试器)</title><link>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Wed, 19 Apr 2006 14:24:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/42014.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/04/19/42014.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/42014.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/42014.html</trackback:ping><description><![CDATA[
		<p>The MyEclipse JavaScript Debugger is the first fully integrated client-side Eclipse debugger for JavaScript. Feature highlights include: <br />MyEc Javascript 调试器试首个为Javascript。完整集成客户端Eclipse调试器。特征主要包含：</p>
		<ul>
				<li>Debug any web page containing JavaScript source or included JavaScript files, or standalone JavaScript files 
</li>
				<li>调试任何web页面包含Javascript 源代码或包含Javascript 文件，或者单独的Javascript文件
</li>
				<li>Operations: Pause, Resume, Step Into, Step Over, Step to Return, Terminate 
</li>
				<li>操作：暂停、重新开始、进入、跳出、跳入返回、终止
</li>
				<li>Views: 视图
<ul><li>Web Browser View (web 浏览器视图)
</li><li>Call Stack View  （呼叫堆栈视图）
</li><li>Variables View (变量视图)
</li><li>Console View  （控制台视图）</li></ul></li>
				<li>Set JavaScript breakpoints in: 设置javascript断点
<ul><li>JavaScript files (Javascript文件)
</li><li>HTML with embedded JavaScript and linked JavaScript files （包含内置的javascript和关联的javascript文件的HTML）
</li><li>JSP files (jsp 文件)
</li><li>Conditional breakpoints planned for MyEclipse 4.1.1 （为MyEC的有条件的断点计划）</li></ul></li>
				<li>Integrates with Eclipse Launch Manager （集成Eclipse发行管理器）
<ul><li>Quick launch from context-menu using "Debug As" (使用Debug As 迅速调用上下文按钮)
</li><li>Launch from Eclipse Debug toolbar action （从Eclipse 调试工具条行为中调用）
</li><li>Use Launch Profile to modify launch configuration （）
</li><li>Launch JavaScript resource from project location or deployed MyEclipse web-application </li></ul></li>
		</ul>
<img src ="http://www.blogjava.net/javaora/aggbug/42014.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-04-19 22:24 <a href="http://www.blogjava.net/javaora/archive/2006/04/19/42014.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>10条通向快速Web 站点现实的步骤</title><link>http://www.blogjava.net/javaora/archive/2006/02/11/30257.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sat, 11 Feb 2006 05:48:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/02/11/30257.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/30257.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/02/11/30257.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/30257.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/30257.html</trackback:ping><description><![CDATA[10条通向快速Web 站点现实的步骤<BR>1.确定瓶颈<BR>&nbsp;1.1文件大小<BR>&nbsp;&nbsp; 在需要使用这个页面时用户需要加载多少数据。、<BR>&nbsp;&nbsp; 60-100K 页面大小 保持教小的文件<BR>&nbsp;1.2反应时间<BR>&nbsp;&nbsp; 你向服务器发送请求和数据到达PC的时间间隔<BR>&nbsp;&nbsp; 网络反应时间<BR>2.减少文件大小<BR>&nbsp; 100K以上 <BR>&nbsp; 大量的文件当前主要是由巨大的Javascript类库。<BR>&nbsp; 巨大的图片<BR>&nbsp; 老的HTML样式也会产生大文件，尽可能地使用XHTML和CSS<BR>&nbsp; 压缩<BR>3.查找什么导致了很高的反应<BR>&nbsp; 如上我们所提到的，反应时间主要由两个主要的元素<BR>&nbsp; 3.1网络反应时间<BR>&nbsp; 3.2是否花费了太长的时间来产生页面<BR>&nbsp; 3.3性能<BR>4.确定绝缘组件<BR>5.编译缓存<BR>6.查看DB查询<BR>&nbsp; 避免join. 查询缓存<BR>7.发送正确的已修改数据<BR>8.考虑组件缓存<BR>9.减少服务加载<BR>&nbsp; 9.1使用相反的代理<BR>&nbsp; 9.2采用轻量级的HTTP服务器<BR>10. 增加服务器<BR><img src ="http://www.blogjava.net/javaora/aggbug/30257.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-02-11 13:48 <a href="http://www.blogjava.net/javaora/archive/2006/02/11/30257.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ten good practices for writing JavaScript in 2005</title><link>http://www.blogjava.net/javaora/archive/2006/02/08/29976.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Wed, 08 Feb 2006 15:06:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/02/08/29976.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/29976.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/02/08/29976.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/29976.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/29976.html</trackback:ping><description><![CDATA[<H1>原文地址：<A href="http://www.bobbyvandersluis.com/articles/goodpractices.php">http://www.bobbyvandersluis.com/articles/goodpractices.php</A></H1>
<H1>Ten good practices for writing JavaScript in 2005</H1>
<H3>1. Make sure your JavaScript code is in balance with its environment</H3>
<P>Web Standards are a <A href="http://www.happycog.com/mov/"><FONT color=#cc0000>three-legged stool</FONT></A>, or without metaphors(暗喻), a threesome（三人一组） of technologies that should live together in harmony（和睦相处）. (X)HTML adds structure and semantics to your content, CSS is responsible for （为...负责）its presentation, and the DOM provides an interface to add behavior. You keep your Web pages flexible (or: easier to understand, maintain, restyle&lt;改变样式&gt; and update behavior) by separating all three layers; structure and content from presentation, <A href="http://www.digital-web.com/articles/separating_behavior_and_structure_2/"><FONT color=#cc0000>structure and content from behavior</FONT></A> and presentation from behavior. To accomplish this, try to avoid inline behavior and use <A href="http://www.kryogenix.org/code/browser/aqlists/"><FONT color=#cc0000>unobtrusive techniques</FONT></A> instead.<BR><BR>主要表述了三种技术的综合使用，html为细节结构和语法 css为表现负责&nbsp; dom支持增加事件行为的接口。</P>
<P>When you attach behavior on page load, you may have to work around some known issues. First, you may encounter <A href="http://www.scottandrew.com/weblog/articles/cbs-events"><FONT color=#cc0000>differences in cross-browser event handling</FONT></A>. Second, make sure you don't <A href="http://simon.incutio.com/archive/2004/05/26/addLoadEvent"><FONT color=#cc0000>overwrite existing onload handlers</FONT></A>. Last, but not least, you may encounter a delay in the attachment of your behavior. The underlying （潜在的）problem is that a window onload event will only execute after the whole document, including all page assets like images and objects, is loaded. If your script needs to respond immediately after an element has loaded or if you work with a lot of content, a series of images or a slow server, you may be forced to look for a solution. You can either <A href="http://www.bobbyvandersluis.com/articles/unobtrusiveshowhide.php"><FONT color=#cc0000>hide your content until the behavior is attached</FONT></A> or attach the behavior via a script call after your elements are loaded, like at the end of the body element.<BR>介绍在页面开发中主要遇到的问题！</P>
<P>Choose your markup wisely, so you can take full advantage of the power of the DOM.&lt;充分利用dom的力量&gt; For example, when you use nested lists to build a navigation bar, you can use the structure of the DOM tree instead of a replicated(复制) structure in arrays.&lt;list dom tree&gt; Scripting should be avoided in some cases where you can use markup or CSS to create behavior. This may sound a bit contradictory(反对), however built-in behavior enabled by (X)HTML attributes (e.g. disabling a form field or setting a max length on an input field) and CSS <A href="http://www.w3.org/TR/CSS21/selector.html#pseudo-elements"><FONT color=#cc0000>pseudo-classes</FONT></A> (e.g. when building <A href="http://www.alistapart.com/articles/rollovers/"><FONT color=#cc0000>rollovers</FONT></A> or <A href="http://www.alistapart.com/articles/dropdowns"><FONT color=#cc0000>drop downs</FONT></A>) are regarded to be wider supported and easier to implement than using JavaScript. <A href="http://www.quirksmode.org/blog/archives/2005/04/toughquiz_ii.html"><FONT color=#cc0000>ToughQuiz on Quirksmode</FONT></A> illustrates the discussion and the fine line between the uses of CSS <A href="http://www.w3.org/TR/CSS21/generate.html"><FONT color=#cc0000>generated content</FONT></A> and regular markup and behavior.</P>
<P>In those cases where CSS currently lacks&lt;缺乏&gt; cross-browser support or is missing features for adding presentation, DOM based scripting can supplement&lt;补充&gt; CSS. <A href="http://www.bobbyvandersluis.com/articles/presentationaljavascript.php"><FONT color=#cc0000>Presentational scripting</FONT></A> will probably be replaced in a few years, when browsers have better CSS2.1 compliance&lt;顺从&gt; and with the support of CSS3. Please realize that, because of the interrelationship&lt;相互影响&gt; of the different Web Standards and because both Web Standards and Web clients are constantly evolving&lt;进化&gt;, some good practices for using the DOM and JavaScript will change over time&lt;随着时间的过去&gt;.</P>
<H3>2. Create accessible&lt;可理解的、易受影响的&gt; JavaScript</H3>
<P>JavaScript is accessible when a page's navigation, content and main functionality (e.g. submitting a form) is available to your whole target audience, independent of their Web client or input device. This includes:</P>
<UL>
<LI>People who use assistive&lt;帮助&gt; technologies, like screen readers 
<LI>People who don't use a mouse for navigation 
<LI>People who have no JavaScript support (e.g. some mobile clients), have JavaScript disabled, or have partial&lt;部分的&gt; DOM or JavaScript support 
<LI>Machines, like search engines </LI></UL>
<P>The most common way to create accessible JavaScript is to use <A href="http://www.onlinetools.org/articles/unobtrusivejavascript/"><FONT color=#cc0000>unobtrusive techniques</FONT></A> that are mouse independent and <A href="http://www.sitepoint.com/article/structural-markup-javascript/"><FONT color=#cc0000>enhance your already accessible markup</FONT></A> with behavior. <A href="http://hesketh.com/publications/progressive_enhancement_paving_way_for_future.html"><FONT color=#cc0000>Progressive enhancement</FONT></A> and its predecessor <A href="http://webtips.dan.info/graceful.html"><FONT color=#cc0000>graceful degradation</FONT></A> are good strategies to create Web pages that are accessible to the most common denominator, while providing a better user experience for a smaller group of people with more advanced devices or Web clients. No matter what strategy you use, make sure that you always design for multiple scenarios.</P>
<H3>3. Create usable（便于使用的） JavaScript</H3>
<P>The usability of a Web page is often determined by a good information architecture, clear and intuitive(直觉的) visual design and well designed functionality. One of the main arguments to enhance your markup using unobtrusive JavaScript is to improve the usability of a Web page by supporting these usability attributes. If you add JavaScript and don't enhance the usability of a Web page, you should rethink if you should apply it at all.</P>
<H3>4. Create easy applicable（可适用的） JavaScript</H3>
<P>Unobtrusive scripting bridges the gap between 'designers' and 'coders'. There is a big group of people in today's industry that does know how to write (X)HTML and CSS but doesn't feel very comfortable with the DOM and JavaScript. Unobtrusive behavior introduced a mechanism to easily apply small portable scripts to a Web page: "Just make sure your markup looks like A, include this script B, and as a result you have a page that can do C".</P>
<P>Try to create small pieces of independent code. The disadvantages of a lot of existing JavaScript code libraries are that you often have to include a lot more code than you really need and that they are harder to understand and maintain if you didn't create them yourself. Because the functions in these libraries are often grouped and reused by other scripts, it often feels like they are spaghetti-coded. A library with small unobtrusive scripts has the advantage of being light-weight, easy to be understood and easy to be adjusted for more specific implementations.</P>
<P>Create reusable code. If you find yourself duplicating code snippets(片段), create functions. If you find yourself duplicating(复制) similar code snippets, try to abstract your code to the level that you can reuse it for multiple purposes.</P>
<P>Document your code well. If you work together with other people, like to share your code with others, or still want to know why you did certain things one year from now, good documentation is key.</P>
<H3>5. Create future-proof JavaScript</H3>
<P>Avoid browser detection, because it is almost impossible to maintain in the future. Feature testing or <A href="http://developer.apple.com/internet/webcontent/objectdetection.html"><FONT color=#cc0000>object detection</FONT></A> offers a browser independent and future-proof technique to test to what extent your Web client supports JavaScript.</P>
<P>XHTML (if not used in backwards-compatible mode) introduces media type application/xhtml+xml (currently unsupported by Internet Explorer), which has a huge impact on how we write JavaScript code:</P>
<UL>
<LI>The HTML DOM is case-insensitive, <A href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-5353782642"><FONT color=#cc0000>the XML DOM is case-sensitive</FONT></A> (区分大小写)
<LI>Elements need to be referenced in <STRONG>lowercase</STRONG>, e.g. document.getElementsByTagName("p") 
<LI>document.body is deprecated, instead reference it by id or use document.getElementsByTagName("body").item(0) 
<LI>Collections like document.images, document.applets, document.links, document.forms and document.anchors <A href="http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html"><FONT color=#cc0000>do not exist when serving XHTML as XML</FONT></A>, instead use <STRONG>document.getElementsByTagName()</STRONG> 
<LI><A href="http://www.quirksmode.org/bugreports/archives/2004/11/innerhtml_in_xh.html"><FONT color=#cc0000>innerHTML</FONT></A> and <A href="http://ln.hixie.ch/?start=1091626816&amp;count=1"><FONT color=#cc0000>document.write</FONT></A> cannot be used anymore, instead <STRONG>use DOM methods</STRONG>, e.g. document.createElementNS("http://www.w3.org/1999/xhtml", "div") </LI></UL>
<P>If you want to keep yourself up-to-date with the latest developments, there are a lot of initiatives from different organisations that will impact the ways we use JavaScript and the DOM in the near future:</P>
<UL>
<LI><A href="http://www.w3c.org/"><FONT color=#cc0000>W3C</FONT></A> 
<UL>
<LI><A href="http://www.w3.org/DOM/"><FONT color=#cc0000>DOM 3</FONT></A> provides further XML and XPath integration 
<LI><A href="http://www.w3.org/TR/2004/WD-xhtml2-20040722/"><FONT color=#cc0000>XHTML 2</FONT></A> includes <A href="http://www.w3.org/TR/xml-events/"><FONT color=#cc0000>XML Events</FONT></A>, which introduces a declarative way to hook up event observers via markup, and <A href="http://www.w3.org/TR/2003/REC-xforms-20031014/"><FONT color=#cc0000>XForms</FONT></A>, which will change the way how we add behavior to forms 
<LI><A href="http://www.w3.org/Style/CSS/current-work"><FONT color=#cc0000>CSS3</FONT></A> introduces new <A href="http://www.w3.org/TR/2003/WD-css3-content-20030514/"><FONT color=#cc0000>pseudo-elements</FONT></A> </LI></UL>
<LI><A href="http://www.ecma-international.org/"><FONT color=#cc0000>ECMA</FONT></A> 
<UL>
<LI><A href="http://www.ecma-international.org/publications/standards/Ecma-357.htm"><FONT color=#cc0000>ECMAScript for XML (E4X)</FONT></A> offers a set of programming language extensions adding native XML support to ECMAScript 
<LI><A href="http://www.mozilla.org/js/language/es4/"><FONT color=#cc0000>ECMAScript 4</FONT></A> makes ECMA based languages (like <A href="http://www.mozilla.org/js/language/js20/"><FONT color=#cc0000>JavaScript 2</FONT></A> and <A href="http://www.macromedia.com/devnet/mx/flash/actionscript/actionscript02.html"><FONT color=#cc0000>ActionScript 2</FONT></A>) suitable for writing modular and object-oriented applications </LI></UL>
<LI>Browser vendors 
<UL>
<LI>Standards support, e.g. at the moment it is still a big question if Microsoft will ever fully support existing Web Standards and is going to support future standards 
<LI>The addition of proprietary methods and attributes, e.g. innerHTML, Microsoft.XMLHTTP and XMLHttpRequest 
<LI>Collaborations like the <A href="http://whatwg.org/"><FONT color=#cc0000>WHAT WG</FONT></A> aimed to create new standards in shorter timeframes, e.g. the submission of <A href="http://www.w3.org/Submission/2005/SUBM-web-forms2-20050411/"><FONT color=#cc0000>Web Forms 2</FONT></A> to become a W3C recommendation and <A href="http://whatwg.org/specs/web-apps/current-work/"><FONT color=#cc0000>Web Applications</FONT></A>, which in the future may standardise XMLHttpRequest </LI></UL></LI></UL>
<H3>6. Know JavaScript's weaknesses(弱点), limitations（限制） and bugs</H3>
<P>Although JavaScript is generally well supported by most modern Web clients, support still remains its biggest weakness. Because from the first days of the Web users were often harassed(疲倦的) by all kinds of annoying(讨厌的) behavior, browser makers decided to make it easy to switch JavaScript off (Windows XP Service Pack 2 even disables some JavaScript by default, because it regards it as active scripting). If you compare JavaScript with its little stepbrother ActionScript (which is supported when the Flash plug-in is installed and cannot be switched off), you will find that the main difference is that you can rely on its behavior to accomplish certain tasks. Because it is just too easy to switch JavaScript off, simple tasks like form validation always need to be duplicated at the server side. It will be for this reason that in the future most client-side form validation will be replaced by markup and 'built-in behavior'.</P>
<P>As mentioned earlier, the onload event handler is insufficient to get the best out of unobtrusive techniques. I hope that the people of the W3C will respond to this feedback from the JavaScript community and add new handlers like onElementLoad and onDOMLoad to future DOM specifications.</P>
<P>The JavaScript implementations of Internet Explorer and Safari suffer from <A href="http://javascript.weblogsinc.com/entry/1234000267034921/"><FONT color=#cc0000>memory leaks</FONT></A> when using <A href="http://www.sitepoint.com/blog-post-view.php?id=171578"><FONT color=#cc0000>circular references like closures</FONT></A>. When using circular references, make sure you <A href="http://novemberborn.net/javascript/event-cache"><FONT color=#cc0000>remove event handlers when a page is unloaded</FONT></A>.</P>
<H3>7. Often there is more than one good solution</H3>
<P>JavaScript is a very flexible language and as a result you often have multiple ways of doing things. You could choose for either a procedural(程序上) or an object oriented way of coding. For your unobtrusive behavior you can either use <A href="http://www.alistapart.com/articles/scripttriggers/"><FONT color=#cc0000>custom attributes or use class attributes as triggers</FONT></A> to fully control the behavior of your site. Flexibility implies that you have to make certain choices, however often one solution is not necessarily better or worse than another. Base your decisions on the context in which you have to use your scripts and your own philosophy or taste and try to use a consistent coding style.</P>
<H3>8. Write your own scripts or reuse code from trusted places</H3>
<P>Currently a lot of outdated(过期的) and badly written code is available on the Internet. Many scripts are plagued by browser detection, are using proprietary features that don't work cross-browser, are inaccessible or are not separating behavior from structure, because they rely on inline event handlers and scripts. It seems that Web Standards, Web clients and the practice of writing good JavaScript have evolved so quickly in the past two years, that it is hard to keep up with the latest good practices. This on its turn makes it hard to reuse code from others or reuse code you wrote yourself a year ago. Because some parts of older scripts may still contain valid code constructs, it is best to review them and rewrite the parts that don't suffice anymore. You will probably often find that a complete rewrite will do best.</P>
<P>So how do less experienced DOM and JavaScript users tell the difference between good and bad code on the Internet? There are some experts on the Internet that advocate modern ways of scripting and there are communities that discuss and rate new scripts and techniques. Some examples are:</P>
<UL>
<LI><A href="http://www.sitepoint.com/blog-view.php?blogid=5"><FONT color=#cc0000>DHTML &amp; CSS Blog: Stylish Scripting</FONT></A> 
<LI><A href="http://www.alistapart.com/topics/dom/"><FONT color=#cc0000>A List Apart</FONT></A> 
<LI><A href="http://www.quirksmode.org/"><FONT color=#cc0000>QuirksMode</FONT></A> 
<LI><A href="http://simon.incutio.com/"><FONT color=#cc0000>Simon Willison</FONT></A> 
<LI><A href="http://www.kryogenix.org/"><FONT color=#cc0000>Stuart Langridge</FONT></A> 
<LI><A href="http://www.icant.co.uk/"><FONT color=#cc0000>Christian Heilmann</FONT></A> 
<LI><A href="http://www.brainjar.com/"><FONT color=#cc0000>Brainjar</FONT></A> 
<LI><A href="http://www.gazingus.org/"><FONT color=#cc0000>Gazingus</FONT></A> </LI></UL>
<P><A href="http://www.sitepoint.com/books/dhtml1/"><FONT color=#cc0000>DHTML Utopia: Modern Web Design Using JavaScript &amp; DOM</FONT></A> is the first title of a new range of books focusing on the application of modern JavaScript and unobtrusive scripting techniques.</P>
<H3>9. Optimize your JavaScript code for performance</H3>
<P>Optimize your scripts for both <A href="http://www.websiteoptimization.com/speed/9/"><FONT color=#cc0000>download speed</FONT></A> and <A href="http://www.websiteoptimization.com/speed/10/"><FONT color=#cc0000>execution speed</FONT></A>. &lt;下载速度和执行速度&gt;Some tips:</P>
<UL>
<LI>Avoid fat code libraries and make sure your scripts stay lean and mean (or: small, independent and straightforward) 
<LI>Write efficient code and avoid constructs that execute slow 
<LI>Keep developer versions of your scripts that include full comments and use a compression&lt;压缩&gt; tool (like <A href="http://www.cfoster.net/jscrunch/"><FONT color=#cc0000>JavaScript cruncher</FONT></A> or <A href="http://www.brainjar.com/js/crunch/"><FONT color=#cc0000>JavaScript Crunchinator</FONT></A>) to strip out all comments and white-spaces to create a version for deployment. </LI></UL>
<H3>10. Use tools to optimize your work process</H3>
<P>A selection of tools that make life much easier:</P>
<UL>
<LI><A href="http://www.mozilla.org/products/mozilla1.x/"><FONT color=#cc0000>Mozilla</FONT></A> or <A href="http://www.mozilla.org/products/firefox/"><FONT color=#cc0000>Firefox browser</FONT></A> 
<UL>
<LI>Includes the good old Netscape JavaScript console by default (Tools &gt; Web Development &gt; JavaScript Console for Mozilla and Tools &gt; JavaScript Console for Firefox), e.g. to view errors and warnings that make sense 
<LI>The <A href="http://chrispederick.com/work/firefox/webdeveloper/"><FONT color=#cc0000>Web Developer Toolbar</FONT></A> extension, e.g. to quickly enable or disable your scripts 
<LI>The Mozilla <A href="http://www.mozilla.org/projects/inspector/"><FONT color=#cc0000>DOM Inspector</FONT></A> and the Firefox <A href="https://addons.update.mozilla.org/extensions/moreinfo.php?application=firefox&amp;category=Developer%20Tools&amp;numpg=10&amp;id=63"><FONT color=#cc0000>DOM Inspector extension</FONT></A>, to inspect and edit the live DOM of any Web document 
<LI><A href="http://www.mozilla.org/projects/venkman/"><FONT color=#cc0000>Venkman</FONT></A>, the JavaScript debugger (the <A href="https://addons.update.mozilla.org/extensions/moreinfo.php?application=firefox&amp;category=Developer%20Tools&amp;numpg=10&amp;id=216"><FONT color=#cc0000>Venkman extension</FONT></A> for Firefox) </LI></UL>
<LI><A href="http://jsdoc.sourceforge.net/"><FONT color=#cc0000>JSDoc</FONT></A>, a tool that parses inline documentation in JavaScript source files, and produces an HTML summary 
<LI><A href="http://www.crockford.com/javascript/lint.html"><FONT color=#cc0000>JSLint</FONT></A>, a JavaScript verifier to check for syntax and programming errors. </LI></UL>
<P class=back><A href="javascript:history.back()"><FONT color=#cc0000>Back</FONT></A></P>
<P id=copyright>© Copyright 2004-2006 Bobby van der Sluis All rights reserved.</P><img src ="http://www.blogjava.net/javaora/aggbug/29976.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-02-08 23:06 <a href="http://www.blogjava.net/javaora/archive/2006/02/08/29976.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Navigator object &amp; userAgent</title><link>http://www.blogjava.net/javaora/archive/2006/01/14/28001.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sat, 14 Jan 2006 01:55:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/01/14/28001.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/28001.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/01/14/28001.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/28001.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/28001.html</trackback:ping><description><![CDATA[<P>The Navigator object (named after the Netscape web browser, of course) has variables that specify the name and version of the browser that is running, as well as variables that identify the platform on which it is running. These variables allow scripts to customize their behavior based on browser or platform, so that they can take advantage of extra capabilities supported by some versions or work around bugs that exist on some platforms. <BR><BR><STRONG>userAgent</STRONG> <BR>&nbsp;&nbsp; The string that the browser sends in its USER-AGENT HTTP header.This property typically contains all the information in both appName and appVersion.</P>
<P>eg.<BR>&nbsp;<STRONG>this.isIE = navigator.userAgent.toLowerCase().indexOf("msie") &gt;= 0;</STRONG></P><img src ="http://www.blogjava.net/javaora/aggbug/28001.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-01-14 09:55 <a href="http://www.blogjava.net/javaora/archive/2006/01/14/28001.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Function.bindAsEventListener</title><link>http://www.blogjava.net/javaora/archive/2006/01/14/27999.html</link><dc:creator>java世界畅谈</dc:creator><author>java世界畅谈</author><pubDate>Sat, 14 Jan 2006 01:35:00 GMT</pubDate><guid>http://www.blogjava.net/javaora/archive/2006/01/14/27999.html</guid><wfw:comment>http://www.blogjava.net/javaora/comments/27999.html</wfw:comment><comments>http://www.blogjava.net/javaora/archive/2006/01/14/27999.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/javaora/comments/commentRss/27999.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/javaora/services/trackbacks/27999.html</trackback:ping><description><![CDATA[<P>name: Function.bindAsEventListener</P>
<P>This provides a new method to the core class Function. The method,called bindAsEventListener(),is used to do bind methods to event handlers.</P>
<P>这为核心class 函数支持了一个新的方法。这个方法叫bindAsEventListener(),是用来绑定方法给事件处理器的。<BR>var obj = new SomeClass();<BR>var closure = obj.someMethod.bindAsEventListener(this);<BR>element.onclick = closure;</P><img src ="http://www.blogjava.net/javaora/aggbug/27999.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/javaora/" target="_blank">java世界畅谈</a> 2006-01-14 09:35 <a href="http://www.blogjava.net/javaora/archive/2006/01/14/27999.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>