易截截图软件、单文件、免安装、纯绿色、仅160KB

[翻译]High Performance JavaScript(010)

Cloning Nodes  节点克隆
    Another way of updating page contents using DOM methods is to clone existing DOM elements instead of creating new ones—in other words, using element.cloneNode() (where element is an existing node) instead of document.createElement().
    使用DOM方法更新页面内容的另一个途径是克隆已有DOM元素,而不是创建新的——即使用element.cloneNode()(element是一个已存在的节点)代替document.createElement();
    Cloning nodes is more efficient in most browsers, but not by a big margin. Regenerating the table from the previous example by creating the repeating elements only once and then copying them results in slightly faster execution times:
    在大多数浏览器上,克隆节点更有效率,但提高不太多。用克隆节点的办法重新生成前面例子中的表,单元只创建一次,然后重复执行复制操作,这样做只是稍微快了一点:
• 2% in IE8, but no change in IE6 and IE7
 在IE8中快2%,但在IE6和IE7中无变化
• Up to 5.5% in Firefox 3.5 and Safari 4
 在Firefox 3.5和Safari 4中快了5.5%
• 6% in Opera (but no savings in Opera 10)
 在Opera中快了6%(但是在Opera 10中无变化)
• 10% in Chrome 2 and 3% in Chrome 3
在Chrome 2中快了10%,在Chrome 3中快了3%
    As an illustration, here's a partial code listing for generating the table using element.cloneNode():
    一个示例,这里是使用element.cloneNode()创建表的部分代码:
function tableClonedDOM() {
  var i, table, thead, tbody, tr, th, td, a, ul, li,
  oth = document.createElement('th'),
  otd = document.createElement('td'),
  otr = document.createElement('tr'),
  oa = document.createElement('a'),
  oli = document.createElement('li'),
  oul = document.createElement('ul');
  tbody = document.createElement('tbody');
  for (i = 1; i <= 1000; i++) {
    tr = otr.cloneNode(false);
    td = otd.cloneNode(false);
&nb


相关文档:

JavaScript:history.go() 的妙用(转)

  在Web开发中,会遇到从一页(父页)导向另一页(子页),并且要求“返回”父页的情况,在这里如果用ASP.NET提供的 Response.Redirect()方法,往往不会达到理想的效果,例如:返回后,重新加载了页面,无法保存导向子页前的状态,等等,在这里我就介绍 一下如何使用JavaScript中history.go()函数来实现返回 ......

firefox与IE对javascript和CSS的区别

1. document.formName.item("itemName") 问题
说明:IE下,可以使用document.formName.item("itemName")或document.formName.elements["elementName"];
Firefox下,只能使用document.formName.elements["elementName"].
解决方法:统一使用document.formName.elements["elementName"].
2.集合类对象问题
说明:IE下,可 ......

[读书笔记][JavaScript高级程序设计]

第二章:ECMAScript基础
1.当函数无明确返回值时,返回的也是值undefined
  function testFunc(){}
  alert(testFunc()==undefined);
2.typeof(null)=='object' //true,null可以解释为对象占位符
3.undefined 是声明了变量但未对其初始化时赋予该变量的值,null则用于表示尚未存在的对象。
  alert(nu ......

javascript location.reload()

功能:
重新加载文档。
语法:
location.reload(force)
参数:
force:可选参数,是一个布尔值。
      如果省略参数,或者参数是false,它就会用HTTP头If-Modified-Since来检测服务器上的文档是否已改变。如果文档已改
变,reload()会再次下载该文档。如果文档未改变,则该方法将从缓存中 ......

[翻译]High Performance JavaScript(008)

Nested Members  嵌套成员
    Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号