  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之奇特的文字变化特效
脚本说明:
* B. }+ d. X* _3 v! f1 k. b+ P ; h/ X" F6 C; s4 w
第一步:把如下代码加入<body>区域中
' n" N9 y3 @9 M5 M. t8 o9 P9 u3 y <script language="JavaScript">
* V/ Q; R* {% O9 z
9 I% [6 w; L% ~( e7 L) Mfunction nextSize(i,incMethod,textLength)
$ u; ?" `, c8 ^$ N* C A{6 ~4 j$ Q$ L3 B
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) ); N$ ~" p! k7 Q/ n5 K7 Z! d
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));, }( y3 i) s2 @
}
) ^. M% ?3 C, q, T+ {* Z; O3 {* P$ T6 i. N# {% r; N
function sizeCycle(text,method,dis)3 p+ B- m! \0 s/ ?) d; y0 n
{
9 M( [: \; k2 ?" y+ ?9 U) L% o output = "";, _& H* G/ j6 A. S/ b9 R, ~
for (i = 0; i < text.length; i++)' g' P& q1 |! M2 [
{ Y8 P3 Y+ f4 ]* f. v0 n9 M9 E5 T
size = parseInt(nextSize(i +dis,method,text.length));
5 w4 O3 L m/ h% H output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";$ }" @% f$ y1 v" V. M5 |
}
7 B/ H' E7 V( J, R0 r1 y theDiv.innerHTML = output;
5 y7 r" M1 i7 v! K7 a6 p; g9 C/ k: ~}7 n V4 E* y- u" ]7 M
+ Y4 ?* P! _0 u0 \
function doWave(n)
6 |0 t3 c+ z- y3 [) D |' `{ 5 A' a- m/ v9 a
theText = "JavaScript";
0 J# E( K- E+ S$ [* b% z sizeCycle(theText,1,n);4 Y; w" ^ L0 H# o; B
if (n > theText.length) {n=0}
. M0 n$ H; s6 a: ], d% X) t: { setTimeout("doWave(" + (n+1) + ")", 50);
; Z( g5 f, } ?, w+ i}
; _3 t) N2 q/ p& Q9 C* p9 j4 W</script>
( F5 B" t4 d0 t: M" I- z4 @<div ID="theDiv" align="center">
0 k7 a- [5 O7 p- p2 u6 ?. k! _
" R# N1 x# ?8 L0 `</div>- C4 n) e1 T9 o; C/ C# f1 v: _
/ \, ]) g5 q' p7 \* r
- x7 i* R+ }5 T, ^
% t' J( k% D" @: B4 I0 w f/ q " Q }; G% }0 F) g! H: B) O
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|