Javascript: setTimeout()ʹÓü° setInterval()ʹÓÃ
Evaluates an expression after a specified number of milliseconds has elapsed.
(ÔÚÖ¸¶¨Ê±¼ä¹ýºóÖ´ÐÐÖ¸¶¨µÄ±í´ïʽ)
Syntax:
iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])
Parameters
vCode
Required. Variant that specifies the function pointer or string that indicates the code to be executed when the specified interval has elapsed.
iMilliSeconds
Required. Integer that specifies the number of milliseconds.
sLanguage
Optional. String that specifies one of the following values:
JScript
Language is JScript.
VBScript
Language is VBScript.
JavaScript
Language is JavaScript.
Return Value
Integer. Returns an identifier that cancels the evaluation with the clearTimeout method.
==============================================================
ÒÔÉÏÄÚÈÝÕª×Ôij±¾JScript½Ì³Ì(CHM¸ñʽ,³ö´¦²»Ïê,¸úÔ×÷Õß˵ÉùSorry)
ÒÔÏÂÄÚÈÝû³ÈκÎÈ˵Ä,Èç¹ûÓÐÀ×ͬ,¹À¼Æ²»ÊÇÄã³Å¼µÄ¾ÍÊÇÇɺÏ,ºÙºÙ.
-------------------------------------------------------------------
setTimeout( alert("3ÃëÖÖ¹ýÈ¥ÁË"), 3000);//µ÷ÓÃÒ»¸öº¯Êý,ÔÊÐí´ø³£Á¿²ÎÊý
-------------------------------------------------------------------
<script language="Javascript">
//by zuoyang
var x = 1;
var y = 2;
var z = 3;
var sum;
function Plus(a, b)
{
var z = 0;
var i = 0;
for (i = 0; i < arguments.length; i++)
{
z += arguments[i];
}
setTimeout( function() {alert(z);}, 6000); //¿ÉÒÔ´ø±äÁ¿²ÎÊýµÄsetTimeoutµ÷ÓÃÐÎʽ
return z;
}
setTimeout( function(){ sum = Plus(x, y, z); }, 3000);/*³ýÁË¿ÉÒÔ´ø±äÁ¿²ÎÊý»¹¿ÉÒÔ»ñÈ¡·µ
Ïà¹ØÎĵµ£º
JavaScript³£ÓÃÑéÖ¤º¯Êý
Òý×Ô:http://www.webdeveloping.cn/blog/?action=show&id=209
//УÑéÊÇ·ñÈ«ÓÉÊý×Ö×é³É
function isDigit(s) {
var patrn=/^[0-9]{1,20}$/;
i ......
ÔÚÊý°ÙÍòÕÅÒ³ÃæÖУ¬JavaScript ±»ÓÃÀ´¸Ä½øÉè¼Æ¡¢ÑéÖ¤±íµ¥¡¢¼ì²âä¯ÀÀÆ÷¡¢´´½¨cookies£¬µÈµÈµÈµÈ¡£
JavaScript ÊÇÒòÌØÍøÉÏ×îÁ÷ÐеĽű¾ÓïÑÔ£¬²¢ÇÒ¿ÉÔÚËùÓÐÖ÷ÒªµÄä¯ÀÀÆ÷ÖÐÔËÐУ¬±È·½Ëµ Internet
Explorer¡¢ Mozilla¡¢Firefox¡¢Netscape¡¢ºÍ Opera¡£
......
function getCookies(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return '';
}
function setCookie(name, value, expires, path, domain, secure)
{
var liveDate = new Date();
expires = l ......
Èç¹ûÄú»¹Ã»ÓÐÔĶÁ¡¶JavaScriptµ÷ÊÔ¼¼ÇÉÖ®£º¿ìËÙ¶¨Î»¡·£¬½¨ÒéÏÈ¿´¿´ÄÇÆª¡£Ëµ²»¶¨£¬ÓÿìËÙ¶¨Î»¾ÍÄܽâ¾öÎÊÌâÁË£¬ºÇºÇ¡£Õâ´ÎÎÒ»á×ܽá¼Ç¼һ϶ϵãµ÷ÊԵıʼǣ¬Ï£ÍûÒ²¶Ô´ó¼ÒÓÐÓ㬻¶Ó²¹³ä½»Á÷£¡
Ê×ÏÈ£¬ÔÚ¸÷¸öä¯ÀÀÆ÷ÖУ¬¶Ïµãµ÷ÊÔÖ§³ÖµÄ×îºÃµÄµ±È»ÊÇFirefox£¬Firefox²»½ö¿ÉÒÔʹÓÃFirebugµ÷ÊÔÒ³Ãæjs½Å±¾£¬»¹¿ÉÒÔÓø߼¶µ÷ÊÔ¹¤¾ßÀ ......
Ò»¶ÎJavaScript½Å±¾³ÌÐò£¬¸ºÔð¹Ø±Õ´°¿Ú£¬Èç¹ûÍøÒ³²»ÊÇͨ¹ý½Å±¾³ÌÐò´ò¿ªµÄ£¨window.open()£©£¬µ÷ÓÃwindow.close()½Å±¾¹Ø±Õ´°¿Úǰ£¬±ØÐëÏȽ«window.opener¶ÔÏóÖÃΪnull£¬·ñÔòä¯ÀÀÆ÷£¨IE7¡¢IE8£©»áµ¯³öÒ»¸öÈ·¶¨¹Ø±ÕµÄ¶Ô»°¿ò¡£
£¼script language="javaScript"£¾
function closeWindow()
{
¡¡window.opener = null;
¡¡w ......