js点击按钮出现进程条

js点击按钮出现进程条

转自:http://wangjinlongaisong-126-com.iteye.com/blog/939687

<html> 
<head> 
<title>  </title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<style type="text/css"> 
body,html{margin:0;padding:20px;font-size:12px;font-family:Arial;font:12px/1 Tahoma, Arial;} 
.stepOut{height:20px;border:1px solid #000;background:#eee;width:200px;overflow:hidden;display:none;} 
.stepIn{width:50px;background:#FF0080;border-top:1px solid #FFB5DA;border-bottom:1px solid #fff;overflow:hidden;color:#fff;text-align:center;font:12px/1.6 arial;} 
</style><script type="text/javascript" src="http://52mfx.com/tools/alert.js"></script> 
</head> 
<body> 
<button id="google">button</button><br/><br/> 
<div class="stepOut" id="stepOut" > 
    <div class="stepIn" id="stepIn"></div> 
</div> 
</body> 
<script type="text/javascript"> 
function LoadBar(outer,iner,time){ 
    $=function (x){return typeof x=="string"?document.getElementById(x):x}; 
    outer=$(outer); 
    iner=$(iner); 
    var i,width,This=this,s=(time||2000)/10; 
    this.run=function (){ 
        clearTimeout(This.t); 
        outer.style.display='block'; 
        width=outer.offsetWidth; 
        i=0; 
        (function (){ 
            iner.style.width=width/s*i++; 
            iner.innerHTML=Math.ceil(iner.offsetWidth/width*100)+'%'; 
            if(i<s){This.t=setTimeout(arguments.callee,10)    
             }else{iner.innerHTML="ok"} 
        })()           
    } 
}; 
var ldh=new LoadBar(stepOut,stepIn,5000); 
document.getElementById('google').οnclick=ldh.run; 
</script> 
</html> 

效果:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值