返回列表 发帖

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

脚本说明:
9 ]  j8 m7 H# w' f8 B3 @
3 u% }6 ~# @4 p8 {第一步:把如下代码加入<body>区域中) S+ i0 c. G5 B, z" d8 ?% I3 i
<script language="JavaScript">
" Y: D* L( F2 d  l/ w, [, U7 O  G- @4 D0 c
function nextSize(i,incMethod,textLength)6 y! ^8 j. r+ }
{; R5 F/ |3 N, {% O1 P" v) A
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
7 m' U7 K5 Y1 ~& e  dif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
# r4 B* t" U  w! O6 c}2 a- R2 s. \6 b9 e+ K: _7 }
4 a" X8 _  K) [0 l8 S$ V3 i2 E
function sizeCycle(text,method,dis)# @/ P' e+ g" n
{: K0 r' W5 T/ @* G; \  F2 u
        output = "";5 p7 }: b& }2 O' m
        for (i = 0; i < text.length; i++). W8 b3 s  U; S' f- U( G" e
        {# N5 a) O/ @7 X  K7 t; E6 r* d5 q
                size = parseInt(nextSize(i +dis,method,text.length));! _& n9 ~. h& w0 t  W
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
/ B4 R2 ?3 G) u  o        }! O7 h# @% `& O5 s
        theDiv.innerHTML = output;
6 \/ D! ?8 g; ^* j. E# J6 ~}
: I; O& R) T/ q0 G/ ~  ]% p
9 V8 Y% m' V  J0 v3 x1 a: Cfunction doWave(n)
9 [( B: d: m2 c4 O{   7 {" Q. p2 b6 L. b( ~1 m, V
        theText = "JavaScript";" J! m, N( t8 h: }
        sizeCycle(theText,1,n);
0 I7 _* Z( i7 F2 O3 }6 c! j# r        if (n > theText.length) {n=0}& u$ S& N/ N6 i4 ?3 o5 G  H+ P4 L
        setTimeout("doWave(" + (n+1) + ")", 50);. L/ C! [1 m* j; m: l' H% Y" W
}; u8 Z  y4 o0 _
</script>
8 h$ N9 Q0 j( e* b" \. l  I<div ID="theDiv" align="center">
0 g+ s2 h7 ^3 j) N. {4 T& @- d: F& t8 q; z% u# l# W. s
</div>( q! h) o, z" l! r
+ x. K" ^9 j- X$ J3 u$ s

' W! g: J  ]. _1 P/ v/ ]- Z9 w
$ B& ^% V5 h+ U + M# m. ~$ ^6 q/ s$ }& _
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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