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

// 大学里最痛苦的事情莫过于做毕业设计,目前正处于这个时期。
// :( :(
//
// 首先记录下的是 Function 的一个问题
Function.prototype.method = function( name, func){
if( ! this.prototype[ name]){
this.prototype[ name ] = func;
}
} // 给 函数原型增加方法
//
// 给函数原型增加的方法在 St ......

javascript 实现分页条

function Paging(pageNum,pageSize,totalCount,skipCount,fuctionName,currentStyleName,currentUseLink,preText,nextText,firstText,lastText)
{
//debugger;
    var returnValue = "";
    var begin = 1;
    var end = 1;
    var total ......

javascript操作dom 建立 增加 删除 克隆 访问节点

一、DOM基础
1.节点(node)层次
Document--最顶层的节点,所有的其他节点都是附属于它的。
DocumentType--DTD引用(使用<!DOCTYPE>语法)的对象表现形式,它不能包含子节点。
DocumentFragment--可以像Document一样来保存其他节点。
Element--表示起始标签和结束标签之间的内容,例如<tag></tab ......

javascript 打印(人云亦云,我错了)

<html>
<head>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<title>***WSOFT.NET***</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 这个属性可以在打印时有效-->
<style ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号