返回列表 发新帖

用htc实现进度条控件

499.2k 8
swmozowtfl 发表于 2015-7-9 22:53:17|湖北 | 查看全部 阅读模式
代码如下:
! }; Y$ I' r# E& y- }$ D
<public:component>
4 J( A" L+ Y/ k/ r: R/ h6 C: v* w<public:method name =init internalname =fncreateprogressbar /> 2 T5 i7 g+ i. K6 y. J4 Z
<public:method name =showprogress internalname =showprogress /> + o9 K$ {3 G. `5 A2 d; O1 K: A1 o. F& o
<public:property name=container/> + z' F- `4 G  @% @( ^# L4 t
<public:property name=speed/> * y7 i2 W: M# h3 |! m* [" w% X8 M
<script language=javascript> 9 I1 h- k% @7 }0 V# \! W6 G
var starttime = null ; # P  n# k4 v0 y/ C, w
function fncreateprogressbar(){ ; P1 K) B3 X0 }  @+ k' N6 E
now = new date();
" w' L( d3 z4 n/ W" |starttime = now.gettime();
9 o  C8 z% b# _, i2 W% ?' Rnow = null
8 u7 S$ Q' X  p- ^, h7 Z4 i3 G* Y! socontainer = element.container ( E  f( i( P' z  A) `! _$ |
ocontainer.innerhtml = ; & C5 k% ^9 o. q9 e5 O
odiv = window.document.createelement(div) . y/ W$ p3 s0 k
odiv.classname = progress
0 w( W6 n* b- Y5 b7 locontainer.appendchild(odiv) 3 ^  N5 d' ^; @/ A" B+ ?4 @
odiv.style.display = ;
; R+ _" @2 u0 uelement.bar = odiv; / `5 {+ J# ]# f- e+ J! ~' t
}
- n2 O3 N2 w# A% Jfunction pause(numbermillis) { 6 _4 Z# J9 ^0 g
var dialogscript =
& n: x! r6 i  m; v* z( ~! S2 k'window.settimeout(' + & `. u0 h' C0 u8 c4 }
' function () { window.close(); }, ' + numbermillis + ');'; ) ^) O. e8 p+ T9 [5 g! n
var result = ( Y! `9 F+ a4 Z! u
window.showmodaldialog( % W5 `6 d% l$ n# t* {# F
'javascript:document.writeln(' +
6 I& T6 f! Y6 W0 o- i'<script>' + dialogscript + '<' + '/script>)'); * J+ U5 L2 G. \' |; Q1 M; Y
}
5 [5 `; g( L6 b$ E2 b  x- |function showprogress(statesdesc){
; N- E  v3 w8 ?! Q; I) snow = new date(); 7 m( S% j' ?) S- w# p' |' r
currtime = now.gettime(); , m  x9 G! W, `% u- L# A1 C
now = null
  O: M& ?9 E; U7 l8 }. G  A, [if(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
8 F+ ^: A* t7 t! A; B' delement.bar.style.width = (currtime - starttime) / element.speed; 9 S3 M! o; d7 U' [. X
pause(1) ! x$ Q, \" `1 H8 r$ Y3 H: f
}
( Q: q! x/ E5 X! m6 T</script>
+ h7 O, A# D! \0 d</public:component>2 u% l9 m" @+ j: q: a. G* J
应用例子:
$ T$ N' }9 I+ n  ~代码如下:
! c  e0 k4 z# y+ e# ~+ A
<html>
+ {! p" U! X% Y) e) b( Y<head> . x  N0 X- B* y' z
<meta http-equiv=content-type content=text/html; charset=gb2312> 5 @2 p  T3 J- [  L, k" n# x
<title>进度条测试</title>   @) F$ M* _$ g7 b% `6 Q' [( U5 k6 [
<link rel=stylesheet type=text/css href=progressbar.css> 2 `  H2 z7 G5 V! V+ p$ p
<script>
- l( z3 W. M; u! O. g3 Tfunction demo(){ " Q0 g! p# U1 W: d. d$ c
prgbar.container = document.all.layer1
5 I# p7 d( B; ~6 f5 |$ a7 zprgbar.init(); + b( @  Z* s- ?0 q
for(var i=0;i<500;i++){
# f/ T# a, w- Q8 E" e6 p  C( ]if(i%5==0) prgbar.showprogress(操作进行中......)
% _- K7 S; x+ V  o: a9 P) p  n7 ?}
$ |* `) x: m1 q/ S$ q$ i2 A" Pprgbar.showprogress(操作完成!) ! M8 d$ \1 V2 \' P( z0 K  A- u9 ^
} / @7 M7 f) G& T4 `) \
</script>
0 S, K/ r% y/ Q1 x0 h</head> + z+ q4 C/ ]) m4 g4 y
<body>
1 N- T2 W+ s& D' I<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>
9 b1 ^7 w/ O( e9 c' j<p><input type=button value=测试 name=b3 onclick=demo()></p> " g# }2 m! D5 Y9 Z( B( B4 z
<progressbar id=prgbar class=progressbar speed=10/>
" }6 V" a; }# q+ ?/ t" L$ b</body>
: I, u9 r$ g. p6 i+ u6 Q- \</html>7 c( N- Y7 G5 f+ x0 r
样式文件:progressbar.css
  O  H" l3 M. Z; v& E代码如下:+ y7 o: Q; E3 o% C# o2 `
.progressbar ; a9 s8 q# v. ?3 `+ n/ ~
{ 8 s9 }/ X( F8 \0 c1 y* ~
behavior: url(progressbar.htc)   o0 H- ^( \) D5 c0 N
}
) G- L, m0 i8 P- c3 I$ ]; M8 d, A.progress{
) c; m2 ~7 E, y4 Jposition: relative; ; s$ E% b/ `& x
width: 0px; + t( F$ Z1 A8 L
height: 20px;
2 L% ?6 T# K9 ]$ W3 n' `z-index: 1; ) u( O7 I5 d; s  j- M! |
background-color: #006699; & X7 M* D/ c1 g9 W: R
filter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0); $ {: \8 {$ W& v( n/ s
border: 1px ridge #c0c0c0;
6 U  ~* j( Q5 D9 L# v6 v3 l: o}
' _) X8 }0 J' Q' L* ~) F& Z9 J: L8 g' \& y! r
更多网页制作信息请查看: 网页制作

回复|共 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技术交流平台 版权所有 All Rights Reserved. Powered by Discuz! X5.0 鄂ICP备15006301号-5|鄂公网安备 42018502006730号
关灯 在本版发帖 扫一扫添加QQ客服 返回顶部
快速回复 返回顶部 返回列表