setTimeout Method--------------------------------------------------------------------------------Evaluates an expression after a specified number of milliseconds has elapsed. SyntaxiTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])ParametersvCode 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 any one of the possible values for the LANGUAGE attribute. Return ValueInteger. Returns an identifier that cancels the evaluation with the clearTimeout method.
iMilliSeconds Required. Integer that specifies the number of milliseconds.
sLanguage Optional. String that specifies any one of the possible values for the LANGUAGE attribute. Return ValueInteger. Returns an identifier that cancels the evaluation with the clearTimeout method.
<script>
var sMsg="Hello, world";
window.setTimeout("alert(sMsg)", 5000);
</script>
2/
<SCRIPT>
var g_oToHide = null;function fnHide(oToHide){
g_oToHide = oToHide;
window.setTimeout(fnHide2, 3000);
}
function fnHide2(sID){
if (g_oToHide) {
g_oToHide.style.display="none";
}
}
</SCRIPT>
<INPUT TYPE=button VALUE="Now you see me ..." ID="oHideButton"
onclick="fnHide(this)">
看一下为这个例子你就明白了,换成1000试一下,
setTimeout("alert()",1000)
</script>
设置定时执行一段代码或一个函数,1000在这里是1秒钟(1000毫秒)