================检测窗口是否为当前窗口================
<script language="javascript">
window.onblur = function(){alert('out');}
window.onfocus = function(){alert('in');}
</script>
================每两秒打印一次数组================
<script language="javascript">
var OBJ = [];
setInterval(function(){
OBJ[OBJ.length]=OBJ.length;
alert(OBJ);
},2000);
</script>
================检测页面是否已经打开================
<script>
var op; //定义全局变量op作为窗口引用
function OpenWin() //定义打开新窗口的函数
{
if(op == null) //如果窗口还没有打开,则打开新窗口
{
op = window.open('http://www.163.com','aa');
}
else //否则,让已经打开的窗口获取焦点
{
op.focus();
}
}
OpenWin();
</script>