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

|
网页之奇特的文字变化特效
脚本说明:
6 {: O7 t# M$ ^ # D" J: b' C, c; G
第一步:把如下代码加入<body>区域中# @9 F3 x. u4 B% w$ q, V
<script language="JavaScript">8 b7 ^, u0 {0 w% F Z2 |
2 V2 a9 ]6 n! I& a) yfunction nextSize(i,incMethod,textLength)
+ }* ^% Q# H$ i% q{
, [& Y* B ^3 Gif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );7 E8 f$ \" [: g( l* R, D& K5 d
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
1 m$ s+ k5 v" |9 j( ?0 \3 R}) n% J" e$ x& P8 q
, q3 W# f, I* t6 A( {# z% {2 Z
function sizeCycle(text,method,dis)0 z6 r5 S: ?$ j6 u3 ]! w
{
+ V- h% o/ L& q8 P ] output = "";- T K, P) B7 N6 @9 ~
for (i = 0; i < text.length; i++)2 g3 ?) m% K1 e# S
{& [7 v8 W0 O) Z5 ]
size = parseInt(nextSize(i +dis,method,text.length));9 }4 a6 ?9 {+ U+ V! J5 Y# ]$ _
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";- l5 T+ u. m/ h- X% ]' W
}3 C2 o7 Z4 I+ P& z% X0 T3 S
theDiv.innerHTML = output;! q3 @6 }: m, b7 o
}& o& c9 `/ X& r4 G% D/ u9 ~/ Y
7 v" S3 S8 B3 r i( [function doWave(n)
/ M6 E1 y1 B4 o, x{
. o1 g5 y2 B& { theText = "JavaScript";! u0 H( e9 L$ ^- ^* }( m
sizeCycle(theText,1,n);
' u5 D" r/ p" r# P2 {+ M- o if (n > theText.length) {n=0}4 [; @* G% g2 c( U2 ^4 F
setTimeout("doWave(" + (n+1) + ")", 50);& U# i- f- m' F
}+ d4 g Z* w+ G8 A& \+ `3 F
</script>2 \8 K& l, _- K* a1 f
<div ID="theDiv" align="center">
1 y5 n' Z0 U8 X; \8 v) T; Z" f) V- Z. f4 T2 V; a; H; I% `
</div>/ R, [% _& Q1 P
" U5 y6 A) W; g9 v* j1 ^2 M
9 A7 E: ]8 H7 i. M/ n9 S Y3 W: n/ E9 G' O5 j2 @9 y& ~: Z
+ {& n' o. p' d$ }3 n* P第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|