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
Ïà¹ØÎĵµ£º
±¾ÎÄת×Ô£ºhttp://www.felixwoo.com/archives/247
×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ÍÊÇÓÃ×îͨË×µÄÎÄ×Ö½Ò¿ªJavascript±Õ°üµÄÕæÊµÃæÄ¿¡£
Ò»¡¢Ê²Ã´ÊDZհü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£º±Õ°üÊ ......
// ´óѧÀï×îÍ´¿àµÄÊÂÇéιýÓÚ×ö±ÏÒµÉè¼Æ£¬Ä¿Ç°Õý´¦ÓÚÕâ¸öʱÆÚ¡£
// £º£¨ :(
//
// Ê×ÏȼǼϵÄÊÇ Function µÄÒ»¸öÎÊÌâ
Function.prototype.method = function( name, func){
if( ! this.prototype[ name]){
this.prototype[ name ] = func;
}
} // ¸ø º¯ÊýÔÐÍÔö¼Ó·½·¨
//
// ¸øº¯ÊýÔÐÍÔö¼ÓµÄ·½·¨ÔÚ St ......
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<!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 ......
function Paging(pageNum,pageSize,totalCount,skipCount,fuctionName,currentStyleName,currentUseLink,preText,nextText,firstText,lastText)
{
//debugger;
var returnValue = "";
var begin = 1;
var end = 1;
var total ......
<mce:script language="javascript" ><!--
function person(name,age)
{
this.name=name;
this.age=age;
}
function man(name,age)
{
this.sex="ÄÐ";
this.base=person;
this.base(name,age);
}
function woman(name,age)
{
this.sex="Å®";
this.base=person;
this.base(name,age)
}
......