请教各位进度条的做法!(100分求教) 去www.xici.net/main.asp看看,里面每打开一个超链都有进度条和广告,自己去里面问问或者用力找 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 进度条的效果好做,就是隔一定时间把某个控件的尺寸加大一点但如何获得真正的下载进程就难了现在所见过的进度条(包括上面说的XICI的),都是利用定时器模拟的下面是我做的一个进度条“类”的简化版,仅供参考:<html><head><script>function CProgBar(iNo, iMax, sUnit, nWidth, nHeight, sFont, clBg, clBorder, clBar, clText){ this.iNo = iNo; this.iMax = iMax; this.sUnit = sUnit; this.nWidth = nWidth; this.nHeight = nHeight; this.sFont = sFont; this.clBg = clBg; this.clBorder = clBorder; this.clBar = clBar; this.clText = clText; this.iPos = 0; this.Init = CProgBar_Init; this.SetPos = CProgBar_SetPos; this.IncPos = CProgBar_IncPos;}function CProgBar_Init(){ with ( this ) document.write( '<div id=voProgBar_'+iNo+' style="position:relative;width:'+(nWidth+2)+'px;height:'+(nHeight+2)+'px;border:1px solid '+clBorder+';background:'+clBg+';font:'+(sFont?sFont:'1px')+'">' +'<div style="position:absolute;left:0px;top:0px;width:0px;height:'+nHeight+'px;background:'+clBar+'"></div>' +'<div style="position:absolute;left:0px;top:0px;width:'+nWidth+'px;height:'+nHeight+'px;color:'+clText+';text-align:center">0</div>' +'</div>' );}function CProgBar_SetPos(iNewPos){ with ( this ) { var o = document.all.item('voProgBar_'+iNo).children; o(0).style.pixelWidth = Math.round(nWidth * iNewPos / iMax); if ( sFont) o(1).innerText = '' + iNewPos + sUnit; iPos = iNewPos; } }function CProgBar_IncPos(nStep){ with ( this ) { if ( iPos < iMax ) { SetPos(iPos + nStep); return true; } } return false;}</script></head><body><script>var oProgBar1 = new CProgBar(0, 100, '%', 400, 13, '10px Arial', '#bb0', '#f00', '#00f', '#fff');oProgBar1.Init();function incProgBar(){ if ( oProgBar1.IncPos(1) ) setTimeout("incProgBar();", 20); //每10毫秒加1,酌情设定}incProgBar();</script><br>简单的也可以考虑用<input type=text><br>一个字符代表10%,10个字符代表100%等</body></html> <html><head><title></title></head><body><table width=100% height=100% ><tr><td valign=middle align=center width=100% height=100% ><form name=loading><p><font color="7285CF">正在载入首页,请稍候.......</font></p><p> <input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:7285CF; background-color:white; padding:0px; border-style:none;"><br><input type=text name=percent size=46 style="font-family:Arial; color:FF0000; text-align:center; border-width:medium; border-style:none;"><script>var bar = 0 var line = "||" var amount ="||" count() function count(){ bar= bar+2 amount =amount + line document.loading.chart.value=amount document.loading.percent.value=bar+"%" if (bar<99) {setTimeout("count()",100);} else {window.location = "index.html" ; //填写跳转地址}}</script></p></form></td></tr></table></body></html> 在 setTimeout 里可以根据当前页面大小来决定进度条的速度....setTimeout("incProgBar();", parseInt(document.fileSize)/100); http://support.persits.com/upload/progress.asp Progress Bar Control:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/progbar/progbar.asp net_lover(孟子E章)找到的就是我刚找到的一种啦。也好合适你的要求。 [转]什么是闭包(closures) js问题 jq不执行 请教各位document.write 怎么用? 关于在firefox钟onload事件用法的疑问?? csdn论坛上的帖子都是HTML文件,为什么可以回复帖子,很象动态网页 帮忙看下这段JS代码错误是怎么回事? 如何实现文件的上传,类似 WEB 邮箱中的附加文件功能? 为什么回车提交以后,文本框的内容就是取不出来呢?????? 如何控制输入的数据类型? 关于js中16进制转化为字符串的问题 如何控制鼠标的位置,通过程序实现???谢谢 等待 改变图片透明度:帮我看看这段脚本为什么老报错
但如何获得真正的下载进程就难了
现在所见过的进度条(包括上面说的XICI的),都是利用定时器模拟的下面是我做的一个进度条“类”的简化版,仅供参考:<html>
<head>
<script>
function CProgBar(iNo, iMax, sUnit, nWidth, nHeight, sFont, clBg, clBorder, clBar, clText)
{
this.iNo = iNo;
this.iMax = iMax;
this.sUnit = sUnit;
this.nWidth = nWidth;
this.nHeight = nHeight;
this.sFont = sFont;
this.clBg = clBg;
this.clBorder = clBorder;
this.clBar = clBar;
this.clText = clText;
this.iPos = 0;
this.Init = CProgBar_Init;
this.SetPos = CProgBar_SetPos;
this.IncPos = CProgBar_IncPos;
}
function CProgBar_Init()
{
with ( this )
document.write(
'<div id=voProgBar_'+iNo+' style="position:relative;width:'+(nWidth+2)+'px;height:'+(nHeight+2)+'px;border:1px solid '+clBorder+';background:'+clBg+';font:'+(sFont?sFont:'1px')+'">'
+'<div style="position:absolute;left:0px;top:0px;width:0px;height:'+nHeight+'px;background:'+clBar+'"></div>'
+'<div style="position:absolute;left:0px;top:0px;width:'+nWidth+'px;height:'+nHeight+'px;color:'+clText+';text-align:center">0</div>'
+'</div>'
);
}
function CProgBar_SetPos(iNewPos)
{
with ( this )
{
var o = document.all.item('voProgBar_'+iNo).children;
o(0).style.pixelWidth = Math.round(nWidth * iNewPos / iMax);
if ( sFont) o(1).innerText = '' + iNewPos + sUnit;
iPos = iNewPos;
}
}
function CProgBar_IncPos(nStep)
{
with ( this )
{
if ( iPos < iMax )
{
SetPos(iPos + nStep);
return true;
}
}
return false;
}
</script>
</head>
<body>
<script>
var oProgBar1 = new CProgBar(0, 100, '%', 400, 13, '10px Arial', '#bb0', '#f00', '#00f', '#fff');
oProgBar1.Init();
function incProgBar()
{
if ( oProgBar1.IncPos(1) )
setTimeout("incProgBar();", 20); //每10毫秒加1,酌情设定
}
incProgBar();
</script><br>简单的也可以考虑用<input type=text>
<br>一个字符代表10%,10个字符代表100%等
</body>
</html>
<head>
<title></title>
</head>
<body>
<table width=100% height=100% >
<tr>
<td valign=middle align=center width=100% height=100% >
<form name=loading>
<p><font color="7285CF">正在载入首页,请稍候.......</font></p>
<p>
<input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:7285CF; background-color:white; padding:0px; border-style:none;">
<br>
<input type=text name=percent size=46 style="font-family:Arial; color:FF0000; text-align:center; border-width:medium; border-style:none;">
<script>var bar = 0
var line = "||"
var amount ="||"
count()
function count(){
bar= bar+2
amount =amount + line
document.loading.chart.value=amount
document.loading.percent.value=bar+"%"
if (bar<99)
{setTimeout("count()",100);}
else
{
window.location = "index.html" ; //填写跳转地址
}
}
</script>
</p>
</form>
</td>
</tr>
</table>
</body>
</html>