返回列表 发帖

网页之奇特的文字变化特效

脚本说明: # s3 f) f9 {6 U# M( M' H' I: J
3 C4 |0 I& o9 l4 M
第一步:把如下代码加入<body>区域中6 F' g) Q0 K$ ?7 y! W, O" c0 b
<script language="JavaScript">' y  s( F6 u) U# ^  n: k3 f+ ~- p

% ?, Q1 @' q0 k, @. C8 o0 Xfunction nextSize(i,incMethod,textLength)
* x3 g. r% o. V! V7 A{
2 I& W" p* D" @4 rif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
  _2 R) a& u" c; {9 A2 L% \+ y  iif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
& `* I7 N; M9 J8 }" C- u8 q% f}
- g+ S+ o& n0 [. K
7 S7 \6 ?! ]# J2 ffunction sizeCycle(text,method,dis)
1 A4 l# x" q; l, a2 T# W/ R/ V{
# \% C9 S' U2 H" j# |6 P3 Y! ~5 `        output = "";
6 t* P) R2 p! d. C9 i- Q        for (i = 0; i < text.length; i++): X: p$ ^3 ]. _5 b2 P
        {# y+ F- w- ?1 h' J1 e# W
                size = parseInt(nextSize(i +dis,method,text.length));% m' o7 |. _- O9 V9 N' [! B/ r; h$ R
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";) ]& X! h8 N! T2 x' Z6 t
        }
$ g7 x8 A# a5 b6 E5 d7 x        theDiv.innerHTML = output;2 N# h7 k0 l8 t) k& C- N
}
0 |. ?1 Q- C: ]" I: r  I  H6 L1 z% F4 |% j) N) l( n
function doWave(n) ! h: R3 U: V( r& e# S0 ?
{   
  F2 n7 y6 I* I) _( B        theText = "JavaScript";4 {% x- N: Y3 t- m* F: A! T7 B6 f
        sizeCycle(theText,1,n);) I+ M  T1 U1 k& o
        if (n > theText.length) {n=0}
6 `3 n! I" [/ q        setTimeout("doWave(" + (n+1) + ")", 50);8 W: G/ o% X2 z  O+ z8 j& b
}5 W$ j  w) T" P$ I+ H& _7 t
</script>4 D  R/ e. q* k0 b  A3 v# e2 f3 q9 [4 g
<div ID="theDiv" align="center">* G0 {! o  q. }. O6 ~/ u' G$ i6 P
6 B7 l2 X& t: V5 w# t, L
</div>1 B' x# t& O% X) I& L7 j

+ \4 _( w. M  d! K* g& G( w# s- Q

+ H5 q5 \2 V3 F0 @) R
5 a  P0 I2 K  X: u  q2 R& C/ A第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

返回列表
【捌玖网络】已经运行: