js进度条效果

javascript 前端进度条效果<title>网页loading</title>
<script language="javascript">
function setSB(v, el) {
var ie5 = (document.all && document.getElementsByTagName);
if (ie5 || document.readyState == "complete") {
filterEl = el.children[0];
valueEl = el.children[1];
filterEl.style.width = v + "%";
valueEl.innerText = v + "%";
}
}
function fakeProgress(v, el) {
if (v > 100)
location.href = "/";
else {
setSB(v, el);
window.setTimeout("fakeProgress(" + (++v) + ", document.all['" + el.id + "'])", 20);
}
}
</script>
</head>

<body οnlοad="fakeProgress(0, sb)" topmargin=180 bgcolor=#CCCCCC>
<center>
<p align=center style="font-szie:9pt; line-height: 100%">正在加载请稍侯……</p>
<span id=sb style="width: 500px">
<div style="filter: Alpha(Opacity=0, FinishOpacity=60, style=1, StartX=0, StartY=0, FinishX=100, FinishY=0); width: 0%; height: 12px; position: absolute; background: #9999ff"></div>
<div style="font-size: 12px; width: 100%; color: #ff3333; font-family: arial; text-align: center"></DIV>
</span>
</center>
</body>
</html>


<html xmlns="http://schemas.microsoft.com/intellisense/html-401">
<head>
<title>一个JS做的相当漂亮的进度条</title>
</head>
<body>
</body>
<script type="text/jscript">
function DoubleAnimation(target,targetProperty,from,to,Duration)
{
this.Begin=function anonymous()
{
target[targetProperty]=from;
var starttime=new Date();
setTimeout(StoryBoard(),1);
function StoryBoard()
{
return function()
{
var now=new Date();
var d=now.getTime()-starttime.getTime();
target[targetProperty]=Math.round(from+(to-from)*d/Duration);
if(d<Duration)setTimeout(StoryBoard(),10);
}
}
}
this.setTo=function(val){to=val;}
this.setFrom=function(val){from=val;}
}
function ProgressBar(ID)
{
document.write( "<div id=\""+ID+"\" style=\"position:absolute;top:10%;width:100; left: 108px;\"> <image src=\"http://www.qpsh.com/icon/emptypb.jpg\" style=\"position: absolute;left: 84px; top: 137px;\" /> <div id=\""+ID+"pb\" style=\"position: absolute; left: 86px; top: 137px;z-index:5;overflow:hidden;width:130;\" > <img src=\"http://www.qpsh.com/icon/iconfullpb.jpg\"/> <div id=\""+ID+"highlight\" style=\"background:#ffffff;left: -500px; position: absolute; top: -1px;width:100;height:20;filter:Alpha(Opacity=75,FinishOpacity=0,Style=2)\"></div> </div> <div style=\"position:absolute;top:83px;width:180px; left: 148px;\"> 加载中请稍候...... </div> </div>");

var story=new DoubleAnimation(document.getElementById(ID+"highlight").style,"left",-100,324,2000)
var stophandle=setInterval(story.Begin,2000);
this.set=function(percentage)
{
document.getElementById(ID+"pb").style.width=Math.round(percentage*329/100);
}
}


var pb1=new ProgressBar("ok");
var p=0;
function loading()
{
pb1.set(p+=0.3);
if(p<100)
setTimeout(loading,2);
else
window.location.href="http://www.qpsh.com";

}
loading();

</script>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值