代码如下:
- S; G; c T9 f: ]5 S- S<public:component> + M$ V+ E- f3 ~& @ y" r
<public:method name =init internalname =fncreateprogressbar />
" K" D* }" E; n. w; k* z( W<public:method name =showprogress internalname =showprogress />
+ u! B$ a: `" G<public:property name=container/>
/ p% o: \8 K/ B3 @, F3 U/ i<public:property name=speed/>
: m2 {. A( i; i: s1 |<script language=javascript>
9 n6 C: V/ W! Bvar starttime = null ;
. t' s% d k+ t% W. E) yfunction fncreateprogressbar(){ . V* Q( x6 A) c
now = new date(); X' q; r2 W& f R
starttime = now.gettime(); 3 `' s1 D- x1 @7 R, j) b) ^
now = null 9 `: r0 G. p' g+ B% ~: D
ocontainer = element.container
# O5 }6 x7 w. C9 ~, T" u1 Kocontainer.innerhtml = ; 6 }* z0 g& i' Z3 Q
odiv = window.document.createelement(div)
/ e+ d1 Y6 ~4 n6 v6 ]1 xodiv.classname = progress : v/ Q% |2 g! d, [9 Y
ocontainer.appendchild(odiv)
9 Y% _/ n; T5 u0 p" T+ a& {odiv.style.display = ; 3 D3 X% o5 ]4 Y$ A# F9 s+ I% z
element.bar = odiv; ' ?9 ]/ U5 K6 n+ b g" j m
} 0 p; y8 s( U; h
function pause(numbermillis) {
1 V& I* R) U! f, t; O% N- h# ]8 A; ~var dialogscript = ; B3 S- g6 p5 ^8 Q. |+ X2 ]! Y# e! i
'window.settimeout(' +
' r8 y9 p) [5 V5 ?8 g' B' function () { window.close(); }, ' + numbermillis + ');'; ( U' l/ j( @! T
var result = 7 V4 d! n$ _! I, B+ i$ `1 h% ^
window.showmodaldialog( ! r. ?, ^$ I( q5 |$ j: y% [
'javascript:document.writeln(' +
( L% r, P& e# ^" ^# ^'<script>' + dialogscript + '<' + '/script>)');
) i, w4 T/ e/ f9 T" p1 e- K! D}
: U+ x$ f% S# ^3 v% ~function showprogress(statesdesc){
4 j5 o/ w# V X7 n& Z3 hnow = new date();
, z' ^8 f+ g: q; @currtime = now.gettime(); ' ]9 Z* |1 B$ ]$ P
now = null 2 j* C2 @8 X' P3 t- L( Q6 M
if(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
8 V$ h; b/ D4 J: }4 Yelement.bar.style.width = (currtime - starttime) / element.speed; x9 k# `( U7 u' z5 O& _& E
pause(1)
' O) F b/ W J}
4 W- t0 A6 R& c/ q. w</script> . C3 ^1 d, w* i: n; Z/ _! n
</public:component>3 u, \: L, `2 G5 p# w7 n
应用例子:
1 O* d% V6 e) A/ G7 c$ `1 `代码如下:
+ W) y9 X$ P( z0 H<html> 9 m1 Z; b. `5 T: ?- q! u. P
<head> 3 ^- H$ O6 j) p3 P5 `% b- a
<meta http-equiv=content-type content=text/html; charset=gb2312> 5 e6 u( t3 ]( T0 T; G
<title>进度条测试</title>
7 [; K0 {: o. r9 ~1 B u- I<link rel=stylesheet type=text/css href=progressbar.css> * J' j5 f. b1 e7 m/ z9 H6 L0 j
<script>
4 \6 U+ S7 S$ x9 J8 ]function demo(){
$ d r2 s+ C+ m4 E: Nprgbar.container = document.all.layer1 * b4 J2 b! H m2 F
prgbar.init();
# {' m1 B' H- M0 Kfor(var i=0;i<500;i++){
' Y# M/ Q+ k1 pif(i%5==0) prgbar.showprogress(操作进行中......) 2 m5 q8 }) l1 \) M
} " r& G b8 M/ y+ i0 W
prgbar.showprogress(操作完成!)
# B0 Y$ V6 p5 ]: L7 W7 D}
4 n/ y9 {; s5 z7 {9 q$ x</script> " Y* y7 G! g" q* R) [' }
</head> ! Z( K' E: p* G& e
<body>
9 x/ [3 y+ j# V# @. a+ i( Y+ h<div style=position: absolute; width: 612px; height: 19px; z-index: 1; left: 10px; top: 72px; border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px id=layer1></div>
4 |; }7 X( t- ^' e) o0 h0 ]9 @<p><input type=button value=测试 name=b3 onclick=demo()></p> # F. R" p" n _9 N
<progressbar id=prgbar class=progressbar speed=10/> , l# ]- s/ b9 V' W- w
</body> / `2 h4 Q( O/ v+ h
</html>
8 I. o. C) Y9 o) H9 t ^2 I7 F样式文件:progressbar.css0 _7 Q) _/ g% E# I
代码如下:& E( P% z; s8 i
.progressbar & i t! \: A# \+ @
{
' c$ u6 F1 w6 o; \1 Mbehavior: url(progressbar.htc)
3 I9 K, Z+ ^6 x% |) g& ?} 3 o* o) Q5 D3 K. N% ^! ]( t
.progress{
8 W8 w% L0 E$ Z) h- \( E8 D& }, mposition: relative; u* `4 f' ?; ~+ O. E( I/ l5 Y
width: 0px;
) v3 i5 v1 Z5 k2 z' ^/ Fheight: 20px;
! O$ b1 j. G+ X1 N, M/ h/ q4 Cz-index: 1;
. f* p7 e$ z' C! B3 F4 T! v/ s9 Cbackground-color: #006699;
: X* U. Z! H1 d% S& afilter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0);
) _: ?+ s& P4 h, L7 mborder: 1px ridge #c0c0c0;
- J. e# t1 s/ ?5 @% p}
# S+ h& T2 h5 K6 u: Q2 Y- c# I1 H
9 D, _- ^4 j, L8 k9 A* ?, c5 d# _: `7 n更多网页制作信息请查看: 网页制作 |
|