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.
==============================================================
以上内容摘自某本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);/*除了可以带变量参数还可以获取返
相关文档:
<input type=button value=刷新 onclick="window.location.reload()">
<input type=button value=前进 onclick="window.history.go(1)">
<input type=button value=后退 onclick="window.history.go(-1)"> ......
简单的例子,自己看看,省得以后老是去找了。
<script language="javascript">
//用正则替换将X替换成y
var s="daxdasx";//原字符串
var k="x";//被替换的字段
var re = new RegExp(k,"g");
alert("替换前字符串为:"+s);
s = s.replace(re,"y");
alert("替换后字符串为:"+s);
</script> ......
JavaScript常用验证函数
引自:http://www.webdeveloping.cn/blog/?action=show&id=209
//校验是否全由数字组成
function isDigit(s) {
var patrn=/^[0-9]{1,20}$/;
i ......
JavaScript 事件方法
http://www.webdeveloping.cn/blog/?action=show&id=207
事件源对象
event.srcElement.tagName
event.srcElement.type
捕获释放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按键
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件返回值
......