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

|
网页之奇特的文字变化特效
脚本说明:
9 y! [) b0 t9 G' A" U0 A8 P2 C0 ]4 Y3 F " e9 ?% p2 F7 h2 M
第一步:把如下代码加入<body>区域中
! t, s2 d1 i5 `$ x# s+ j$ t <script language="JavaScript">
. B$ T' [8 n' a
$ l3 k) Y$ N0 G5 x% d% rfunction nextSize(i,incMethod,textLength)* a5 ?9 a& w4 T0 U" |9 ^" E
{
5 f+ X( V+ p: b: [, h9 ^0 Xif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
# e, ]' N: I' c0 Y% y; m, Hif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
2 S3 }7 S# b* n8 t8 d/ _2 y' k# x8 {}
5 L3 L& w5 t1 k/ b0 c4 \% R
o- e" A( N1 \/ J; I% O) jfunction sizeCycle(text,method,dis)0 R( m4 G0 S h' d6 [/ F5 X
{
0 ]8 T) ?4 s6 H output = "";
8 S) r* B0 a: k$ w) K R for (i = 0; i < text.length; i++): |5 `0 d, g+ J3 W
{
) {3 L1 Y0 `' p; c M size = parseInt(nextSize(i +dis,method,text.length));* t; m8 S0 B1 }5 s M
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
( z% A* i2 \8 D3 @4 O }
# j7 g* p1 o' L% A theDiv.innerHTML = output;5 T( f/ @- [1 D7 P# ~; `
}& ^8 f+ l; w, y; U
, q3 W6 {8 z! S; t) R) R
function doWave(n)
2 T( O- f* U' A6 m5 J{ 9 ?3 o" r* `, c: ?; h
theText = "JavaScript";
; A2 Q4 d6 T. Z' G sizeCycle(theText,1,n);
) }4 ?. t, S4 F* f if (n > theText.length) {n=0}+ H b9 n0 U; j: _. q
setTimeout("doWave(" + (n+1) + ")", 50);
3 E0 P' q# Z/ F/ F5 X7 z2 P3 H}! A& @3 V+ C$ s4 I& `
</script>" t+ b, ~/ O# k1 g" G& ] \2 x: D
<div ID="theDiv" align="center">/ g" ?3 ^/ g2 R! B3 r# \) W( q
! C$ H- v5 z! k( s4 g</div>% U" C- b3 Y' W6 e% ~4 S1 E) a
8 A: X$ e% z: D/ I& s5 z9 V; C
( a4 Y" r5 W2 u
3 s; g2 U. G9 ?1 s
$ U/ n+ E# r) }4 N- z第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|