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

|
网页之奇特的文字变化特效
脚本说明: ( ]1 Q% \9 @5 h# y: B& [" ]- G
# e, Q' s; L; ]4 b9 H# U8 w: F1 v第一步:把如下代码加入<body>区域中
) T3 V( ?' a- Q/ o9 @2 j: g <script language="JavaScript">
# G4 Y0 r/ K7 y l0 A* g7 f( N6 ?- B- E- l. X2 l
function nextSize(i,incMethod,textLength)
& F& ]/ f! B- `- X. f* ~! B$ I6 r{
8 X2 i8 \& Z( U! i! ^if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
& K8 L6 ^5 x; i+ Xif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
& p1 @5 e* l0 h! T" n9 w, r}# q) H# d6 s, p8 h1 H+ J% F
y! @: [9 E2 y0 p% jfunction sizeCycle(text,method,dis)
2 a+ a# K% ^, ?$ W{
- u. W, I- }3 M |6 A output = "";; F. n4 P" r4 D6 c$ [% F% J
for (i = 0; i < text.length; i++)2 h7 v! d& e0 L; u! M7 n( S+ ^) Y
{! j. y2 S7 `+ [% s* c4 F; Y
size = parseInt(nextSize(i +dis,method,text.length));
" n9 S+ L: w# C+ v% S output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
0 G7 K" r( H- g$ J H; U }
! D4 R3 \+ Y2 T; h theDiv.innerHTML = output;2 ^3 ?5 j5 M8 Z' t& w4 a! x
}+ k6 b( }+ j8 k; c
9 s" z4 b- C$ A
function doWave(n) ) ^6 V& z0 m' [7 |" }
{ 1 d- i& u ?- z5 Q% Y
theText = "JavaScript";/ E! z6 v! E8 S$ P
sizeCycle(theText,1,n);; a+ P7 D0 d# ^' I3 H& M* J" k
if (n > theText.length) {n=0}
' g, q$ C+ A# Z" h( d setTimeout("doWave(" + (n+1) + ")", 50);( Q. L% [* a" H* T3 v8 R+ z
}
- @5 E9 g# g+ b! I$ |</script>6 r4 l! a8 Y4 g% l0 q+ Y. t
<div ID="theDiv" align="center">
4 p% a* o0 V; \- s, m A3 x0 d0 y. p* [& N& L$ [2 N
</div>
! m. T; k* E/ Z. D) O% h3 Y+ L6 k; {& I
- u0 l: u" ]; d+ }
0 v! `' @7 E1 k- \1 u
( A! I( Q- I! K; n9 j5 e& W- j
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|