社区
JavaScript
帖子详情
请问用Javascript怎样实现一个进度条?
biti_jack
2002-05-05 09:27:37
谢谢!
...全文
29
10
打赏
收藏
请问用Javascript怎样实现一个进度条?
谢谢!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
10 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
llrock
2002-05-20
打赏
举报
回复
哪还不如定义一个表格莱得快,<table><tbody><td></tbody></table>控制宽度
flylyke
2002-05-07
打赏
举报
回复
good!
biti_jack
2002-05-06
打赏
举报
回复
能大概解释一下上面程序的原理吗?谢谢!
good02xaut
2002-05-06
打赏
举报
回复
做一个进度条图片,用settimeout()动态显示图片的width。
blues-star
2002-05-06
打赏
举报
回复
so easy,用script控制表格的TD的WIDTH
孟子E章
2002-05-05
打赏
举报
回复
也可以参见:
http://lucky.myrice.com/main.html
孟子E章
2002-05-05
打赏
举报
回复
也可以参见:
http://lucky.myrice.com/main.htm
孟子E章
2002-05-05
打赏
举报
回复
<HTML>
<HEAD>
<SCRIPT>
function ProgressBar (styles) {
this.id = ProgressBar.cnt;
ProgressBar.bars[ProgressBar.cnt++] = this;
if (!styles)
styles = {};
var df = ProgressBar.defaults;
for (var p in df)
this[p] = styles[p] ? styles[p] : df[p];
this.writeHTML();
}
function ProgressBar_writeHTML () {
this.layerID = 'Bar' + this.id;
var html = '';
if (document.all) {
html += '<SPAN';
html += ' ID="' + this.layerID + '"';
html += ' STYLE="';
if (this.position != 'none')
html += ' position: ' + this.position + ';'
+ ' left: ' + this.left + ';'
+ ' top: ' + this.top + ';';
html += ' width: ' + this.width + 'px;';
html += ' height: ' + this.height + 'px;';
html += ' background-color: ' + this.backgroundColor + ';';
html += ' border: ' + this.borderWidth + 'px solid'
+ ' ' + this.borderColor + ';';
html += '"';
html += '>';
html += '<DIV ID="P' + this.layerID + '"';
html += ' STYLE="';
html += ' position: absolute;';
html += ' width: 100%; height: 100%;';
html += ' background-color: ' + this.color + ';';
html += ' clip: rect(0px, 0px, auto, 0px)';
html += '"';
html += '>';
html += '<\/DIV>';
html += '<\/SPAN>';
}
else if (document.layers) {
this.fullWidth = this.width + 2 * this.borderWidth;
this.fullHeight = this.height + 2 * this.borderWidth;
html += '<STYLE>';
html += '#' + this.layerID + ' {';
if (this.position == 'none')
html += ' position: relative;'
else
html += ' position: ' + this.position + ';'
+ ' left: ' + this.left + 'px;'
+ ' top: ' + this.top + 'px;';
html += ' width: ' + (this.fullWidth) + 'px;';
html += ' height: ' + (this.fullHeight) + 'px;';
html += ' clip: rect(0 ' + this.fullWidth + ' '
+ this.fullHeight + ' 0);';
html += ' layer-background-color: ' + this.backgroundColor + ';';
html += '}';
html += '#B' + this.layerID + ' {';
html += ' position: absolute;';
html += ' width: ' + this.fullWidth + 'px;';
html += ' height: ' + this.fullHeight + 'px;';
html += ' clip: rect(0, ' + this.fullWidth + ', ' +
this.fullHeight + ', 0);';
html += 'layer-background-color: ' + this.borderColor + ';';
html += '}';
html += '#I' + this.layerID + ' {';
html += ' position: absolute;';
html += ' left: ' + this.borderWidth + 'px;';
html += ' top: ' + this.borderWidth + 'px;';
html += ' width: ' + this.width + 'px;';
html += ' height: ' + this.height + 'px;';
html += ' clip: rect(0, ' + this.width + ', ' + this.height
+ ', 0);';
html += 'layer-background-color: ' + this.backgroundColor + ';';
html += '}';
html += '#P' + this.layerID + ' {';
html += ' position: absolute;';
html += ' left: ' + this.borderWidth + 'px;';
html += ' top: ' + this.borderWidth + 'px;';
html += ' width: ' + this.width + 'px;';
html += ' height: ' + this.height + 'px;';
html += ' clip: rect(0, 0, ' + this.height + ', 0);';
html += 'layer-background-color: ' + this.color + ';';
html += '}';
html += '<\/STYLE>';
html += '<SPAN ID="' + this.layerID + '">';
html += '<DIV ID="B' + this.layerID + '">';
html += '<\/DIV>';
html += '<DIV ID="I' + this.layerID + '">';
html += '<\/DIV>';
html += '<DIV ID="P' + this.layerID + '">';
html += '<\/DIV>';
html += '<\/SPAN>';
}
else if (document.getElementById) {
html += '<DIV';
html += ' ID="' + this.layerID + '"';
html += ' STYLE="';
if (this.position != 'none')
html += ' position: ' + this.position + ';'
+ ' left: ' + this.left + ';'
+ ' top: ' + this.top + ';';
html += ' width: ' + this.width + 'px;';
html += ' height: ' + this.height + 'px;';
html += ' background-color: ' + this.backgroundColor + ';';
html += ' border: ' + this.borderWidth + 'px solid'
+ ' ' + this.borderColor + ';';
html += '"';
html += '>';
html += '<DIV ID="P' + this.layerID + '"';
html += ' STYLE="';
html += ' width: ' + this.width + 'px;';
html += ' height: ' + this.height + 'px;';
html += ' background-color: ' + this.color + ';';
html += ' clip: rect(0px, ' + this.width + 'px, auto, 0px);';
html += ' overflow: hidden;';
html += '"';
html += '>';
html += '<\/DIV>';
html += '<\/DIV>';
}
document.write(html);
}
ProgressBar.prototype.writeHTML = ProgressBar_writeHTML;
function ProgressBar_progressTo (percentage) {
if (document.all) {
if (!this.pbar)
this.pbar = document.all['P' + this.layerID];
this.pbar.style.clip =
'rect(0px, '
+ Math.floor(percentage * this.width) + 'px,'
+ ' auto, 0px)';
}
else if (document.getElementById) {
if (!this.pbar)
this.pbar = document.getElementById('P' + this.layerID);
this.pbar.style.clip =
'rect(0px, '
+ Math.floor(this.width - percentage * this.width) + 'px'
+ ', auto, 0px)';
}
else if (document.layers) {
if (!this.pbar)
this.pbar = document[this.layerID].document['P' + this.layerID];
this.pbar.clip.width = Math.round(percentage * this.width);
}
}
function ProgressBar_hide () {
if (document.layers)
document[this.layerID].visibility = 'hide';
else if (document.all)
document.all[this.layerID].style.visibility = 'hidden';
else if (document.getElementById)
document.getElementById(this.layerID).style.visibility =
'hidden';
}
ProgressBar.prototype.hide = ProgressBar_hide;
ProgressBar.prototype.progressTo = ProgressBar_progressTo;
ProgressBar.defaults = {
position: 'none',
left: 0,
top: 0,
width: 200,
height: 25,
borderColor: 'black',
borderWidth: 1,
backgroundColor: 'blue',
color: 'lime'
}
ProgressBar.cnt = 0;
ProgressBar.bars = new Array();
</SCRIPT>
<SCRIPT>
var pb;
var c = 0;
function progressDemo () {
pb.progressTo (c);
c += 0.1;
if (c <= 1)
setTimeout('progressDemo()', 200);
else
window.location="http://colorweb.go.163.com"
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="progressDemo();">
Progress Bar Demo:
<SCRIPT>
pb = new ProgressBar ();
</SCRIPT>
<BR>
</BODY>
</HTML>
qisanyou
2002-05-05
打赏
举报
回复
是不是这个:
http://www.qisanyou.com/csdn/load.html
你可以直接另存为,不过在此之后,别忘了给分哦.
huojiehai
2002-05-05
打赏
举报
回复
在MSE中用控件呀
javascript
实现
的
进度条
效果
javascript
实现
的
进度条
效果
javascript
实现
的
进度条
效果
用
javascript
实现
进度条
用
javascript
实现
进度条
----
Javascript
上传
进度条
精简
实现
以下是
一个
简单的
JavaScript
实现
: ```
javascript
function upload() { const fileInput = document.getElementById('uploadFile'); const file = fileInput.files[0]; if (!file) return; const formData = ...
用
JavaScript
实现
的
进度条
因为项目需要,自己开发了
一个
测试的
进度条
, 共测试使用。
css3+
JavaScript
实现
环形
进度条
在本示例中,我们将探讨如何利用CSS3和
JavaScript
技术来创建这样
一个
动态的、可定制的环形
进度条
。CSS3提供了丰富的样式功能,而
JavaScript
则负责动态更新进度。 首先,我们来看CSS3在环形
进度条
设计中的作用。CSS3...
JavaScript
87,996
社区成员
224,693
社区内容
发帖
与我相关
我的任务
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
分享
社区描述
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章