<html>
<head>
<script type="text/javascript">
var timerID;
var nTimeout;
var saver;
/**
* 初始化
**/
function onload(){
document.body.onmousemove = ScreenSaver.prototype.onevent;
document.body.onmousedown = ScreenSaver.prototype.onevent;
document.body.onkeydown = ScreenSaver.prototype.onevent;
document.body.onkeypress = ScreenSaver.prototype.onevent;
//创建关闭事件
//saver = new ScreenSaver();
}
/**
* 鼠标单击事件
**/
//document.οnmοusedοwn= function(){
//}
ScreenSaver.prototype.onevent = function(e){
//鼠标单击事情-根据序列ID清空事件
window.clearTimeout(timerID);
//重新创建关闭事件
saver = new ScreenSaver();
}
/**
* 调用关闭事件方法体
**/
function ScreenSaver(){
//初始化参数:5000毫秒=5秒
nTimeout = 5000;
//返回序列ID
timerID = window.setTimeout(f, nTimeout);
}
/**
* 获取过时对象
**/
var f = function(){
//获取当前超时对象
ScreenSaver.prototype.timeout();
}
/**
* 初始化超时对象
**/
ScreenSaver.prototype.timeout = function(){
/* window.opener = "whocares";
var browserName=navigator.appName;
if (browserName=="Netscape")
{
window.open('','_parent','');
window.close();
}
else if (browserName=="Microsoft Internet Explorer")
{
window.opener = "whocares";
window.close();
} */
window.close();
}
</script>
</head>
<body οnlοad="onload();">
</p>5秒不动就跳转
</body>
</html>