易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

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陷阱。。。。。。。

1.浮点运算
这可能是挫败一些对javascript不熟悉并准备执行一些数学运算的人的主要原
因.
<script>  
alert(0.02 / 0.1);  //0.19999999999999998 
  
alert(1.14 * 100);  //113.99999999999999    ;)
  
......

[翻译]High Performance JavaScript(009)

第三章  DOM Scripting  DOM编程
    DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号