返回列表 发帖

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

脚本说明:
" ?) ^6 v7 Z3 a! S . I% w) i: I: U8 x
第一步:把如下代码加入<body>区域中
! a% @2 A$ n  ]% z& R. Z- O <script language="JavaScript">6 r: a9 F- M, _; Z

$ P5 Q9 ]9 E; D3 ~  A" Y; Ifunction nextSize(i,incMethod,textLength)
7 i* T9 p" v$ f5 S* Q/ U{
7 V. ?9 ^  }; N3 V, K3 y) wif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
! C/ [7 B$ D+ w! h# N- l9 V" X  Cif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));5 f0 w. g& p* B4 [5 l1 O' c
}
. f: ]$ E8 C) _/ t5 l6 S( M+ n
+ i  n3 z( L0 v# X6 i7 Dfunction sizeCycle(text,method,dis)1 q5 T5 u* u* ~) U+ X
{, E" @0 \/ e' {! r% a. @2 d4 L
        output = "";
3 i8 i1 m; G. `; q. n9 ]1 H9 {        for (i = 0; i < text.length; i++)
; D- U* ?9 h. R5 Y( \- H        {) \# E8 [' ?; A) k9 o2 x
                size = parseInt(nextSize(i +dis,method,text.length));
, |# k+ v5 x$ s: q                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
. n) e. B8 {  J& L" m        }
- [4 `* O% b7 M) }        theDiv.innerHTML = output;
& A& i) E  `5 s  C3 m% V: _* E% W. i}4 b+ m8 N$ O! Y! o! T- e2 S
) M0 x, X" W" O) ?; D9 j
function doWave(n)
; ?& E/ C# ~" l{   
& C2 a1 j4 z. z* z. y1 U        theText = "JavaScript";6 ]! f9 a; J; \4 b
        sizeCycle(theText,1,n);
  R! h2 f1 V: f0 H" @1 K        if (n > theText.length) {n=0}2 y. {: `3 g1 P7 u5 m
        setTimeout("doWave(" + (n+1) + ")", 50);5 K7 u( }  T# A; d2 J$ ^
}; h9 }, O9 z* N# V7 ?' Z4 g/ i
</script>
9 y6 I( ?1 b$ c2 F: G<div ID="theDiv" align="center">$ z8 s$ R2 g' D7 x- `1 n% _% o
8 q8 E' o/ N' Z  Z# t$ ~8 a
</div>0 x8 Y6 d# S+ z& y3 Z* M8 z& L

: o, O" a1 v" p$ {2 d; C5 c
1 o  V) H1 `9 B
! S! {" z2 \, h; A7 u ' f7 i' [2 o2 ~4 ^5 q6 R; _( n
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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