返回列表 发帖

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

脚本说明:
- h. d" r4 j  m  f# Z5 U& B. ^, ]
$ c) R9 Q+ j! N- j5 n第一步:把如下代码加入<body>区域中
( k: c/ K) \5 R5 R0 I% u4 y <script language="JavaScript">: j% b* _) {' R# c+ I. V4 H

$ ?2 e9 c2 K- H4 ?. Z( P. lfunction nextSize(i,incMethod,textLength)9 c2 ?3 e) Z1 k, t( n
{( ^- [+ F4 i" X$ d
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );/ O( ?" h. ]  U: H. r" v; g# P
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
$ R4 z# \: u" g( ^0 p$ \7 p) X" q- e}
* j' W" x/ S2 v% B2 n8 b3 M8 g+ ?6 d% L- l
function sizeCycle(text,method,dis)
8 n7 F) d9 ]( C{8 q9 _. t" q& L3 }! V
        output = "";
. [- B$ b' P3 K        for (i = 0; i < text.length; i++)
3 \  c! `' H% }! ]6 H        {
9 e0 y+ l7 r9 f5 Q( S) h' [8 X3 m                size = parseInt(nextSize(i +dis,method,text.length));
" ~& C$ `6 x/ z% \4 i                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";& M( ^9 d0 X: ^) \+ @- J
        }
& V  I( K1 S" R0 d% p4 e' g        theDiv.innerHTML = output;, r$ J2 J. ^6 G/ j
}
& ]" l) z% h4 {6 k4 t2 y
: h, ?0 {$ S7 v! _2 O7 sfunction doWave(n)
7 r! ~0 W  r: ?  w{   
. g' {! \* f; n4 u        theText = "JavaScript";2 E# ?5 L& D8 c8 T
        sizeCycle(theText,1,n);
8 l+ v( }8 ~% S3 j9 }5 b        if (n > theText.length) {n=0}
& @/ A/ R2 N9 P) ^        setTimeout("doWave(" + (n+1) + ")", 50);0 C6 m2 M$ `  t. w. g  ]  H
}) z/ ?  |! Z7 O0 x+ v
</script>
) ?, |1 m3 m' w( ^) e3 g<div ID="theDiv" align="center">, @; c5 c2 C1 T2 _/ z

% Z$ s+ H3 P2 m</div>
/ J1 c- w8 k6 N; ]
% [, Y/ o$ I# y+ k
/ O& r( P, p2 L* ]9 ?  ~; b) U( d( D1 n! g- ^9 ]5 s% Y$ ~- l7 n
; o7 R7 o/ D! P, Y3 c8 G
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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