Board logo

标题: 网页之奇特的文字变化特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:50     标题: 网页之奇特的文字变化特效

脚本说明:
" ]" e& Q  I; w; I! d/ L+ i 1 ^: }4 H4 h8 I9 u$ w
第一步:把如下代码加入<body>区域中
1 R8 {* Q2 `/ s+ p: O <script language="JavaScript">& {# B  Y) f, Z- p, P9 p' N
; {5 N5 m& t8 _& g( S5 }0 P
function nextSize(i,incMethod,textLength)
, H  t: g$ O5 g% i) l% f' r{% B* N# j/ C7 V: G, W( A
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
' B1 Z, b; K/ c% x. Sif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
6 J+ w% v8 d, h# ]# p/ v& W6 C}5 t! q7 U# R6 }( q

3 D1 {7 F$ X2 S+ m2 c( o2 gfunction sizeCycle(text,method,dis)
: _8 L' u3 ?  Q) c{( a1 x# X) D6 x! j4 w
        output = "";
# I* ^! B  Y' W# z1 l$ L        for (i = 0; i < text.length; i++)  B0 {2 ], I% C. G. x1 Q
        {$ z" o$ h( c$ [
                size = parseInt(nextSize(i +dis,method,text.length));' q+ p$ d3 m- L$ O$ I8 c6 ]
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
, z  F5 @) N( {( M# F( ^& H        }4 d( H, `" o) u7 F- E
        theDiv.innerHTML = output;
1 P8 g( k: X$ K}: ~( j! g/ f! f, C6 b8 E6 j

, p6 @8 y" z: R9 c4 o& D" j5 E% Gfunction doWave(n)
& e2 C3 |# e$ Z. L{   / {* Z; L; r7 B* K( G
        theText = "JavaScript";
2 z3 m, d- E+ Y4 I+ o+ y* j        sizeCycle(theText,1,n);2 `5 h+ l9 y+ w# g
        if (n > theText.length) {n=0}
0 |# K) l, \7 d' a8 t        setTimeout("doWave(" + (n+1) + ")", 50);% W( b8 O) e& v2 x) M! B
}
- x! w5 |% b3 ~) Y& ]</script>: c5 r6 g) c+ l0 ^5 i; x* p9 a, z
<div ID="theDiv" align="center">2 J. u" |; M5 A* H# M/ j% W
7 t' x5 t+ D) `( n' a
</div>
0 `$ b, o! ?% I0 r) e7 m7 y, E, y0 y4 x  e' K
9 f" _: E8 o1 {

) H3 Z/ L' M) Y2 H
6 @7 v% W+ K  G第二步:把如下代码加入<body>区域中<body onload=doWave(0);>




欢迎光临 捌玖网络工作室 (http://www.89w.org/) Powered by Discuz! 7.2