Javascript实现的进度条原理,大家来讨论讨论它实现的原理,知道了原理了实现起来就比较容易了。
解决方案 »
- 跪求高人帮忙看看一个关于层的问题!@!!
- 请高手帮忙看一个自动生成控件的问题.真是太纠结了。。
- 关于网页源文件的问题
- 如何判断表单中输入验证码是否正确
- ATGrid报表控件/WEB插件[专业版]
- 请教一个问题,JS脚本,怎么限制在表单只允许输入英文和数字
- 各位老大,帮偶看看这样的代码应该怎样写?● ● 急急急……
- 这个javascript代码很有用,哪位知道怎么写?
- 请问一下普通输入框的自动记忆功能能不能去掉呢?
- 我编写的一个便于在WEB页面中输入时间的JSCalendar控件!欢迎大家多提意见!:)
- 急!为何表格中填入视频对象后,表格宽高无法用JS改变?
- 在线等!!js怎么往指定的div里面加属性!!
<head>
<title>一个JS做的相当漂亮的进度条 www.qpsh.com</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://news.qq.com";
}
loading();</script>
</html>
那么你用js做出一个14秒左右的效果,等指示到100%,在允许继续操作.其实在10秒时,数据已经准备完毕