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

|
网页之奇特的文字变化特效
脚本说明: ; y9 _6 d6 P0 W' n
8 {+ n/ O2 X3 e8 Q0 D第一步:把如下代码加入<body>区域中, u/ v6 K, k1 N) I
<script language="JavaScript">) n k( w" b: q& O: w- L( J9 C8 Q2 Q
, ?# `/ l& O* d
function nextSize(i,incMethod,textLength)
0 v- [4 M5 Z0 r+ s{
+ T" a ~& j, tif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
5 s+ N. ~4 Y) x9 i: r- L; f# _if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
+ R; b7 d* z! @) |# F$ k}
9 @/ [& o& ]0 ^$ m' y' L. E
! a- l6 Z# L C4 D5 S" tfunction sizeCycle(text,method,dis) }, }5 K% p( T& a
{% H+ F9 U( p8 ?/ r8 R
output = "";6 b/ D# g% A5 Z/ T6 K# j, ]1 f" g% g
for (i = 0; i < text.length; i++)
0 O7 H( m3 O6 R8 Y {
& Z7 z( Y0 g3 S size = parseInt(nextSize(i +dis,method,text.length));9 l0 v3 [) |% g9 j! _
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";1 ^* S& ]/ D1 _, x" x# U) |
}% f$ P% C$ w; l' r
theDiv.innerHTML = output;
+ h9 S: I, s+ M: Q* W}
8 Q2 M( g7 b% a2 a% ^/ d( r& i& d# w% L% y, G3 V# `( P: t$ q
function doWave(n) . T9 T0 Q0 [' j7 \
{
. U5 J% D( h4 ?/ p1 @4 l, w theText = "JavaScript";
( } |' z5 w) h" Q+ h! G sizeCycle(theText,1,n);; _/ w, d2 O D8 \! m, C
if (n > theText.length) {n=0}
) i) ~9 x- v$ s% [/ J setTimeout("doWave(" + (n+1) + ")", 50);% U( O- M; g. ^% u
}2 d% j6 J L: k) K& R
</script>8 h" v' s- ^0 g# s
<div ID="theDiv" align="center">7 v0 |: {4 f7 P
! x) V! r2 G1 M I2 t6 G! C</div>
+ W4 K3 W; V# z' X$ \- v0 I/ P' k& y5 f/ O7 q) B
' G8 J9 ?8 y8 |/ i
$ w1 ~( z& M( d" s1 S7 e& K& j, g
& N- v0 A5 x8 u' w9 i! `
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|