  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之奇特的文字变化特效
脚本说明:
, P* T- l: E- B- \4 f! y 7 h( R, L3 Y" Z. k1 O; }/ D/ }6 e: G
第一步:把如下代码加入<body>区域中# J+ g- N: X5 N3 _( Z9 d9 S o
<script language="JavaScript">) _* m. l+ A) y" ]9 b9 i; N
- b* J4 x7 s" s3 Ifunction nextSize(i,incMethod,textLength)
5 s& @6 g, w: |7 _{& A( b7 G4 l/ h' O2 g9 _) U
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );2 ^0 w! t" A" ~5 s, `" V
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
- U6 V% d# i% n( u( e! Y; X}6 w3 ?$ c: ?' O7 a
4 H. `3 \5 @: E
function sizeCycle(text,method,dis)
. V0 E0 B W7 D{- H, T8 b& k3 | H
output = "";
$ Q9 n; F2 Z: ^, K1 j for (i = 0; i < text.length; i++)) ]6 D5 ^% Z: b' y1 F
{$ o" m' l. N# _# z$ u
size = parseInt(nextSize(i +dis,method,text.length));
( n$ c! Y3 X" j/ [- n output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
; ~' G n1 k9 w( r& t }/ A& o# y/ T3 l! j
theDiv.innerHTML = output;
6 N" d% N: O/ b* p: e8 K} ~4 i1 j- E7 H* e
5 u1 ], m/ J5 ]: k
function doWave(n)
4 `8 j: \# l! ?5 Y$ r, M, l, O{ ( }$ q! ?' S: y, J8 a: ~
theText = "JavaScript"; L. q+ G( m& {$ c1 n
sizeCycle(theText,1,n);- j# ]+ G3 U0 o4 a# C/ a
if (n > theText.length) {n=0} E3 Z# g6 v# o1 R. Z
setTimeout("doWave(" + (n+1) + ")", 50);
}# K9 h- M6 q5 E}$ j, e2 l9 Z7 e1 Z1 ~# s; l) k
</script>
. T3 i! ^7 d$ N$ t<div ID="theDiv" align="center">
' E% w: }" a5 B8 h# R0 R8 @/ J* U. z9 R
</div>
2 S+ u) ~1 T9 x- K, B* f, F
6 P4 g6 B" r- y Z1 D; V) B) G, h. W9 `$ g
$ u7 U9 R3 c. B: | V( `2 R$ o: ^' ?
( U% s; W5 a. W0 G& V第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|