易截截图软件、单文件、免安装、纯绿色、仅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 制作简单计算器 isNaN eval 使用

判断(value)是否是一个数字,假如值是NaN那么IsNan返回TRUE,否则返回FALSE。
还有一种办法,变量可以与它自身进行比较。 假如比较的结果不等,那么它就是 NaN 。
这是因为 NaN 是唯一与自身不等的值。
第一种方法:
<html>
<head>
<title>简单计算器的制作</title>
</ ......

Javascript面向对象编程(二):继承


ZT:http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_inheritance.html
上一次的文章,主要介绍了如何"封装"数据和方法,从原型对象生成实例。
今天要介绍的是,多个原型对象之间如何"继承"。
比如,现在有一个"动物"对象,
  function Animal(){
    this.species = "动物";
  }
还有 ......

javascript自动跳转设置

 <script>setTimeout("redirect('<?=$url_forward?>');", <?=$ms?>);</script>
设置分页:$page $pagesize $offset = ($page-1)*$pagesize;
$limit  = "limit $offset,$pagesize" ......

JavaScript的BASE64

**
* 我在网上看到过很多BASE64的JavaScript算法,都觉得不满意,于是自己写了一个,在这里分享一下。
* 我的代码在质量的效率都较高,没有一些冗余的操作。总体来讲我觉得非常不错。
* 如果大家有什么不懂的地方可以问我。
*/
var BASE64={
    /**
     * 此变量为编码的 ......

[翻译]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号