JS中使用計(jì)時(shí)器,setTimeout與setInterval函數(shù)詳解
來源:易賢網(wǎng) 閱讀:1571 次 日期:2015-03-18 11:01:13
溫馨提示:易賢網(wǎng)小編為您整理了“JS中使用計(jì)時(shí)器,setTimeout與setInterval函數(shù)詳解”,方便廣大網(wǎng)友查閱!

Evaluates an expression after a specified number of milliseconds has elapsed.

(在指定時(shí)間過后執(zhí)行指定的表達(dá)式)

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.

以上內(nèi)容摘自某本JScript教程(CHM格式,出處不詳,跟原作者說聲Sorry)

以下內(nèi)容沒抄任何人的,如果有雷同,估計(jì)不是你抄偶的就是巧合,嘿嘿.

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

setTimeout( alert("3秒種過去了"), 3000);//調(diào)用一個(gè)函數(shù),允許帶常量參數(shù)

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

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); //可以帶變量參數(shù)的setTimeout調(diào)用形式

return z;

}

setTimeout( function(){ sum = Plus(x, y, z); }, 3000);/*除了可以帶變量參數(shù)還可以獲取返回值的setTimeout調(diào)用形式*/

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

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

更多信息請查看IT技術(shù)專欄

更多信息請查看腳本欄目
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)