代码如下:
F# n. U: e |' f# u<public:component>
! Z% f& K; T+ [2 K9 I+ c! C<public:method name =init internalname =fncreateprogressbar />
8 c0 ?, y- T3 o$ m8 \, G6 O<public:method name =showprogress internalname =showprogress />
" _1 y- K% G7 P6 |<public:property name=container/> ! [, p7 s* ]& U( A4 ~5 B$ R
<public:property name=speed/>
- E) @+ g" B, }: G5 m+ I/ ^5 C5 Y<script language=javascript> 7 ]. T( N6 _3 z5 V& T6 v
var starttime = null ; ! Z6 b+ L) M* k; _/ w- f0 ^
function fncreateprogressbar(){ 0 a4 V6 O7 {! M7 X; _0 p
now = new date();
5 k3 w/ s$ \1 o/ N! x6 h6 g$ Qstarttime = now.gettime();
; l/ i: [$ S2 q1 ~% r8 Vnow = null 3 Q; i, H# c8 |4 a3 t6 Z t
ocontainer = element.container ( T9 q4 b# i6 C6 f3 ?- T
ocontainer.innerhtml = ; 0 F. @0 k. a, _6 Q7 K
odiv = window.document.createelement(div)
8 P0 [0 u# L. k4 j" v* G; Rodiv.classname = progress
" O, o3 P6 Q6 @" Bocontainer.appendchild(odiv)
3 g* [# G% F7 ]1 ~odiv.style.display = ;
4 G' Y; E4 [- @# G' \$ c Aelement.bar = odiv;
$ O0 y; g) H& _2 E* P8 i" j} 9 V3 s, R2 ~7 U. K/ z. o6 O
function pause(numbermillis) { 4 V5 p: m0 C5 L6 W; N% d. C
var dialogscript =
" r- _1 p1 ~3 U g'window.settimeout(' +
) H' S7 ^6 @& y8 t% `& ]& ?9 G, w" {/ M' function () { window.close(); }, ' + numbermillis + ');'; 3 U2 y$ y9 I. ~ p* _- u0 j
var result =
, f4 L' r# K. f7 B) b' j' fwindow.showmodaldialog( : S; `; h! M! _
'javascript:document.writeln(' + H, }6 M" b) A+ @* x* d( J( q6 `
'<script>' + dialogscript + '<' + '/script>)');
" \" Y `$ b+ i7 c9 \4 Q \) u}
F9 H# }: g5 ?function showprogress(statesdesc){ 8 c) D+ N( K; V7 u5 c- c3 q$ [# z
now = new date(); # M( a! b: F$ r+ j
currtime = now.gettime();
4 B" q4 H$ v, T- {* X3 H1 F. F1 w; ?; Snow = null
8 x1 e& [" D2 P' L% R6 h: `. Rif(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
d- g$ ]; c3 f$ e2 x+ `8 g. R. `0 Felement.bar.style.width = (currtime - starttime) / element.speed;
' \) g2 [9 V( s8 [, G% J: hpause(1)
% a, s$ m, c$ D# s, e- Z& K}
4 z, a& E0 p- }6 k</script> 1 G; l) ?' w( ^9 p5 _8 i
</public:component>% y. A0 Y% I' B& v V
应用例子:
) ]# p9 [. o; p3 u( i代码如下:
9 E2 \8 ?$ k/ e1 ~: ~<html>
* B2 g& ^1 V. i4 M<head>
, ?5 c7 S9 Y) M, r. K6 E2 S8 U4 W<meta http-equiv=content-type content=text/html; charset=gb2312>
# c4 T2 d6 Y5 x3 h, s<title>进度条测试</title> 9 |: p6 u3 m0 ^7 g$ e9 K6 a
<link rel=stylesheet type=text/css href=progressbar.css> - Y3 s/ h9 \0 V0 A2 e, M4 C
<script>
8 s I( P9 Q! K/ H! ? o" B$ b0 hfunction demo(){
" D8 S! B5 f% Eprgbar.container = document.all.layer1 9 T3 v) D) d+ h/ K( V# `
prgbar.init();
. [. k7 h% ^; Efor(var i=0;i<500;i++){
) L7 U( I" R; @% wif(i%5==0) prgbar.showprogress(操作进行中......)
' [: h5 l \$ ^ h) L}
$ N- ~6 P" g# ?6 d7 P; kprgbar.showprogress(操作完成!)
8 E: W! h' q& c3 G7 ~ \ Z} 1 Y- N Z# g0 w2 n
</script>
m3 u* S5 L( f2 o$ w, `</head>
9 g" I: G% e# Z<body>
& e0 }) j/ v, c( X<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> ( B" z2 o" O( R, n6 o3 u0 ?" `
<p><input type=button value=测试 name=b3 onclick=demo()></p> ) {# F8 U7 Y) J F2 n
<progressbar id=prgbar class=progressbar speed=10/> |* w2 o6 X l8 G; v
</body>
3 F4 j" x: N" }0 G3 R3 K+ k$ P) r</html>/ f! J/ s5 [6 P4 w
样式文件:progressbar.css
% a* N% O' C2 Z! a* U% k6 b代码如下:
0 K5 ~6 y% ? a' Q1 X: a6 v" o4 A.progressbar 3 x) `! o1 N7 h0 q2 P6 M+ i' Z
{ 8 m7 H; a% E1 x' T; m
behavior: url(progressbar.htc) / R( D3 }$ Q/ l& n
} % ~/ f! ~9 K: P, L( |3 V' v
.progress{ + h7 o% u+ Y9 U8 @
position: relative;
, _9 Z# o2 C2 ?width: 0px;
8 I, |9 [% e' n/ Cheight: 20px;
0 d: s) A+ u, E6 B! ]5 g6 F6 P2 cz-index: 1; 6 d- W9 f" i. b9 D( {! z
background-color: #006699;
' w, l% {1 c. {filter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0);
3 i% ^9 ]4 p& [* F& W- M/ Qborder: 1px ridge #c0c0c0; ; P& w- D! @4 k, G5 S
}, p& _2 g# S" j+ ^* i
9 X# d7 w* h+ y* \/ Y# s更多网页制作信息请查看: 网页制作 |
|