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

|
网页之奇特的文字变化特效
脚本说明: * _0 u0 n3 U0 H$ x( o6 x) H/ l
( C. E" j# A2 U5 S' D第一步:把如下代码加入<body>区域中
" J6 u7 `) L1 Y <script language="JavaScript">
2 N2 s7 E8 z' U% e3 A$ ?2 ~& ^; a; R/ U" ~$ x
function nextSize(i,incMethod,textLength)2 S5 N5 R5 C3 x% X8 d3 M% y9 i
{$ O$ h3 X9 s: s0 y8 J1 H4 C
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );" Y/ ^1 }. m; |1 |* Q l& ~( {4 q
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
; G, J& R, N5 @9 H; y}, w. `( B* y$ q" a. m
6 ?2 I8 a/ D1 p7 q5 H! m
function sizeCycle(text,method,dis)
: q8 A" \2 M# D3 U8 B{! ^8 ~* n# f P: }7 V
output = "";- L J9 L- N: t7 H
for (i = 0; i < text.length; i++)7 q6 p, v) H) }% G
{0 i. }. L/ T) U+ i, ~
size = parseInt(nextSize(i +dis,method,text.length));
! n, W0 W5 ?* O' x0 A output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
* ^' b$ ]% |0 A7 g$ N }
- c p1 m# M( K7 t0 c6 p theDiv.innerHTML = output; e8 L, j: h6 s+ N% d
}; ?$ e: m9 T( h7 X+ u
m- K2 w. ]( ]/ |
function doWave(n)
* z8 {6 _/ J5 d{ 9 k# ?+ C( X6 ~. A' d: d" F4 u
theText = "JavaScript";1 O0 F3 ?; G3 K
sizeCycle(theText,1,n);1 a8 Z5 N& @3 T& _4 O1 c
if (n > theText.length) {n=0}
( z' v) \$ Z7 `7 ~1 g4 l setTimeout("doWave(" + (n+1) + ")", 50);5 j0 A; U6 D2 j! t3 n
}
! V4 t2 o$ i3 j0 a6 L8 T3 Z! @0 E</script>
4 a+ P* ^ l: t; Y: ]3 K<div ID="theDiv" align="center">2 C5 D) R) m0 K! Y; Y0 t
Y$ ]( s& J" a; n5 V& v" h
</div>. Y. ^" o; u2 ~9 I ^- ?. d
+ H3 m3 r3 s0 `
+ }, V- x& }5 w1 b$ Q4 X0 g* N7 `1 N; ~- w& L" ?/ g5 y( D
" U, I, f+ k, c; @; U第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|