返回列表 发新帖

用htc实现进度条控件

499.7k 8
swmozowtfl 发表于 2015-7-9 22:53:17|湖北 | 查看全部 阅读模式
代码如下:
  F# n. U: e  |' f# u
<public:component>
! Z% f& K; T+ [2 K9 I+ c! C<public:method name =init internalname =fncreateprogressbar />
8 c0 ?, y- T3 o$ m8 \, G6 O<public:method name =showprogress internalname =showprogress />
" _1 y- K% G7 P6 |<public:property name=container/> ! [, p7 s* ]& U( A4 ~5 B$ R
<public:property name=speed/>
- E) @+ g" B, }: G5 m+ I/ ^5 C5 Y<script language=javascript> 7 ]. T( N6 _3 z5 V& T6 v
var starttime = null ; ! Z6 b+ L) M* k; _/ w- f0 ^
function fncreateprogressbar(){ 0 a4 V6 O7 {! M7 X; _0 p
now = new date();
5 k3 w/ s$ \1 o/ N! x6 h6 g$ Qstarttime = now.gettime();
; l/ i: [$ S2 q1 ~% r8 Vnow = null 3 Q; i, H# c8 |4 a3 t6 Z  t
ocontainer = element.container ( T9 q4 b# i6 C6 f3 ?- T
ocontainer.innerhtml = ; 0 F. @0 k. a, _6 Q7 K
odiv = window.document.createelement(div)
8 P0 [0 u# L. k4 j" v* G; Rodiv.classname = progress
" O, o3 P6 Q6 @" Bocontainer.appendchild(odiv)
3 g* [# G% F7 ]1 ~odiv.style.display = ;
4 G' Y; E4 [- @# G' \$ c  Aelement.bar = odiv;
$ O0 y; g) H& _2 E* P8 i" j} 9 V3 s, R2 ~7 U. K/ z. o6 O
function pause(numbermillis) { 4 V5 p: m0 C5 L6 W; N% d. C
var dialogscript =
" r- _1 p1 ~3 U  g'window.settimeout(' +
) H' S7 ^6 @& y8 t% `& ]& ?9 G, w" {/ M' function () { window.close(); }, ' + numbermillis + ');'; 3 U2 y$ y9 I. ~  p* _- u0 j
var result =
, f4 L' r# K. f7 B) b' j' fwindow.showmodaldialog( : S; `; h! M! _
'javascript:document.writeln(' +   H, }6 M" b) A+ @* x* d( J( q6 `
'<script>' + dialogscript + '<' + '/script>)');
" \" Y  `$ b+ i7 c9 \4 Q  \) u}
  F9 H# }: g5 ?function showprogress(statesdesc){ 8 c) D+ N( K; V7 u5 c- c3 q$ [# z
now = new date(); # M( a! b: F$ r+ j
currtime = now.gettime();
4 B" q4 H$ v, T- {* X3 H1 F. F1 w; ?; Snow = null
8 x1 e& [" D2 P' L% R6 h: `. Rif(statesdesc!=null) window.status = statesdesc+当前耗时:+(currtime - starttime)+毫秒!;
  d- g$ ]; c3 f$ e2 x+ `8 g. R. `0 Felement.bar.style.width = (currtime - starttime) / element.speed;
' \) g2 [9 V( s8 [, G% J: hpause(1)
% a, s$ m, c$ D# s, e- Z& K}
4 z, a& E0 p- }6 k</script> 1 G; l) ?' w( ^9 p5 _8 i
</public:component>% y. A0 Y% I' B& v  V
应用例子:
) ]# p9 [. o; p3 u( i代码如下:
9 E2 \8 ?$ k/ e1 ~: ~
<html>
* B2 g& ^1 V. i4 M<head>
, ?5 c7 S9 Y) M, r. K6 E2 S8 U4 W<meta http-equiv=content-type content=text/html; charset=gb2312>
# c4 T2 d6 Y5 x3 h, s<title>进度条测试</title> 9 |: p6 u3 m0 ^7 g$ e9 K6 a
<link rel=stylesheet type=text/css href=progressbar.css> - Y3 s/ h9 \0 V0 A2 e, M4 C
<script>
8 s  I( P9 Q! K/ H! ?  o" B$ b0 hfunction demo(){
" D8 S! B5 f% Eprgbar.container = document.all.layer1 9 T3 v) D) d+ h/ K( V# `
prgbar.init();
. [. k7 h% ^; Efor(var i=0;i<500;i++){
) L7 U( I" R; @% wif(i%5==0) prgbar.showprogress(操作进行中......)
' [: h5 l  \$ ^  h) L}
$ N- ~6 P" g# ?6 d7 P; kprgbar.showprogress(操作完成!)
8 E: W! h' q& c3 G7 ~  \  Z} 1 Y- N  Z# g0 w2 n
</script>
  m3 u* S5 L( f2 o$ w, `</head>
9 g" I: G% e# Z<body>
& e0 }) j/ v, c( X<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> ( B" z2 o" O( R, n6 o3 u0 ?" `
<p><input type=button value=测试 name=b3 onclick=demo()></p> ) {# F8 U7 Y) J  F2 n
<progressbar id=prgbar class=progressbar speed=10/>   |* w2 o6 X  l8 G; v
</body>
3 F4 j" x: N" }0 G3 R3 K+ k$ P) r</html>/ f! J/ s5 [6 P4 w
样式文件:progressbar.css
% a* N% O' C2 Z! a* U% k6 b代码如下:
0 K5 ~6 y% ?  a' Q1 X: a6 v" o4 A
.progressbar 3 x) `! o1 N7 h0 q2 P6 M+ i' Z
{ 8 m7 H; a% E1 x' T; m
behavior: url(progressbar.htc) / R( D3 }$ Q/ l& n
} % ~/ f! ~9 K: P, L( |3 V' v
.progress{ + h7 o% u+ Y9 U8 @
position: relative;
, _9 Z# o2 C2 ?width: 0px;
8 I, |9 [% e' n/ Cheight: 20px;
0 d: s) A+ u, E6 B! ]5 g6 F6 P2 cz-index: 1; 6 d- W9 f" i. b9 D( {! z
background-color: #006699;
' w, l% {1 c. {filter:progid:dximagetransform.microsoft.gradient(startcolorstr=#006699,endcolorstr=#e3efff,gradienttype=0);
3 i% ^9 ]4 p& [* F& W- M/ Qborder: 1px ridge #c0c0c0; ; P& w- D! @4 k, G5 S
}, p& _2 g# S" j+ ^* i

9 X# d7 w* h+ y* \/ Y# s更多网页制作信息请查看: 网页制作

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