zoukankan
html css js c++ java
JS实现的进度条
//
进度条
//
<input type="button" value="start" onclick="processBar.changeMode();if(processBar.isMoving){this.value='Stop';}else{this.value='Start';}">
//
---------------------------
//
<script language="javascript" src="ProcessBar.js"></script>
//
<input type="button" value="start" onclick="(new ProcessBar()).changeMode();">
//
可实现方法:doProcessBarAction()
//
---------------------------
function
ProcessBar()
{
var
divG
=
document.createElement(
"
<div style=\
"
background: url(
'
../image/0.gif
'
) no
-
repeat;margin:
0
auto;text
-
align:center;256px;height:18px;position:absolute;top:
45
%
;left:
40
%
;font
-
size:13px;z
-
index:
1000
;\
"
></div>
"
);
var
proc
=
document.createElement(
"
<div id='proc' style=\
"
background: url(
'
../image/1.gif
'
);position:absolute;top:
0
;left:
0
;0px;height:18px;font
-
size:13px;z
-
index:
1000
;\
"
></div>
"
);
var
div2
=
document.createElement(
"
<div style='position:absolute;top:2;left:0;256px;height:18px;text-align:center;font-size:13px;background:transparent'> </div>
"
);
divG.appendChild(proc);
//
divG.appendChile(div2);
document.body.appendChild(divG);
document.execCommand(
"
BackgroundImageCache
"
,
false
,
true
);
var
obj
=
proc;
this
.isMoving
=
false
;
this
.maxLength
=
parseInt(obj.parentNode.style.width.replace(
"
px
"
,
""
));
this
.nowLength
=
parseInt(obj.style.width.replace(
"
px
"
,
""
));
this
.moveInterval
=
100
;
this
.moveRange
=
1
;
this
.timer;
this
.obj
=
obj;
ProcessBar.nowObj
=
this
;
this
.changeMode
=
function
()
{
this
.isMoving
=
!
this
.isMoving;
if
(
this
.isMoving)
{
createBgDiv();
//
创建页面蒙版
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.obj.style.width
=
ProcessBar.nowObj.nowLength;
//
ProcessBar.nowObj.obj.parentNode.lastChild.firstChild.data = Math.ceil((ProcessBar.nowObj.nowLength/ProcessBar.nowObj.maxLength)*100) + "%";
if
(ProcessBar.nowObj.nowLength
>=
ProcessBar.nowObj.maxLength)
{
window.clearInterval(ProcessBar.nowObj.timer);
//
ProcessBar.nowObj.obj.parentNode.lastChild.firstChild.data = "Complete!";
//
执行事件
try
{
doProcessBarAction();
}
catch
(e)
{}
delBgDiv();
//
清除页面蒙版
}
}
}
//
var processBar = new ProcessBar(proc);
//
页面蒙版
function
createBgDiv()
{
var
h
=
document.body.clientHeight;
var
w
=
document.body.clientWidth;
var
div
=
document.createElement(
"
<div id='divDialogBg' style='position:absolute;visibility:visible;background:gray;filter:alpha(opacity=30);z-index:1000;left:0;top:0;
"
+
w
+
"
px;height:
"
+
h
+
"
px;'></div>
"
);
//
div.appendChild(document.createTextNode("xxxxxxxxxxxxxxxxxxxx"));
document.body.appendChild(div);
}
function
delBgDiv()
{
document.body.removeChild(document.getElementById(
"
divDialogBg
"
));
}
查看全文
相关阅读:
拍皮球 (Java实现)
余弦 (java实现)
循环输出
从1输出n位数字
数值的整数次方
旋转数组的最小数字
简单使用栈实现队列
重建二叉树
链表逆序输出
替代空格
原文地址:https://www.cnblogs.com/ding0910/p/1022561.html
最新文章
闭包的认识
overflow:hidden;和clear:both;的不同点
ssm重新开发计科院新闻网站
spring配置与使用
SpringMVC基础配置及使用
EL表达式
MyBatis的使用步骤及配置
javabean
JSP
过滤器的使用
热门文章
COOKIE和Session的原理及异同
session的使用
数据结构实验之串一:KMP简单应用
数据结构实验之栈与队列十一:refresh的停车场
数据结构实验之栈与队列十:走迷宫
数据结构实验之栈与队列八:栈的基本操作
数据结构实验之栈与队列七:出栈序列判定
数据结构实验之栈与队列六:下一较大值(二)
数据结构实验之栈与队列三: 后缀式求值
数据结构实验之栈与队列二:一般算术表达式转换成后缀式
Copyright © 2011-2022 走看看