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

[翻译]High Performance JavaScript(003)

Dynamic Script Elements  动态脚本元素
    The Document Object Model (DOM) allows you to dynamically create almost any part of an HTML document using JavaScript. At its root, the <script> element isn't any different than any other element on a page: references can be retrieved through the DOM, and they can be moved, removed from the document, and even created. A new <script> element can be created very easily using standard DOM methods:
    文档对象模型(DOM)允许你使用JavaScript动态创建HTML的几乎全部文档内容。其根本在于,<script>元素与页面其他元素没有什么不同:引用变量可以通过DOM进行检索,可以从文档中移动、删除,也可以被创建。一个新的<script>元素可以非常容易地通过标准DOM函数创建:
var script = document.createElement_x("script");
script.type = "text/javascript";
script.src = "file1.js";
document.getElementsByTagName("head")[0].appendChild(script);
    This new <script> element loads the source file file1.js. The file begins downloading as soon as the element is added to the page. The important thing about this technique is that the file is downloaded and executed without blocking other page processes, regardless of where the download is initiated. You can even place this code in the <head> of a document without affecting the rest of the page (aside from the one HTTP connection that is used to download the file).
    新的<script>元素加载file1.js源文件。此文件当元素添加到页面之后立刻开始下载。此技术的重点在于:无论在何处启动下载,文件的下载和运行都不会阻塞其他页面处理过程。你甚至可以将这些代码放在<head>部分而不会对其余部分的页面代码造成影响(除了用于下载文件的HTTP连接)。
    When a file is downloaded using a dynamic script node, the retrieved code is typically executed immediately (except in Firefox and Opera, which will wait until any previous dynamic script nodes have executed). This works well when the script is self-executing but


相关文档:

Javascript 的词法作用域、调用对象和闭包

作用域 Scope
Javascript 中的函数属于词法作用域,也就是说函数在它被定义时的作用域中运行而不是在被执行时的作用域内运行。这是犀牛书上的说法。但“定义时”和“执行(被调用)时”这两个东西有些人搞不清楚。简单来说,一个函数A在“定义时”就是 function A(){} 这个语句执行的时候就 ......

JavaScript中DOM树的Node接口的一些简单应用

1. 用类名查找元素
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml
" >
<head>
<title>Untitled Page</title>
......

javascript check all and uncheck

<script language='javascript'>
function toggleAll(cb)
{
    var val = cb.checked;
    var frm = document.forms[0];
    var len = frm.elements.length;
    var i=0;
    for( i=0 ; i<len ; i++)
  &nb ......

JavaScript 动态数组 实例


<html>
<body>
<script type="text/javascript">
//方法一
var num_arr= [];
for (var i = 0 ; i < 10 ;  i ++)
{
  num_arr[i] = i; 
}
document.write(num_arr+'</br>');
//方法二
var obj_arr=new Array();
obj_arr[6]='ss';
document.write(obj_arr.len ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号