代码如下:) {0 z( w' M" b7 z; I2 W
<public:component>
5 e U" U T/ }5 m<public:method name =init internalname =fncreateprogressbar /> + H' e, U; u; B* [
<public:method name =showprogress internalname =showprogress /> 5 U/ `" A j0 t2 B
<public:property name=container/> / e: f8 b$ r* c
<public:property name=speed/>
5 y: o( E6 l7 P) o% s<script language=javascript>
- W. d% T _4 w, G6 @9 f3 A7 ^var starttime = null ; & A( t+ {5 \1 G7 [+ V9 n4 ^
function fncreateprogressbar(){
; @/ k/ |( {$ l& G9 hnow = new date(); 7 q8 r! B; }) x. m% \
starttime = now.gettime();
$ L. {' F( s- Q: j6 q/ Inow = null
( h9 \" h3 A# I3 }/ {( vocontainer = element.container
+ c6 x' f/ W9 Tocontainer.innerhtml = ; 2 |( U6 e, W! U! X
odiv = window.document.createelement(div) # S- R2 y. o9 S$ d+ E; C
odiv.classname = progress
5 D6 Y+ ]* D3 jocontainer.appendchild(odiv)
$ }' \5 w! v% N& v+ d) Zodiv.style.display = ;
8 Y7 l: z; Y# p6 v3 ]element.bar = odiv;
* `3 J% g" b) h}
2 X0 S w1 }7 ^function pause(numbermillis) {
( l2 J1 o u0 J/ bvar dialogscript =
. l3 G0 ?# N. `5 F* j7 ?'window.settimeout(' + * i# s: g+ d6 c
' function () { window.close(); }, ' + numbermillis + ');';
4 L6 E% P( V2 {, E- o. @var result = 7 d% j2 v5 [/ a! M* s+ f
window.showmodaldialog(
8 G8 H4 o. r8 {" I& _'javascript:document.writeln(' +
9 z9 _# j7 S. \" t. W# \: {'<script>' + dialogscript + '<' + '/script>)'); 0 b$ ~& V6 f( w) M% S/ E
} 3 m7 o+ B2 _' p- l# d
function showprogress(statesdesc){
j4 S8 l9 `; J7 ]& _0 Xnow = new date();
% n: f" F7 _1 Vcurrtime = now.gettime(); . z/ Z" k; w' @& h: d& b3 W
now = null
+ |6 z) y! n; m) c5 J1 Dif(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
# L+ z) F# I X2 K) g' |, aelement.bar.style.width = (currtime - starttime) / element.speed;
% N- u9 ?# i( M) L) i6 a' tpause(1) 7 x9 y; ]6 f% K" r/ e' P/ _5 B: b& h
} # I. y. g* P* p) S9 j: V3 o
</script>
# E/ S& w: F: n# b</public:component>) V& l1 ]& a2 k
应用例子:# Q. K- ~% v+ f" S/ \! d% v+ B
代码如下:
, p% ]6 A9 x* i) R0 C2 x, O<html>
# [5 P' G. r4 c, s8 u9 O4 [<head>
# r8 i4 T& |5 t& O, Y<meta http-equiv=content-type content=text/html; charset=gb2312> % B2 E$ h" l* k1 t4 `( [
<title>进度条测试</title>
: Z0 o4 I' K+ J; H! F) r8 i<link rel=stylesheet type=text/css href=progressbar.css>
& _( _8 S) Z3 _<script> 6 h1 {+ ~' v! U
function demo(){ * O) L4 W2 \1 L" Z! t! p v5 p4 m: Z
prgbar.container = document.all.layer1
" m5 S! M. x, K2 H- G# cprgbar.init(); $ q3 ~9 a2 a! B: ?* p
for(var i=0;i<500;i++){ # Z( }* ]9 ~ ^6 F
if(i%5==0) prgbar.showprogress(操作进行中......) / ?+ Z" ]' v7 b" }
}
8 b @- s. g. S% t3 bprgbar.showprogress(操作完成!)
+ y$ Z0 u3 _- r0 F}
# ^- c3 m/ ?# {( }3 Y( ?- L</script>
% N' f9 @2 J: v( i8 d</head> 1 }/ Y a& a& ?; ~3 I3 `- } H a* r
<body>
) T% U7 G1 q: W# s# }<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>
1 `7 O. c1 Q0 T( M: L7 U4 `<p><input type=button value=测试 name=b3 onclick=demo()></p>
2 q, q" I5 E9 i5 s, _9 a! ]<progressbar id=prgbar class=progressbar speed=10/> 0 _4 m( Y) E1 m* ]( L2 L$ B! x- @
</body>
3 H+ W9 f' ~5 |, e% m' }( @- p</html>
. d0 `- X$ c) B, p样式文件:progressbar.css
& v+ S, @3 J! L代码如下:
6 }! m; i# }! g k- c.progressbar
4 X$ t% d/ m V S% F0 q; Z; F{
+ w) u4 O. S0 X( |! ibehavior: url(progressbar.htc)
" }: i9 h( g6 W4 W; W* V}
3 m& [4 w Q9 N.progress{ 9 q; M* u% ?' Q i6 y. |8 A
position: relative;
3 `0 A( b5 C5 Z& C+ Lwidth: 0px; 8 ~. ~8 L3 u# s0 P
height: 20px; $ }3 z4 o: B" x
z-index: 1;
: a$ I& Z& N/ [background-color: #006699; ) k, u( x4 E5 e |3 w, [ q
filter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0); 3 R: ?3 o; e: n
border: 1px ridge #c0c0c0; ! V) C+ H8 G& R
}
* t0 f3 _# W, i+ k8 ?3 F6 u7 n' O; }$ `7 C' C) Z
更多网页制作信息请查看: 网页制作 |
|