返回列表 发新帖

用htc实现进度条控件

499.3k 8
swmozowtfl 发表于 2015-7-9 22:53:17|湖北 | 查看全部 阅读模式
代码如下:
& d/ Y  q* f2 ^. m
<public:component> 6 V) q; B6 y, P3 x
<public:method name =init internalname =fncreateprogressbar />
6 x: s+ r: X" H0 f; x4 g* F0 S<public:method name =showprogress internalname =showprogress />
7 d" t/ R4 I! B- w<public:property name=container/> 1 l& M* E$ Z4 e" N
<public:property name=speed/> 1 N4 \4 ]1 P. O5 a! W8 Y9 b
<script language=javascript> 8 q$ B( F2 q6 ^( x% c3 V
var starttime = null ; & o  j5 r8 _% [& F5 s! h
function fncreateprogressbar(){
1 b) B( a+ O/ `. I8 _8 X/ N7 d# Dnow = new date();
6 _$ O# k9 i  Z! Ustarttime = now.gettime();
  r! a$ E! z: O, ]. i5 bnow = null 1 J1 |5 X' N: M% g4 N; `
ocontainer = element.container
! L) l! G# K6 {ocontainer.innerhtml = ; 8 x# j$ @; B! ^5 F3 \: A
odiv = window.document.createelement(div) - k2 t5 Z4 Y; ^
odiv.classname = progress   h9 R5 v( c/ u
ocontainer.appendchild(odiv) 6 y8 }/ K6 j6 B7 n
odiv.style.display = ; 4 i9 k* C0 I' Y. V  e: _  k) I5 E
element.bar = odiv;
% e1 E/ C" O+ j0 p/ R}
5 E4 w# e& J5 B  m- J. Wfunction pause(numbermillis) {
- h# t6 V/ f1 K$ B, ?! z  pvar dialogscript =
" R1 M: I& B1 G0 F/ ^& L% S6 O'window.settimeout(' + ( Q' G3 J1 X) g# J1 x8 M3 @
' function () { window.close(); }, ' + numbermillis + ');'; + P6 @! F9 K6 f  r* `4 r6 g2 @- w0 ]% F
var result =
* ^! F3 o% M% K. g+ R4 q6 N* awindow.showmodaldialog( ! y. @. O* m9 E8 B
'javascript:document.writeln(' + - P2 y/ {! p9 U. A! z) [1 A5 T6 Q
'<script>' + dialogscript + '<' + '/script>)');
% H; J+ I  q  F" U/ l% |}
- ?* O, m6 L. ^& ~8 S+ _7 Pfunction showprogress(statesdesc){
/ T: H. F: `2 Z, B+ u' D) jnow = new date();
1 w, H" \7 F% ]) m. @5 A0 Fcurrtime = now.gettime();
" p  Z, u1 d% P) Q/ n2 ?now = null & O8 L5 E* X/ J" k! {" M
if(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
4 \) W6 _: S9 I: b; Celement.bar.style.width = (currtime - starttime) / element.speed; # ]# Y- e- N% W  j5 B- }  \4 |
pause(1)
) O5 F& |3 _" Y( |3 |, V}
1 V" c& B4 V. Q: R7 j  `" `* n6 i, O</script>
; u+ W6 s& A: _" R5 f  g</public:component>
. }7 q1 G9 x% n. _1 ^2 h应用例子:
* V) _* ~  f" M% t- {- E代码如下:, s; B$ F( z& h" C3 O8 \% J
<html> ' V% T# e! {8 Y( a: }$ j
<head>
' [2 B  x1 ]- p+ a<meta http-equiv=content-type content=text/html; charset=gb2312> 3 ?5 H7 \! ^$ _# O5 n- N2 N
<title>进度条测试</title> 0 }: k" J( V4 t
<link rel=stylesheet type=text/css href=progressbar.css>
  k2 L3 M6 b: l) \3 G/ ^<script>
6 I& T4 d4 X: c! B- a5 Dfunction demo(){ % `" o! \/ |& H- Z6 ?: S
prgbar.container = document.all.layer1
8 X: a0 Y  j" h8 L; {( }: qprgbar.init(); 8 h; ^8 v/ A% w6 Y( K4 r/ U
for(var i=0;i<500;i++){
* D: M2 i$ o9 R" mif(i%5==0) prgbar.showprogress(操作进行中......) ! b: _1 T5 G, \, S" k/ S( C
}
2 Z2 S0 `- ^2 Aprgbar.showprogress(操作完成!)
0 p* o. p$ x3 Y- ~}
5 l+ F' X+ G: n% T( u</script> & c2 x9 [, V  _. H$ H$ N' G. d
</head> 0 w1 v8 H4 _& P- i: J
<body>
: C7 A( ^4 y7 M, D2 y" B5 N<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>
7 n' L5 o7 f; @. V$ e) e0 u2 m<p><input type=button value=测试 name=b3 onclick=demo()></p>
" o2 t( _" W4 o0 L<progressbar id=prgbar class=progressbar speed=10/>
7 z* b  L# J2 a/ P4 y7 w! T</body>
* {8 r5 \1 z& v</html>
. W/ ?, S: S2 h3 q' O! }样式文件:progressbar.css8 T: T6 o! ^; k5 }/ V. s6 `# w
代码如下:
3 o9 A, r9 w7 s9 b7 W. |% L7 x) ?
.progressbar ; _: o6 A. {- R( {
{   ~! G9 h3 K4 W4 Q/ h" x9 `/ p
behavior: url(progressbar.htc)
$ }+ `) @/ C4 X} 4 s  J1 S5 T& U' u; P% F
.progress{
9 X0 g: x% \. F. Z; e3 b6 \position: relative;
% v' v4 K2 z. h& Vwidth: 0px; $ Q- E  f4 g" {2 J
height: 20px; ( j! s1 t: E& D; G0 J5 j) Y9 g& \( `
z-index: 1;
: p: q* I  T# I% k  `3 j! Ubackground-color: #006699;
6 h+ S9 t2 h/ d8 sfilter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0);
* O/ P  R+ Z( [% \& Q7 xborder: 1px ridge #c0c0c0;
. t6 {/ e) t! U- Q$ _}
2 [* S5 |9 Z5 z  U% x- |& Z
1 h4 |. k4 x! ^$ p更多网页制作信息请查看: 网页制作

回复|共 8 个

Acropozelan 发表于 2015-9-18 19:46:03|哥伦比亚 | 查看全部
一骂人就激动....
GoodyFouppy 发表于 2015-9-18 19:46:08|瑞典 | 查看全部
你该这么说~~
GoodyFouppy 发表于 2015-9-18 19:46:41|美国 | 查看全部
哈哈~~~相比现在没人在了 吧 哈哈~~~~
buingeEvineus 发表于 2015-12-15 14:21:10|波兰 | 查看全部
下流~~~~加~~~~~至极~~~~~~
bqtklouu 发表于 2015-12-15 14:21:30|美国 | 查看全部
呵呵 没事怎么有点被讽刺的味道啊
gevaemaidovef 发表于 2015-12-15 14:22:07|法国 | 查看全部
呵呵 那是啊~~
alapScady 发表于 2015-12-15 14:22:17|日本 | 查看全部
对自己好点~别难为自己
wwdu926a 发表于 2015-12-15 14:22:22|Reserved | 查看全部
我怎么就踩不死你呢??

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

得知互动是一个融创意、设计、开发、营销、生活、互联网于一体的专业交流分享平台。
Copyright © 2026 得知互动-专注Ai与站长技术交流社区-Ai交流平台 版权所有 All Rights Reserved. Powered by Discuz! X5.0 鄂ICP备15006301号-5|鄂公网安备 42018502006730号
关灯 在本版发帖 扫一扫添加QQ客服 返回顶部
快速回复 返回顶部 返回列表