zoukankan      html  css  js  c++  java
  • JavaScript入门学习(2)--进度条

    <html>
    <style type="text/css">
    #bar{0px; height:20px;
         background:#ee00ff;}//定义进度条的前景色
    </style>
    <script>
       var act;
       function over(){
         var w=document.getElementById("bar").style.pixelWidth;
         if (w<400){
                     document.getElementById("bar").style.pixelWidth=w+2;
                     document.getElementById("txt").innerText="Loading..."+Math.floor((w/400)*100)+"%";
                     clearTimeout(act);
                     act=setTimeout(over,10);
         }  else{document.getElementById("txt").innerText="载入完成100%";
         };
    
       };
       function out(){
         var w=document.getElementById("bar").style.pixelWidth;
         if (w>0){
                     document.getElementById("bar").style.pixelWidth=w-2;
                     document.getElementById("txt").innerText="Loading..."+Math.floor((w/400)*100)+"%";
                     clearTimeout(act);
                     act=setTimeout(out,10);
         }  else{document.getElementById("txt").innerText="载入完成0%";
         };
    
       };
       function Apouse(){
                     clearTimeout(act);
       };
    </script>
    <button onclick="over()">开始转入</button><br>
    <button onclick="out()">开始卸载</button><br><br>
    <button onclick="Apouse()">暂停</button><br><br>
    
    
    <h4  id="txt">等待载入</h4>
    <div id="bar"></div>
    
    </html>
    

      

    HTML/CSS/JS 在线工具

    仅在IE浏览器有用

  • 相关阅读:
    Linux and the Unix Philosophy(6)
    在docker环境下部署kafka集群
    Docker学习笔记1-docker介绍及安装
    nginx安装
    centos7下NFS配置
    搭建kafka集群
    nexus开机启动
    java跨库事务Atomikos
    mongodb数据库还原
    Linux下运行jar
  • 原文地址:https://www.cnblogs.com/tulater/p/9210729.html
Copyright © 2011-2022 走看看