六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 175|回复: 0

js点击按钮出现进程条

[复制链接]

升级  93%

145

主题

145

主题

145

主题

举人

Rank: 3Rank: 3

积分
479
 楼主| 发表于 2013-2-7 19:42:55 | 显示全部楼层 |阅读模式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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">
//<![CDATA[
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').onclick=ldh.run;
//]]>
</script>
</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表