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

|
网页之奇特的文字变化特效
脚本说明: 9 Y* j& Z0 f% p- S" y
5 r& c5 z& {: ]8 a' X; P5 G
第一步:把如下代码加入<body>区域中
, S, ?( e! H8 _3 l; P <script language="JavaScript">
! h' B2 z. y! V& F- L1 `( c Q L0 A) k* G% h. v
function nextSize(i,incMethod,textLength)
$ H4 k' e7 w' w$ ^{7 ~. H) r7 D- E- n
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
' x% V v' f1 C6 Wif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));6 I) u/ M- r5 ~2 _$ q+ h4 }
}0 L- v4 o ^% S+ f1 w5 R3 w7 N
{ s" q- J$ }: K$ a, ^function sizeCycle(text,method,dis)% t, v' c4 H. i' @9 ?
{
2 v+ d: h" V- V4 b# l output = "";
9 C& D3 B8 {; d5 N1 j; r# V1 B0 R for (i = 0; i < text.length; i++)& U5 z1 n0 w% Y q9 n
{
" A) T0 ?# h" d* m+ j' X, D5 J( k size = parseInt(nextSize(i +dis,method,text.length));
$ B) U( I/ @! K; K$ C" Q output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";8 K- j; r1 s# ]$ f& M/ z. g
}' L% d/ m4 ?/ z2 h6 u5 m# P
theDiv.innerHTML = output;% E) |- }* n4 B
}% n1 Z" u5 P N' j3 p; e. `& q8 K
; {$ R5 \6 D. C9 A6 K) rfunction doWave(n) # ?/ B, b+ h3 c, `/ L! p! y
{ : X, y8 ]3 P; R
theText = "JavaScript";/ N+ G2 `7 m u; n4 p/ y
sizeCycle(theText,1,n);
* i8 a+ ^2 q1 [( _8 J: v if (n > theText.length) {n=0}+ m' ?; q/ d$ n/ F& C& p
setTimeout("doWave(" + (n+1) + ")", 50);1 D- M5 m8 Y6 r& ~; ?' s- O
}
9 |( K' J. {0 O9 X% P( L: j% P</script>
p7 r) s6 y, [ m4 u0 f/ @<div ID="theDiv" align="center">1 `' B1 P! \# }, Z/ x, \. X
0 _1 g& I: w& I; W0 {
</div>
5 n3 {, ]+ c# p3 ` y1 z- t1 Y7 ]9 W$ y& |2 R
* f1 L2 |( k: e0 s) w4 Z: P) p
" S! B5 M; f7 H' E - r, s& ^$ O& _: o, d7 Z+ m
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|