返回列表 发帖

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

脚本说明:
, ]# A, S2 _4 I3 y+ a* ]; ]# L
# a4 n+ c* W6 W/ \3 P& s' P第一步:把如下代码加入<body>区域中* v3 V2 a4 R. Y  W
<script language="JavaScript">
: a, m8 u7 t. v
3 z. Q, X- n! f- K! dfunction nextSize(i,incMethod,textLength)7 Y' o: s( Z7 P
{6 Y5 D6 l3 ?' _( I5 {; G
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
2 f. M2 x: M! W  x2 m+ @) m1 Qif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));3 S& U; X% ?; x2 r$ R2 e1 v8 Y- F
}" X( f* _1 t- i7 b; T( L1 y* Q

" F: g( v1 h) K6 f- L0 O% g' Qfunction sizeCycle(text,method,dis)
5 G- [% \' G2 n, A$ e; U{7 y1 E5 s* \6 W4 y" b' z
        output = "";& [* G7 K( t# \: c) [
        for (i = 0; i < text.length; i++)
4 Z; w" J" M1 d# P        {
( r! b4 b" a5 e, {0 \+ y                size = parseInt(nextSize(i +dis,method,text.length));1 c, ?& ]5 X# \( b
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
: Z- E" X8 ~( v, `        }: L* Q5 i" C) L
        theDiv.innerHTML = output;5 T3 b$ f$ W! o
}, c& X9 B" [) P& k! K; r! g4 U
7 V+ l1 p0 }/ K
function doWave(n)
' H% O# x* |& F) W! m{   3 a2 x( r$ p/ _, X- P
        theText = "JavaScript";
8 c8 I8 E! o0 K& I. U: ?9 C* m% x& C        sizeCycle(theText,1,n);
+ Z3 R. \- u2 t        if (n > theText.length) {n=0}
2 q6 T( r+ a! d/ ?/ g' J5 Y2 K0 Y        setTimeout("doWave(" + (n+1) + ")", 50);
/ n8 E( K, M( F$ j- c. _}: p! e2 c6 j" M. g# J1 a8 e7 H% N
</script>/ _, M) f2 ]: ?. S/ F+ P) g
<div ID="theDiv" align="center">
: a: c$ u3 G$ y/ _8 E& f9 I' O0 ~2 q# A* K0 j
</div>
+ b7 A+ ~- g0 R6 ^+ j7 [4 G. f1 e) a% D/ t- |7 v4 H
3 c, W. k2 A5 k$ Y( @# q

& E) D- k9 H/ a 4 p! ]2 m8 ~0 x6 v
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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