返回列表 发帖

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

脚本说明:
! `4 _. r4 _" t5 u( ~" ~
  g5 \% t+ p6 j  K0 P第一步:把如下代码加入<body>区域中5 u7 D7 G" {5 |* w5 ~
<script language="JavaScript">- B! h. ~1 Q9 O3 `

# `( H! \! b3 R6 b3 y5 Xfunction nextSize(i,incMethod,textLength)
5 f& I, A) h. R6 V{- J* j( u1 b1 X: h" l
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );5 y9 C# |0 P/ f: c# b, o( m% P
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));. B2 Q  B. H) b( H$ @/ D7 a7 m
}
8 y3 P0 \+ Y0 e; A% X  u* W( v* E5 e6 [3 W
function sizeCycle(text,method,dis), d$ r% K  a7 `  S5 o& c
{
4 V( d! `% @, P! \  \6 k2 w        output = "";
+ {. M, r) {# S6 Z2 ]. R        for (i = 0; i < text.length; i++)" w. Y. z+ h5 K; |& N) l: u
        {9 f# c) C% g  U" Z
                size = parseInt(nextSize(i +dis,method,text.length));- w  z; W2 c8 L' b" r" r# V
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";9 Z2 Q& o4 r3 X; t3 ~3 U7 d
        }
& }! y9 S' G( w/ h5 ^        theDiv.innerHTML = output;. [# u* v/ T6 v  E' F! a8 c7 p
}( p% P  Q4 \+ t9 W7 ?

& D9 H; N& Y& o7 g, y% u6 Tfunction doWave(n)
0 s# A4 y6 t5 B) Z' L6 k. w* C/ w{   # S! I! g# f: ^2 i8 q8 Q
        theText = "JavaScript";  @5 I9 n5 B: S: T5 @, U/ I
        sizeCycle(theText,1,n);" \; x# Z% o9 ^5 l( ^2 y# S
        if (n > theText.length) {n=0}7 S- |# L) o$ _4 o/ Z: [; a( M
        setTimeout("doWave(" + (n+1) + ")", 50);
1 }8 U/ o2 w- ?& N# O/ D) Q}9 I- p; @! o2 C* k; E0 {
</script>
, O( ^- S& [; q+ [1 _8 M2 `<div ID="theDiv" align="center"># r$ s% Y4 q3 p# ]) ~$ f

7 I. {  J9 n" f% K4 O5 J</div>
* _+ ]4 h. E, s( g9 \1 n3 F
  J* R8 G" ]: t( ~. _( D8 G) U- S# _0 `7 j/ t7 k
5 V, R( `0 c  u9 N, m

2 h" ?, A: K; t第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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