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հü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£º±Õ°üÊ ......
Javascript¹Ø±Õµ±Ç°´°¿Ú2007-09-03 11:11Õâ¸öÌ«¼òµ¥ÁË£¬window.close()¾Í¿ÉÒÔÁË£» ²»¹ýËü»á³ö¸öÌáʾ“Äú²é¿´µÄÍøÒ³ÕýÔÚÊÔͼ¹Ø±Õ´°¿Ú¡£ÊÇ·ñ¹Ø±Õ´°¿Ú£¿”£¬Äܲ»Äܲ»³öÕâ¸öÌáʾ£¿NÄêǰ¾ÍÓÐÈËÎʹýÎÒ£¬ÄÇʱºòÎÒ»¹ÊDzËÄñ£¬²»¹ýÎҵĻشð»¹Ëã“רҵ”¡£ºÇºÇ£» “Èç¹ûÄãµÚÒ»´Î´ò¿ªÕâ¸öÍøÒ³£¬window.close() ......
´ó²¿·ÖµÄ½âÊÍÐͽű¾ÓïÑÔ¶¼Ìṩ eval ·½·¨À´Íê³É¶¯Ì¬´úÂëµÄ½âÊÍÖ´ÐУ¬ C# È´²¢²»Ìṩ£¨Ïò Java ѧϰ£©¡£²»¹ýÔÚ .NET Framework Àà¿âÀïÃæÌṩµÄ Microsoft.JScript ÃüÃû¿Õ¼äµ¹Êǰüº¬ÁËÖ§³ÖʹÓÃJScript ÓïÑÔ±àÒëºÍÉú³É´úÂëµÄÀà¡£
ÏÈÉÏ´úÂ룺
¡¡¡¡¸ÃÀàÐèÒªÄãÌí¼Ó¶Ô³ÌÐò¼¯ Microsoft.JScript µÄÒýÓã»Èç¹û°Ñ“current v ......
Ò»¸ö¹«ÓÃÀࣺflash.external.ExternalInterface£»
¸ÃÀàÓÐÁ½¸öÏà¹Ø·½·¨£º
1¡¢µ÷ÓÃjavascriptº¯Êý£»
ExternalInterface.call(´jsº¯ÊýÃû´[,ÒÔ¶ººÅ¸ô¿ªµÄ¶à¸ö²ÎÊý]);
ÆäÖÐjsº¯ÊýÃûΪÔÚjavascriptÖÐÉêÃ÷µÄº¯ÊýÃû³Æ£¬
´«µÝµÄ²ÎÊý¿ÉÒÔÊÇasÖÐÈκÎÀàÐ͵ÄÊý¾Ý£¬ÕâЩ²ÎÊý½«±»×Ô¶¯×ª»»³Éjs±äÁ¿£»
2¡¢×¢²ájsÖпÉÓÃµÄ»Ø ......
javascriptÆÀ¹ÀÓû§ÊäÈëÃÜÂëµÄÇ¿¶È
ÃÜÂëÒѾÊÇÎÒÃÇÉú»î¹¤×÷Öбز»¿ÉÉٵŤ¾ß,µ«Ò»¸ö²»°²È«µÄÃÜÂëÓÐÓÖÓпÉÄÜ»á¸øÎÒÃÇÔì³É²»±ØÒªµÄËðʧ¡£×÷ÎªÍøÕ¾Éè¼ÆÕß,Èç¹ûÎÒÃÇÔÚÍøÒ³ÖÐÄܶÔÓû§ÊäÈëµÄÃÜÂë½øÐа²È«ÆÀ¹À,²¢ÏÔʾ³öÏàÓ¦µÄÌáʾÐÅÏ¢,ÄÇô¶ÔÓû§ÉèÖÃÒ»¸ö°²È«µÄÃÜÂ뽫Óкܴó°ïÖú¡£Í¬Ê±Ò²Ê¹µÃÍøÕ¾¸ü¾ßÈËÐÔ»¯,¸üÓÐÎüÒýÁ¦.
ʲôÊÇÒ» ......