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>

  • 相关阅读:
    github 代理加速
    centos系统语言设置为中文
    红帽 / CentOS安装Jenkins
    查看api有没有更新到位
    永久关闭Windows10或Windows11的系统自动更新
    api传文件连接超时
    docker日常使用
    开发者工具批量替换
    Linux常用工具安装
    office密钥
  • 原文地址:https://www.cnblogs.com/phpspring/p/2845821.html
Copyright © 2011-2022 走看看