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

|
网页之奇特的文字变化特效
脚本说明: 3 G% o! J7 A6 T$ W
: n$ u& i( {) b! J
第一步:把如下代码加入<body>区域中
5 S, z4 P! ~, T <script language="JavaScript">
9 n5 m# Q4 \1 f* R3 P, r" J
- H+ _3 a, q# @" ~9 _- wfunction nextSize(i,incMethod,textLength)
: t8 {. W9 E( I4 B1 @, t& `- U{, Z+ z7 L, ]& e) y! f. _( D- K( W
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
# a% u0 e9 L" B/ Y" Zif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
1 F' l% S, ]8 z2 r8 o}
; z* Q5 ^5 I- H5 r W8 _8 V) K$ _0 L: N4 `. o+ O4 x
function sizeCycle(text,method,dis)
T. _$ L# t6 q- `{
% |6 L/ I9 q$ e output = "";% t& m2 \9 e$ O c2 V1 t' o
for (i = 0; i < text.length; i++)+ Q1 v( U5 s2 J8 f" Q. _
{
6 l- v2 H) V& B, h: r0 z size = parseInt(nextSize(i +dis,method,text.length));# m' f3 T u9 r) x9 F
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
2 f. Q3 o3 U- _+ N$ R }
" E! I; s1 R4 p, R7 s: L theDiv.innerHTML = output;' t" O+ B+ O1 W1 F! n. D3 a
}
* p/ l& J" b, l9 M# h$ z" `
, \! ~" l- ^+ _+ x, p# h5 n4 Rfunction doWave(n)
- C8 K" @3 o2 E3 I# r" b; X2 D{
. F3 h! k2 \9 w. k theText = "JavaScript";
) l) u8 k& l$ j sizeCycle(theText,1,n);! y3 L# K0 b* {9 l) b
if (n > theText.length) {n=0}, a Z2 `* ]# z6 |' V
setTimeout("doWave(" + (n+1) + ")", 50);
0 c4 x% S f# V/ H" {4 _, @" X}
# z) t. s2 f# [* M) u& T3 M7 ]6 ?</script>+ D0 n' I. Z3 Q' s0 q, C
<div ID="theDiv" align="center">( ?0 `; i% S0 U
1 \% n: c! D% \( l& h/ b
</div>* |5 z1 }) M5 \2 o9 @) l
( }5 n+ u9 H& _/ P& k
& q7 ^4 d2 j/ u+ t9 a" t. { p7 B
) y5 O" ^/ x. L K
3 F0 b7 ^; u. i" ^' I; Z第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|