返回列表 发新帖

用htc实现进度条控件

499.5k 8
swmozowtfl 发表于 2015-7-9 22:53:17|湖北 | 查看全部 阅读模式
代码如下:
9 \/ C& u" m2 g* i. x5 m) Y
<public:component>
3 d3 l2 d" `1 b  {<public:method name =init internalname =fncreateprogressbar />
( U. d7 k0 c/ h7 Z) i4 M<public:method name =showprogress internalname =showprogress />
1 D, s3 ?4 @" M- H6 _. K: u6 R" Q<public:property name=container/>
+ G5 h& ]) \7 m, k5 k<public:property name=speed/> 9 F; _" [# m, N9 s% a8 h
<script language=javascript> ( P- ?/ ]+ B0 A
var starttime = null ;
# j5 {5 T* n. k( `function fncreateprogressbar(){   R9 t! [% H0 B! ?  I% {% Z
now = new date();
2 W2 G* a1 k, s8 D6 r% `starttime = now.gettime(); ( O. L; M% @: @5 O/ x" y
now = null $ {6 c. D- Y1 r; y1 h" }
ocontainer = element.container & S+ F' C! z) }/ x! Z$ o4 B# A- [
ocontainer.innerhtml = ;
( W- p; \) v5 o; Modiv = window.document.createelement(div) 7 [  \* i! c+ L# [$ @3 `8 n! G/ Y
odiv.classname = progress $ A& d4 x% C( w' T
ocontainer.appendchild(odiv) 0 z$ }2 S: S, X5 F
odiv.style.display = ;
( {( x4 ]1 m( k; oelement.bar = odiv;
! |/ e, [: ?. x0 [/ r! q}
8 q" r! ^" ^0 k# w1 W' E4 nfunction pause(numbermillis) {
- e0 M6 {! V1 e) N% @5 Hvar dialogscript = " B$ F; Q& _; N0 }2 P  _# x) i
'window.settimeout(' + # I4 Z+ c, b' ^7 F- n- O
' function () { window.close(); }, ' + numbermillis + ');';
- ~9 q% {( x3 d- C/ B1 ivar result =
3 d( H% Y! E; d+ D4 q( Z$ Awindow.showmodaldialog( 8 C! A( U. n4 |
'javascript:document.writeln(' +
6 z+ X' _9 P1 a% u7 o'<script>' + dialogscript + '<' + '/script>)');
8 u1 k) m5 L) W2 A9 C& `& r2 o} ( q2 G( t2 n5 s# J: ^+ o
function showprogress(statesdesc){
( H# Q7 [0 F, D# \, _# q. t4 Wnow = new date();
4 `1 z! u8 w; V0 R, X/ D* _8 h( {8 Rcurrtime = now.gettime();
1 r  U+ e7 ^! M: G/ R: A+ i0 Xnow = null / R' o- H$ S2 R2 P% |; u
if(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
8 _# ^( m; K$ Z9 ]element.bar.style.width = (currtime - starttime) / element.speed;
; A2 Y; b7 i" m. bpause(1)
. D- B) R) Q+ [2 X% u}
$ A9 H% n7 B% v! B2 k9 J# z0 @. S5 F</script> # z! O' i: {+ N! X+ p# p+ ]
</public:component>/ I& t+ O+ V( p6 N
应用例子:9 N! A/ p& A4 L* z
代码如下:
6 f$ z: ~' g* B4 R. u4 }2 G
<html>
5 O! x8 b% w! M# i<head> + Z) t  \  m+ f1 c
<meta http-equiv=content-type content=text/html; charset=gb2312>
+ C/ j0 o) Y& x' L! J$ \: j<title>进度条测试</title> ; X9 ^  e3 z' t: O( I
<link rel=stylesheet type=text/css href=progressbar.css> - l# U9 {+ Y* N4 ]& j
<script> . M) [' A, G% U
function demo(){
9 w& G: s$ l/ }+ Dprgbar.container = document.all.layer1
7 r" P3 R& A! H' X# _: Zprgbar.init(); 1 V. ]0 `6 p! T1 y* q: T
for(var i=0;i<500;i++){ & y4 y' |0 X7 F
if(i%5==0) prgbar.showprogress(操作进行中......) ! h9 R0 o  j  a" r
} , d- a4 l5 _7 W5 K
prgbar.showprogress(操作完成!)
1 ]  d# y& J" ~7 A}
  R* ~, z/ `1 o: ?, @</script>
  W" T: W- Y7 c7 X+ Y6 l( s$ Z</head> / G! u' _0 q+ M) Z4 n
<body> . g& j! u% Z# U, Y: |; g
<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> 2 y9 ~  r* j' ^1 Z* N
<p><input type=button value=测试 name=b3 onclick=demo()></p>   c, w% o6 ?1 y5 P& w) f; n
<progressbar id=prgbar class=progressbar speed=10/> * U9 ~% Y1 S/ I  R6 B
</body> + X" `( ?9 F: Z& y% Y! I
</html>
8 |  U1 \7 i5 {3 {% Z2 I  k* _  i样式文件:progressbar.css5 r3 p) R- D6 H1 I
代码如下:
) B: e4 w' r0 E8 {+ Q' t
.progressbar
& F% |8 k5 j6 |: X4 f$ Q* L{
2 T5 q: @1 s7 b7 R. I( s$ |behavior: url(progressbar.htc)
; m1 ^  \) j1 Q. w0 D# x' n. b}
# r7 M1 a7 L! S( P  l3 a.progress{
; n2 j+ M/ r3 _$ Hposition: relative;
9 |. V& i5 D. D: m; uwidth: 0px; / X; C0 H* t4 Q9 c2 l( z# C* r, w8 `
height: 20px;   u0 f; v! t' k  L6 l2 W. t% o
z-index: 1; 7 J6 d6 o) X6 q: A
background-color: #006699; 3 `8 I; ~& x  x+ e- W
filter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0);
9 V5 v) w0 J# \7 H, nborder: 1px ridge #c0c0c0;
( \$ P* }7 v' z) L- q. h  C}, ^! @: n, V: T/ ~  U

/ n* R' U) H: p. Q4 X更多网页制作信息请查看: 网页制作

回复|共 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客服 返回顶部
快速回复 返回顶部 返回列表