window,是javascript中整个框架中的根。它具有如下属性和方法:
属性:location,navigate,screen,frameset[],document,history等6个重要的属性.
方法:setTineOut(),moveTo(),moveBy(),resizeBy(),resizeTo()等几个常用的方法。
请看如下两个例子:
1、状态栏动态显示年月日
function setTime() {
var dt = new Date();
var strSt = dt.getFullYear() + "年" + (dt.getMonth()+1) + "月" + dt.getDate() + "日" + dt.getHours() + "时" + dt.getMinutes() + "分"+dt.getSeconds()+"秒";
//window.defaultStatus = strSt;
window.status = strSt;
setTimeout("setTime()", 1000);
}
2、移动窗口
var x=0;
var y=0;
function moveWin() {
((x + 0) < (window.screen.width + 0)) ? (x = x + 1) : x = 0;
((y + 0) < (window.screen.height + 0)) ? (y = y + 1) : y = 0;
window.moveTo(x, y);
setTimeout("moveWin()", 1);
}