返回列表 发帖

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

脚本说明: 3 v, Z7 F: [; Z% |6 c1 p3 P

9 r7 M/ w' R8 k  Q第一步:把如下代码加入<body>区域中7 T5 a- T0 _: p. _$ B) u
<script language="JavaScript">! P7 k; K# [) \5 }. U' u
6 J* e& T+ q3 |
function nextSize(i,incMethod,textLength)
+ G3 z, t6 ]& m{2 f$ x- x  ]+ ~$ c1 d, o8 t
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
4 Y' N) j9 P# ^  ~) c4 O- g3 wif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));% u' z% Y% o. x9 N4 Q& ^4 q( d4 b
}7 Y5 Z1 s1 H4 E# d/ \* d, w- w

/ Y% z/ j3 ^3 N0 f' R. qfunction sizeCycle(text,method,dis)# }5 A7 W* U3 @% d4 ]
{0 I- K) g) S, W7 Z8 }3 ]
        output = "";9 h! `* R& r3 m0 X* j7 v1 J
        for (i = 0; i < text.length; i++)
! \( s" Q' \% i& [        {
+ E2 r( Y& y: T* y" I* h' J                size = parseInt(nextSize(i +dis,method,text.length));
# {. w& o, d1 @1 L) D1 q( ?                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
8 L# k$ X  [- ~" X0 l$ i3 f8 T        }
' W' ?; R' D. {0 o        theDiv.innerHTML = output;
+ g* m) T: B( q9 U}- b; o. s) O6 {8 y  C4 c

0 Y5 \, p! H/ {, D2 p. bfunction doWave(n)
$ B+ ]) a: E. m: s, ^. E{   8 g8 o7 K6 K% L4 H  U$ Q+ G
        theText = "JavaScript";
2 c% K/ Z( l) x' ]        sizeCycle(theText,1,n);
2 O# B! Y2 O, _+ A/ y9 s  a# n/ {- M        if (n > theText.length) {n=0}
- a+ G* I4 b$ Q4 o$ G4 c        setTimeout("doWave(" + (n+1) + ")", 50);
6 c1 g* X& o- O}2 M4 U8 b4 g+ l% E5 ]
</script>
* D9 Z1 a, V# @* N2 _<div ID="theDiv" align="center">7 W- I( E& H2 Q0 {* c

$ `9 t; F; f8 [6 `9 K; }</div>* X# x% A1 N+ f4 [4 G
7 a1 ?6 u: Y4 ]; a- W* v7 w0 ~* W
) z& z" ^: X0 {

! t6 b" b  t; V, O. X$ [* E* C 2 H: \; ]; O- T0 l1 h% B/ Y/ Z0 ~
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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