简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

JS中使用计时器,setTimeout与setInterval函数详解

来源:易贤网   阅读:1402 次  日期:2015-03-18 11:01:13

温馨提示:易贤网小编为您整理了“JS中使用计时器,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.

以上内容摘自某本JScript教程(CHM格式,出处不详,跟原作者说声Sorry)

以下内容没抄任何人的,如果有雷同,估计不是你抄偶的就是巧合,嘿嘿.

-------------------------------------------------------------------

setTimeout( alert("3秒种过去了"), 3000);//调用一个函数,允许带常量参数

-------------------------------------------------------------------

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);/*除了可以带变量参数还可以获取返回值的setTimeout调用形式*/

setInterval()的用法和setTimeout()是一样的:

iTimerID = window.setInterval(vCode, iMilliSeconds [, sLanguage])

更多信息请查看IT技术专栏

更多信息请查看脚本栏目
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:javascript跨框架函数相互调用
下一篇:javascript获取当前日期时间及操作
易贤网手机网站地址:JS中使用计时器,setTimeout与setInterval函数详解
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!