首 页
网络学院
视频教程
资源下载
HOT
实例教程
图文教程
专题中心
学习社区
繁體中文
当前位置:
首页
>
图文教程
>
网络编程
>
Javascript
> 一个已封装好的漂亮进度条
Javascript
Javascript实例教程(12) 隐藏script代码
Javascript实例教程(11) 创建\"后退\"按钮
HTC:浏览器上的舞者
JavaScript 小技巧(第四集)
Javascript实例教程(20) 使用HoTMetal(7)
点一下,首页地址添加到收藏夹(javascript)
Javascript设计漫天雪花
Javascript实例教程(21) OLE Automation(2)
Javascript实例教程(20) 使用HoTMetal(3)
Javascript制作闪烁的边框
JavaScript对象与数组参考大全
Javascript实例教程(21) OLE Automation(3)
利用JavaScript制作倒计时牌
Javascript实例教程(5) 利用Javascript创建对象
利用JAVASCRIPT制作简单动画
Javascript实例教程(15) JS代替CGI
Javascript实例教程(19) 数组
JavaScript[对象.属性]集锦之三
Javascript实例教程(21) OLE Automation(6)
JavaScript 小技巧(第一集)
No.
«
‹
9
10
11
12
›
»
技术文章搜索
关键字
Javascript 中的 一个已封装好的漂亮进度条
出处:
互联网
整理:
软晨网(RuanChen.com)
发布:
2009-10-12
浏览: 72 ::
收藏到网摘: n/a
使用prototype.js 的时候应该特别注意的几个问题.
漂亮的widgets,支持换肤和后期开发新皮肤
复制代码
代码如下:
<body>
<input type="button" value="start" onclick="processBar.changeMode();if(processBar.isMoving){this.value='Stop';}else{this.value='Start';}">
</body>
<script>
document.execCommand("BackgroundImageCache",false,true);
function ProcessBar(){
this.width = 256;
this.height = 18;
this.top = 0;
this.left = 0;
this.backImg = "process_back.gif";
this.foreImg = "process.gif";
this.backDiv = document.createElement("div");
this.foreDiv = document.createElement("div");
this.fontDiv = document.createElement("div");
this.isMoving = false;
this.nowLength = 0;
this.moveInterval = 100;
this.moveRange = 1;
this.timer;
ProcessBar.nowObj = this;
this.init = function(){
this.foreDiv.style.backgroundImage = "url(" + this.foreImg + ")";
this.foreDiv.style.backgroundRepeat = "no-repeat";
this.foreDiv.style.position = "absolute";
this.foreDiv.style.width = this.nowLength;
this.foreDiv.style.height = this.height;
this.foreDiv.style.top = 0;
this.foreDiv.style.left = 0;
this.fontDiv.style.background = "transparent";
this.fontDiv.style.position = "absolute";
this.fontDiv.style.width = this.width;
this.fontDiv.style.height = this.height;
this.fontDiv.style.top = 2;
this.fontDiv.style.left = 0;
this.fontDiv.style.textAlign = "center";
this.fontDiv.style.fontSize = "13px";
this.fontDiv.appendChild(document.createTextNode(" "));
this.backDiv.style.backgroundImage = "url(" + this.backImg + ")";
this.backDiv.style.backgroundRepeat = "no-repeat";
this.backDiv.style.position = "absolute";
this.backDiv.style.width = this.width;
this.backDiv.style.height = this.height;
this.backDiv.style.top = this.top;
this.backDiv.style.left = this.left;
this.backDiv.appendChild(this.foreDiv);
this.backDiv.appendChild(this.fontDiv);
document.body.appendChild(this.backDiv);
}
this.changeMode = function(){
this.isMoving = !this.isMoving;
if(this.isMoving){
this.timer = window.setInterval(ProcessBar.nowObj.moving, this.moveInterval);
}else{
window.clearInterval(this.timer);
}
}
this.moving = function(){
ProcessBar.nowObj.nowLength += ProcessBar.nowObj.moveRange;
ProcessBar.nowObj.foreDiv.style.width = ProcessBar.nowObj.nowLength;
ProcessBar.nowObj.fontDiv.firstChild.data = Math.ceil((ProcessBar.nowObj.nowLength/ProcessBar.nowObj.width )*100) + "%";
if(ProcessBar.nowObj.nowLength >= ProcessBar.nowObj.width ){
window.clearInterval(ProcessBar.nowObj.timer);
ProcessBar.nowObj.fontDiv.firstChild.data = "Complete!";
}
}
}
var processBar = new ProcessBar();
processBar.backImg = "/upload/tech/20091012/20091012084645_7647966b7343c29048673252e490f736.gif"; processBar.foreImg = "/upload/tech/20091012/20091012084648_f0935e4cd5920aa6c7c996a5ee53a70f.gif"; processBar.top = 100;
processBar.left = 20;
processBar.init();
</script>
点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]
使用prototype.js 的时候应该特别注意的几个问题.
漂亮的widgets,支持换肤和后期开发新皮肤
评论 (0)
All
登陆
还没注册?