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

|
网页之奇特的文字变化特效
脚本说明:
- G' l7 M1 x: d- ~ & h, G; o$ Z( c! W7 o: H3 Z ?
第一步:把如下代码加入<body>区域中
( D" j) s* y3 w' _$ g- m/ `0 A <script language="JavaScript"># f( c. n& X6 }
9 w6 u ?* K' u) w3 U8 [
function nextSize(i,incMethod,textLength)8 Z) k) f M/ ]: s" W7 U1 j5 B' G
{5 f( e8 z2 {( t1 C
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );/ R7 P! G' B y2 h" I0 T
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));" X# T5 V& [5 x* `/ b* J1 n
}
6 j4 e" d. e+ I, _; Y }3 D4 c W: I4 @ \; B* x" c" D- C
function sizeCycle(text,method,dis): i+ |/ I' l- w3 O2 I
{$ Q' v. }6 ]9 g# t4 ?" y( n
output = "";
{2 h% a% S, a% x6 j% S+ o for (i = 0; i < text.length; i++)
0 `! U! r. z9 a% r/ W {
- j6 ?$ B# ?" l( w size = parseInt(nextSize(i +dis,method,text.length));) d1 Z& B2 {. k4 f9 s6 v
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
& [- A2 p$ ?& E0 e; a3 v }
( m/ g. e, o/ |& ^: y8 O theDiv.innerHTML = output;
/ S+ |3 n$ E8 n& \6 g" L& s G9 k2 |}* I3 o0 k, S9 W
; {8 I" v6 w- z% A3 J4 J7 p; I
function doWave(n)
2 U K5 _" D, w( ?# K{ * @/ v, D8 A. |1 G
theText = "JavaScript";* {/ g* F! V8 e* y2 \7 k2 i
sizeCycle(theText,1,n);
. q& h# m; \+ n if (n > theText.length) {n=0}
! O& E) y& M8 m8 k setTimeout("doWave(" + (n+1) + ")", 50);$ E$ V( l0 Y" O6 a& t* E3 r
}
( P! {" x; W- F$ C</script>! k2 i/ i Z7 i' ]
<div ID="theDiv" align="center">
& O6 U3 j9 y6 E$ I) z$ i7 |. L v+ \. o
: p: M5 z% x7 m</div>
; P, C! [ ~/ g7 W+ I$ Q
/ w" S. [' o2 Z( a2 T: a; e) y& o) i8 C; l) L0 L+ `6 g7 F6 p* Y
, B- z) G+ U! A$ _, {! j5 m
8 f& R' I+ B: Y. _- O
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|