获得本站免费赞助空间请点这里
返回列表 发帖

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

脚本说明:
3 _* E% Y7 H0 v- I& W$ R
! z! _! v; ]1 P. ^2 v7 d& G第一步:把如下代码加入<body>区域中
0 U* F* ~" f3 h% r8 c! b <script language="JavaScript">
/ v. p" Y  w$ z3 e2 R0 |
' {: \" }% d  o6 D2 ~function nextSize(i,incMethod,textLength)/ E9 |' u& H' H# ?
{3 Y; l4 M& R0 H# C/ ]# ~9 B
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );1 @: }' I" ?) q6 u. f% m
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
0 Z' P7 Q, h1 x" S}
" j4 v4 V, i. ]
" n4 p, X& @% K6 Z8 Yfunction sizeCycle(text,method,dis)
8 @( A' L7 S: ]{/ Q/ w1 c# Y4 v1 v
        output = "";
" A% Y: c( B* }9 M4 A3 \        for (i = 0; i < text.length; i++)" h0 X  o! Q$ K6 U3 ], n( e; E9 Z
        {3 [1 t$ ^: l7 g) v1 s# G8 ]! U
                size = parseInt(nextSize(i +dis,method,text.length));2 f6 D/ t: \. z: C
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";% t+ q* U2 m- K
        }1 B3 y9 L5 Z! U$ l- }# b2 y
        theDiv.innerHTML = output;: }  f2 \; ]$ K! `( n6 U2 I
}
; p0 j) o1 \+ x0 s1 `; {; h% b3 }' [  |5 z( }! o" }
function doWave(n) ( j9 @! ^5 R5 j- a2 H8 K/ R# ~
{   0 o9 ?+ [2 C& h# ]5 _& n
        theText = "JavaScript";
: y) H& ^/ s, d9 l6 a7 q        sizeCycle(theText,1,n);+ p1 f! J9 v% |  H# z
        if (n > theText.length) {n=0}$ T9 M  e, N3 @# c
        setTimeout("doWave(" + (n+1) + ")", 50);7 W7 ]: l# C* c
}% V7 D$ Q5 l) Y7 H8 o
</script>; F4 B0 Q+ C- ~! b% Z3 m
<div ID="theDiv" align="center">& z+ n$ T( c. R5 e

" G- h/ O# a4 y) l- F' \0 }4 k, f</div>
1 R1 U; u/ Y( |" v' f) a
. R5 @1 d' G6 i: [, t" X* D5 X& y5 V
; P: w1 B. B  Z' P2 U3 t4 A- w
- }- f/ n" w$ s$ A$ x$ s, a
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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