返回列表 发帖

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

脚本说明: % [" |# A5 n. ]; \  u7 B' e6 e
3 ]! Q9 F8 D8 b) `& _& |4 T0 {
第一步:把如下代码加入<body>区域中5 A7 b" Q, h  U% F4 A$ G
<script language="JavaScript">
& d/ m# ?  P! [$ _2 _. L  C% [. T0 @
function nextSize(i,incMethod,textLength)3 I5 q0 i5 Z) ~3 p: l$ m; \
{
7 ?: }  u. P, Bif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );$ V9 z. G- X4 c1 f( B1 W4 M& F
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));; ^4 J6 A4 x: ~0 l
}2 c# D! \/ T/ P% u& F

' n# W6 _3 d2 o' Ufunction sizeCycle(text,method,dis)7 s! t; j* R% Y
{7 t2 {- X+ y# P' |( r
        output = "";
2 r) x0 a( N! L# _5 Q) g        for (i = 0; i < text.length; i++)" @' S- k' d+ t# f, y4 {
        {+ a" s+ S6 Z) j8 r' o* o6 r; z
                size = parseInt(nextSize(i +dis,method,text.length));6 G4 d0 s3 a! U+ B1 n
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
6 f0 d, N2 h, q1 l% z        }
+ @3 T3 R, z# K9 Q% a5 ~        theDiv.innerHTML = output;7 `. O% H6 S! V2 w, ], R
}
. |( m) g5 f( h" @' v/ c3 E0 Y  N, Q5 h; v1 k5 }* s
function doWave(n) # G# J- G+ L; U; n
{   6 }( u% A$ B3 j  _; F5 m4 O
        theText = "JavaScript";
5 E4 R  n9 l; T2 J        sizeCycle(theText,1,n);
# t) c: M3 P5 T' d% A        if (n > theText.length) {n=0}
; ~9 Z( G, f( J( {6 o! H* {! w2 w        setTimeout("doWave(" + (n+1) + ")", 50);* p3 _5 ?6 B4 b' \" s1 w* x
}
' Q- N3 d. L, q</script>
( s/ G( v6 t3 Q  k" w<div ID="theDiv" align="center">
" ^( t* k& x/ [, S0 J) G2 v3 \3 g/ Q4 G
</div>
4 T/ G3 |1 L) t: ~$ X
3 m$ ^3 x3 f2 _% \  q( I. P. L3 y* Z/ }. y

1 G( q. W& I- U  Z* t / l( i) x# j) i3 V! E. F8 i7 R4 d2 v
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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