代码如下:8 P) r6 l) F2 {1 R+ D
<public:component>
: [) o" k! |4 M9 R6 ?0 k' X<public:method name =init internalname =fncreateprogressbar />
/ c/ t% f7 \5 g# o' i; U- Z<public:method name =showprogress internalname =showprogress /> ) n) {8 }6 y3 h* u' D
<public:property name=container/>
9 |8 u- G9 P- ^7 t/ g<public:property name=speed/> * L/ |7 j9 r, e1 m [$ k; x
<script language=javascript>
: {" u+ j* g2 K* r; F& T' T! b% qvar starttime = null ;
' k% m$ X! c) {7 B2 efunction fncreateprogressbar(){ # H; J C! Q& @
now = new date(); * w0 W& b9 g" @& u
starttime = now.gettime(); 3 g7 S0 M8 ?0 ^/ K5 \8 S5 E
now = null
- p, `0 K8 S8 Mocontainer = element.container
# U$ S P1 _$ E4 socontainer.innerhtml = ;
8 @$ J6 y! Z7 P- |9 u# T# Kodiv = window.document.createelement(div)
8 l1 f0 W4 { Q) y. F E( j# | Hodiv.classname = progress 5 Y, D0 b% {5 U4 z
ocontainer.appendchild(odiv)
7 \7 e- ~) m' Q* Vodiv.style.display = ; " T0 H4 d, ^& l( D5 ~4 S$ H J
element.bar = odiv; 6 T4 N, r* u* l, X- {% i& J
} . l, w8 n! v" H; v& |6 w& h7 a" z
function pause(numbermillis) { / Q3 y* y% f! p, P- S
var dialogscript =
; P* W9 c" t9 z( z a% i'window.settimeout(' +
; [4 h% A6 [& I$ u( S8 Y' function () { window.close(); }, ' + numbermillis + ');';
, W% S$ S( ]! H6 R+ M X6 Dvar result =
6 _" u+ j. n4 cwindow.showmodaldialog( ; y3 H4 ` i) k4 l% h
'javascript:document.writeln(' +
9 n& Y7 c$ S; J4 o: S1 z'<script>' + dialogscript + '<' + '/script>)'); . y0 D- C: c" s% @
}
$ F# z% [& y) v; O. h+ y7 e6 qfunction showprogress(statesdesc){
5 D" J8 d% j- f! @+ ~7 A: pnow = new date();
1 y( R/ K9 C& E9 k' L' acurrtime = now.gettime();
3 h6 {" o* u- r( U# w5 k/ n1 Vnow = null
5 h- U0 S3 A/ a: u' iif(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!; ; O( [2 Q* X7 R$ E# s$ n! y
element.bar.style.width = (currtime - starttime) / element.speed;
& _, E* T7 l x g Qpause(1)
% U& e$ Z0 ]8 }: ^5 T1 f} 9 Z8 W3 J, ~+ ^% }' U, C
</script>
' v2 n4 t. a% I$ U/ d% S/ |' |3 a* K</public:component>8 l6 R& L! Z% j0 N! N) u$ M, H5 ~
应用例子:5 @2 _( m; y2 Y2 N
代码如下:
. [ m' ~) P# [* d- |<html>
# O" p9 ^2 q) y- P<head> : v2 s1 r6 [! R3 `% W- ], a
<meta http-equiv=content-type content=text/html; charset=gb2312>
- r8 o* w' l: U0 g" i: e<title>进度条测试</title> 6 U& R- c9 l, l. x5 O; e+ M! M
<link rel=stylesheet type=text/css href=progressbar.css> ' L3 Y6 r/ @7 n% E% q- H
<script>
6 G A$ x* q5 `0 jfunction demo(){ 5 e! x, l7 t. ]# X. _
prgbar.container = document.all.layer1 % k T4 }0 H) K) H
prgbar.init(); + K6 f* u/ |/ w; h" v8 Y k
for(var i=0;i<500;i++){
4 f* o. d! \" C4 }+ l1 S/ G1 pif(i%5==0) prgbar.showprogress(操作进行中......) ; M. V5 Y3 B" w$ A
}
1 _, E/ Q$ z) l% ^9 E+ H' X& Qprgbar.showprogress(操作完成!) 5 D( \: p! X4 r& [$ M9 C5 z
}
( | r0 B) C" \: \! p \</script>
' D+ w, X" b; @* P( A# C" \) d</head> / s7 g3 G( K5 {
<body>
( {) ]$ l3 t) y- Q& E4 L<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>
3 ?0 d( r, X9 s3 u<p><input type=button value=测试 name=b3 onclick=demo()></p> , L& h h3 p# R' K! U- P
<progressbar id=prgbar class=progressbar speed=10/> . R, R2 }% b* k2 @: a! V( K
</body>
4 D& \. I/ W- `3 ]6 P' D6 s+ L</html>
7 w, B' v' v) f! \* `样式文件:progressbar.css- L$ m% |* M8 [8 z) K
代码如下:3 l( i* ?* y) e6 ]
.progressbar
6 \* f5 j0 l" Z/ [8 Z+ u. s0 n{
) Y+ l% S& F4 \3 a Gbehavior: url(progressbar.htc)
% f4 x* ?9 T. Q% T}
1 `! b$ I! [+ {( Z) b& @3 n" n! e$ R.progress{ 6 c+ k! K' r" f$ I. Y
position: relative;
+ _7 ?! M& \) c7 Z6 [- \width: 0px;
! q4 `: R+ J; A6 H$ theight: 20px;
. ^8 x7 ^' _; z& [& H/ Jz-index: 1;
6 \' G) D( [$ v* u+ y! {& kbackground-color: #006699;
y* m Q5 g0 s( D- x4 Sfilter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0); 0 Q# y0 W, z1 x8 b& M6 |3 o9 Y4 _6 L
border: 1px ridge #c0c0c0; & X: S, W6 P# _# O2 l% P' T
}5 l& m0 R) r- q% I- c* C4 }
: g% z2 B w ~更多网页制作信息请查看: 网页制作 |
|