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հü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£º±Õ°üÊ ......
//¸÷Öֳߴç
s += "\r\nÍøÒ³¿É¼ûÇøÓò¿í£º"+ document.body.clientWidth;
s += "\r\nÍøÒ³¿É¼ûÇøÓò¸ß£º"+ document.body.clientHeight;
s += "\r\nÍøÒ³¿É¼ûÇøÓò¸ß£º"+ document.body.offs ......
function Paging(pageNum,pageSize,totalCount,skipCount,fuctionName,currentStyleName,currentUseLink,preText,nextText,firstText,lastText)
{
//debugger;
var returnValue = "";
var begin = 1;
var end = 1;
var total ......
//¹¹Ô캯Êý£ºÓÃÖ¸¶¨µÄÃû×ֺͿÉÑ¡µÄÐÔÖÊΪָ¶¨µÄÎĵµ´´½¨Ò»¸öcookie¶ÔÏó¡£
//²ÎÊý£º
// doucment:±£´æcookieµÄDocument¶ÔÏó
// name£º Ö¸¶¨cookieÃûµÄ×Ö·û´®
// hours£º Number£¬Ö¸¶¨´ÓÏÖÔÚÆðµ½cookie¹ýÆÚµÄСʱÊý
// path: String£¬Ö¸¶¨cookieµÄ·¾¶ÐÔÖÊ
// domain£º String, Ö¸¶¨cookieµÄÓòÐÔÖÊ
// secure: Bo ......
²Î¿¼×ÊÁÏ:¡¶javascriptȨÍþÖ¸ÄϵÚÎå°æ¡·
===============±äÁ¿==============
1¡¢javaScriptÊÇÒ»ÖÖÈõÀàÐ͵ÄÓïÑÔ£¬ÓÃvarÓï¾ä¼´¿ÉÉùÃ÷Ò»¸ö±äÁ¿¡£
2¡¢Èç¹û²»ÓÃvarÓï¾äÉùÃ÷¶øÖ±½Ó¸øÒ»¸ö±äÁ¿¸³Öµ£¬ÄÇÕâ¸ö±äÁ¿½«±»ÒþʽÉùÃ÷Ϊȫ¾Ö±äÁ¿¡£
3¡¢Èç¹ûº¯ÊýÄÚ²¿ÓÃvarÓï¾äÉùÃ÷ÁËÒ»¸öÓëijȫ¾Ö±äÁ¿Í¬ÃûµÄ±äÁ¿£¬ÔòÔÚº¯ÊýÖÐÈ«¾Ö±äÁ¿±»ÆÁ±ÎÁË ......