window.setTimeout("代码",时间间隔)可以省略Window(默认window对象),自动刷新,代码只执行一次,若需要用多次的用setInterval(代码,毫秒级的时间),或者在方法体里边执行setTimeout(方法名,时间),调用方法有两种1.setTimeout(方法名,时间) 2.setTimeout("方法名()",时间,取消的方法clearTimeout(),clearInterval();
jquery中的页面加载时就执行的js 的函数如下三个:
1.$(document).ready(fuction(){});
2.$().ready(fuction(){}):
3.$(fuction(){});
js页面加载函数
1.<body onLoad="down()"></body> body标签中的onLoad属性的js方法,可以用setTimeout()自动刷新加载
2.window.οnlοad=fuction(){}只能在页面加载的时侯加载一次
js 中的Date ,获取一个具体的时间为例:
function show(){
var weekday=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var date=new Date();//获取当前时间
var time="";
time=time+date.getFullYear()+"年"
+(date.getMonth()+1)+"月"
+date.getDate()+"日"
+weekday[date.getDay()]
+checkTime(date.getHours())+":"
+checkTime(date.getMinutes())+":"
+checkTime(date.getSeconds());
document.getElementById("main").innerHTML=time;
//document.write(time);
}
function checkTime(i){
if(i<10){
i="0"+i;
}
return i;
}
其中checkTime()是用来确保时分秒为两位数,Date还有一个getTime()方法用来获取从1970年1月1日起date对象的毫秒数。