zoukankan      html  css  js  c++  java
  • js倒计时

    <html>
    <head>
    <title>控制页面刷新时间</title>
    <script language="javascript">
    var i=0;
    var flag=null;
    function time(){ //显示时间跳动
    var timeShow=document.getElementById("timeShow");
    timeShow.innerText=i;
    i--;
    flag=setTimeout("time()",1000);
    }
    function changeTime() {
    var nowTime=document.getElementById("newTime").value;//得到输入的刷新时间
    if(nowTime=="") {alert("请输入新的刷新时间");return;}
    setTimeRef(nowTime); //显示当前刷新时间
    clearTimeout(flag);i=nowTime;time();//清除原来定时器,从头开始计时
    setTimeout("window.location.reload()",parseInt(nowTime)*1000); //定时刷新

    }
    function setTimeRef(nowTime){
    document.getElementById("timeRef").innerText=nowTime;
    }
    </script>
    </head>

    <body onLoad="">
    <p>当前刷新时间为: <span id="timeRef" style="color:red"></span>秒</p>
    <p>刷新倒计时: <span id="timeShow" style="color:red"></span>秒</p>
    <p>输入新的刷新时间: <input id="newTime" type="text" size="4"> <input type="button" value="提交" onClick="changeTime()"> </p>
    </body>
    </html>

  • 相关阅读:
    Ubuntu:替换DASH图标
    使用 python 操作 mongodb 常用的操作
    boost Asio网络编程简介
    optional的使用
    boost中Function和Lambda的使用
    boost多线程入门介绍
    boost中bind的使用
    c++11新标准for循环和lambda表达式
    使用gcc命令编译多个文件
    编辑gif
  • 原文地址:https://www.cnblogs.com/phpspring/p/2845821.html
Copyright © 2011-2022 走看看