| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 390 人关注过本帖
标题:修改代码
只看楼主 加入收藏
wysnet
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-3-2
收藏
 问题点数:0 回复次数:0 
修改代码

如何让鼠标一移动和键盘一按键,时间就从新开始计时。我想实现鼠标和键盘无操作N分钟后让页面自动返回。

谢了。

<Script Language="JavaScript">
<!-- Hiding


function display(){
rtime=etime-ctime;
if (rtime>60)
m=parseInt(rtime/60);
else{
m=0;
}
s=parseInt(rtime-m*60);
if(s<10)
s="0"+s
window.status="Time Remaining : "+m+":"+s
window.setTimeout("checktime()",1000)
}

function settimes(){
//alert("You have 20 minutes time !")
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
etime=hours*3600+mins*60+secs;
etime+=60; //You can change the value of 1200 according to how much time you wish to set the timer. Where 1200 is time in secs (1200 = 20 mins * 60 secs/min). Max time is 60 mins (3600secs)
checktime();
}

function checktime(){
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
ctime=hours*3600+mins*60+secs
if(ctime>=etime){
expired();
}
else
display();
}

function expired(){
//alert("Time expired");
location.href="Main.html"; //Put here the next page
}

// Done hiding -->
</Script>
<BODY onLoad="settimes()">
<Center><H2>Look in the status bar. In 20 mins you will be forced to change page</H2>
</Center>
</BODY>

</html>

搜索更多相关主题的帖子: 代码 
2006-03-12 09:20
快速回复:修改代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019335 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved