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

|
网页之奇特的文字变化特效
脚本说明: 9 W7 a5 q- @4 M" G4 r+ ?8 E j
$ [% B& f3 b3 G& P) X- ?* t
第一步:把如下代码加入<body>区域中. T1 @! x# X) x9 m
<script language="JavaScript">/ @+ X7 P( ]# |# K) O1 }) R
$ Y, H3 N# z0 x/ F; Q) j# W& ]function nextSize(i,incMethod,textLength)# \& o- D, K* n( S; t& h( X
{6 U6 T# l t7 n h* L8 ~; \) f. c
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );. L/ Y6 u2 l3 D7 W" u
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
8 Y) K% M* Y9 v1 Q' M5 @ e}; C7 ^! t Z3 j( d
) g1 v4 o% \* y+ ~( l" l
function sizeCycle(text,method,dis)
B3 U( W9 s. T& V{: n& y" T; j8 \# C6 ]7 u
output = "";6 h0 n. \2 g# u3 z( U
for (i = 0; i < text.length; i++)
; {9 N; I1 z! l {, ]- q7 [6 o. F5 ?" b" Z
size = parseInt(nextSize(i +dis,method,text.length));; S! ~9 k4 ~' z* r0 n. ]4 n
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
5 @8 N, r( [6 p4 c! H; X }
2 w! b9 `7 g$ ?) s% ]/ S8 W1 ] theDiv.innerHTML = output;
1 c) p5 p' T" L, A0 [0 U}
/ L9 |! h# r) T5 G1 o1 V& i8 b; [) v! ]0 @ ~& z+ o0 o
function doWave(n) % A) c7 V, q9 I8 q* h( u3 t5 Q
{
4 J# Z' l. z; v4 |; j theText = "JavaScript";
9 G1 X+ d9 b9 x9 I+ c- z sizeCycle(theText,1,n);
: u6 I5 c L* V, m6 G, f if (n > theText.length) {n=0}: k) q) W p6 @! N! x; }2 f! W
setTimeout("doWave(" + (n+1) + ")", 50);
, M+ x% ?" k8 V$ l$ p- B}
4 a! x$ A1 G U, Q' B</script>
* F8 c R( { I V# E' C" r<div ID="theDiv" align="center">2 \4 V7 }: o- A: K/ \% @0 ^
2 S. y1 C4 B6 P9 \4 W1 _4 ?</div>
0 ?! Z; s3 a, P* M6 |
: r0 Z( _2 j7 B5 R& Z
3 m% s+ U' K9 y9 p
& ~7 O/ y- c! Z# o g+ J/ v8 J4 ^
$ b; K' z* i6 ?! p8 V5 o第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|