返回列表 发帖

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

脚本说明:
2 C8 ^: l  Z) R$ q) L8 u% c$ B 2 c" |; `3 k1 ?+ c# p( U( m, g" j
第一步:把如下代码加入<body>区域中
& N" ?* g6 B6 ?5 U <script language="JavaScript">8 k0 H; U+ }1 E4 Q. Q# x# ~0 @

9 t% B( V$ r, O0 Vfunction nextSize(i,incMethod,textLength)' o& Y  O' p% ~3 ?, x8 ]$ f, V
{
9 R$ j& _3 z9 oif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
& c! W: @* C+ B$ Gif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));0 k( E2 m  n  z8 u3 c, I! `& @
}
8 S" n: c7 ^8 l( N* n! H
( @) w  U  R* p! tfunction sizeCycle(text,method,dis)
$ J; W5 i1 d4 ]! K* ?, ]{
' r' G7 c1 K7 o' g3 m        output = "";
( z- i+ s8 @) a3 ~, Q- S        for (i = 0; i < text.length; i++)# m3 g+ S/ N! i2 H2 g  H" n
        {$ J6 D% }" B- k1 {. _
                size = parseInt(nextSize(i +dis,method,text.length));- E  d# x; \. ?. t
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
$ j: }  P2 B1 [, t% L1 P        }
) T: L' ^* d# u! _        theDiv.innerHTML = output;
  s* m, ]. J4 [& F}
! G9 N% C3 n0 E2 ^; z+ [  Q8 g1 k: v* F0 z% c
function doWave(n) 9 ~- @3 W5 l  o0 n- g
{   - N# @& M! r6 U- X
        theText = "JavaScript";' H8 J8 h) S- a4 [+ c% l; P7 |) u
        sizeCycle(theText,1,n);
4 H) ~; F& j; ^+ @' f        if (n > theText.length) {n=0}; r/ w- q: z6 T4 K0 f) |
        setTimeout("doWave(" + (n+1) + ")", 50);8 g& ?  Q6 A0 H7 ]  E, c
}- P8 F3 N1 {$ S2 p
</script>, ^4 i- H! x6 `0 N2 W# X/ |) O
<div ID="theDiv" align="center">; n4 \+ W* O3 _6 l- t' i
0 E3 D; k. b( F2 s7 K
</div>$ C8 q1 P2 Z) s! a
1 J9 u7 b$ x7 V3 x- r( u- g
2 L9 I4 Y% d) `0 ]8 @+ u
+ |; m4 ?  m9 ~3 Y5 \7 C
9 ^! y9 Z5 X% X8 K$ e8 m. U
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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