`
liwei888
  • 浏览: 92912 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

js定时器的实现

阅读更多

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<script>
var secs=5;//第一次提示时间秒
   debugger;
 function checkServer(secs){
 for(i=1;i<=secs;i++) {
  window.setTimeout("update(" + i + ")", i * 1000);
 }
 }
 function update(num) {
  if(num == secs) {
   alert("来数据了!");
   secs=1*60;//提示时间秒
   for(i=1;i<=secs;i++) {
  window.setTimeout("update(" + i + ")", i * 1000);
 }
  }
 else {
  printnr = secs-num;
  }
 }
checkServer(secs);

 

<!--
function clock(){i=i-1
document.title="离关掉页面还有"+i+"秒!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=10
clock();
//-->
</script>
</script>
</body>
</html>

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics