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

javascript中setTimeout()函数

javascript中setTimeout()函数
大家都知道javascript中的setTimeput()函数的作用,一般会用他来处理一些连续的事情,们先看一个例子:
<head>
    <script>
        function init()
        {
            setTimeout("init2()",0);
            alert("1");
        }
        function init2()
        {
            alert("2");
        }
    </script>
</head>
<body onload="init()">
</body> 
也许很多人认为结果是:2 1, 而恰恰结果是:1  2 。这是为什么呢?明明延迟时间设置的是0,应该是立刻先执行init2()啊?我们可以这样认为,setTimeout()函数会自己重新申请一个堆栈空间,而不属于当前函数init()的堆栈空间,所以init()先入栈,alert("1")第2个入栈,当init()函数执行完后,setTimeout()才执行。
 
当然这里没有涉及到参数传递,再看这个例子:
<head>
<script>
  var rgbcolor=new Array(3);
  var whichtr=0;
  function changeColor(wh)
  {
  whichtr=wh;
  for(var i=0;i<3;i++)
  {rgbcolor[i]=Math.ceil(Math.random()*255);}
  trID[whichtr].style.backgroundColor="rgb("+rgbcolor[0]+","+rgbcolor[1]+","+rgbcolor[2]+")";
  setTimeout("changeColor("+whichtr+")",1000);
  }
  
</script>
</head> <body>
<table border="1" height="400" width="500" align="center" cellspacing="0">
  <tr onmousedown="changeColor(0)" id="trID"><td>0</td></tr


相关文档:

JavaScript导出word excel文件

出处:http://www.jcwcn.com/article/2005/1210/javascript_17476.html
<HTML>
  <HEAD>
    <title>WEB页面导出为EXCEL文档的方法
    </title>
  </HEAD>
<body>
<BR>
<table id = "PrintA" width="100%" border="1" cell ......

javascript , ajax

问:
Hi,
I have this C#/ASP.NET/.aspx page with a string variable named myString with the value "Mario Gamito".
How can I access "Mario Gamito" from within a JavaScript function, i. e., the variable's value ?
Already tried '" + mystring + "' but it doesn't works.
Any help would be appreciated.
......

C#中解析javascript代码


大部分的解释型脚本语言都提供 eval 方法来完成动态代码的解释执行, C# 却并不提供(向 Java 学习)。不过在 .NET Framework 类库里面提供的 Microsoft.JScript 命名空间倒是包含了支持使用JScript 语言编译和生成代码的类。
先上代码:
  该类需要你添加对程序集 Microsoft.JScript 的引用;如果把“current v ......

[读书笔记][JavaScript权威指南(第四版)][cookie]

//构造函数:用指定的名字和可选的性质为指定的文档创建一个cookie对象。
//参数:
// doucment:保存cookie的Document对象
// name: 指定cookie名的字符串
// hours: Number,指定从现在起到cookie过期的小时数
// path: String,指定cookie的路径性质
// domain: String, 指定cookie的域性质
// secure: Bo ......

[读书笔记][JavaScript权威指南(第四版)][DOM]

1.HTML文档树形表示
2.Node[] Node.childNodes 
//返回Node对象的所有字节点
3.Node.firstChild  /  lastChild  /nextSibling(下一个兄弟节点)  / previousSibling (上一个兄弟节点)  / parentNode
属性
4.Node.appendChild()  /  removeChild()  /  replaceChil ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号