返回列表 发帖

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

脚本说明:
7 p4 t4 j3 R2 i/ @7 K2 C. T8 c * u! s* @# q  Y) T0 V
第一步:把如下代码加入<body>区域中
' ]! k5 a8 N1 Q! ^4 T9 T <script language="JavaScript">& R% D( R; v- Z6 Q% u, G2 c
1 |5 d1 z5 [; Q
function nextSize(i,incMethod,textLength)
+ j0 Q- p; Z: l" |{
  j. J& t; u1 O9 q% {+ vif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
5 m+ E( y1 b( L& U$ W2 b3 B8 G  \if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));. B' }' n: y8 i: L9 L
}
) i8 p; p" ^( r
0 S, `% _  i- Y9 @/ Kfunction sizeCycle(text,method,dis)
$ s7 k6 r- u! h{) b" i2 ]$ p% ~
        output = "";/ B6 W. n* m0 ~$ i% X$ d# q1 j4 k
        for (i = 0; i < text.length; i++)8 R, u: V. q- c0 |( M6 }+ \5 \( G
        {# c. q. n, X, c  d, u
                size = parseInt(nextSize(i +dis,method,text.length));9 @" y+ o4 X7 r' F9 R! I
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
; x* G. o0 Q: d- u* o9 O- z! C        }
1 w8 X8 J! j( y        theDiv.innerHTML = output;8 W4 Z0 m- i" c5 p
}3 c9 }# K: q+ I2 K

8 J/ m. f' u; u* [8 u) N+ a" Zfunction doWave(n) . S2 w8 c% E- \, D& T
{   
) t9 x. j) K; e( u; Y5 q, Y        theText = "JavaScript";2 U0 G  u) V! ]. f4 h1 R. p
        sizeCycle(theText,1,n);
" M( |( u1 O/ l9 j7 o        if (n > theText.length) {n=0}& X; Y* l, |2 G8 J+ h! Q
        setTimeout("doWave(" + (n+1) + ")", 50);- T# I, A9 s% G9 a/ _
}! x$ S( a$ C( l, j
</script>! B1 i$ ^# A  f# e
<div ID="theDiv" align="center">
7 I8 I9 {3 [$ J! |, J$ M! \# J6 |& K, f; Y( e8 r
</div>9 Y* B$ E4 p5 l# V9 V
" h. \% t! |+ S) Z; f8 H

# _' l2 _  G9 a$ ]1 z: X1 B  A4 w$ s4 T& `& C2 c
4 c' z: G6 p0 q6 J* ?: ]( ~0 A; j! _
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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