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

|
网页之奇特的文字变化特效
脚本说明:
# ]/ P0 N a) u/ M/ `' |, X! O& m( i
# I2 j* T- L) E: G8 E7 V, |第一步:把如下代码加入<body>区域中
- N& y, r7 w6 f7 H3 `; H <script language="JavaScript">
: I% B& ?$ w$ \; E4 h/ u
3 ~) d1 ?0 L5 x4 Q* q4 |- Wfunction nextSize(i,incMethod,textLength)% b" A7 ~2 k! U: Y0 P' a
{. G5 a- G2 z! ]8 y' y; m, h
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
$ u d: |9 Z l6 C7 n+ |if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));( w2 d) ?& A, ~/ n/ X
}
9 p/ s/ G' y, r9 I2 I
( k( M; W0 B" F& F. |function sizeCycle(text,method,dis)/ P- w7 T' D5 Y& i7 {/ \
{
1 s) A, B8 C* g' K5 Q8 E output = "";4 J/ Q* G# A# a0 c
for (i = 0; i < text.length; i++)
7 L( G! J/ _. _6 T* z# v# M; f {
. F9 t, z' i! `' n( K A! r3 M size = parseInt(nextSize(i +dis,method,text.length));- X8 E+ Q# v" _! H9 ~( J9 y- u
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";& [5 m. g1 J% x. S7 a1 t9 i
}, Z# w" p: C' _3 _# |/ H1 c
theDiv.innerHTML = output;
+ b0 K. z5 q2 u* U8 o, U}0 h7 L- f1 e/ {1 }5 N
; `" }! G1 f9 E1 |function doWave(n) ' m- z& h8 e: M7 o: }2 P! a/ y( l* e: }
{
# T$ n6 \9 e/ d. W1 t$ x theText = "JavaScript";
' J4 U0 H7 c8 d$ z. B7 _ sizeCycle(theText,1,n);0 j+ M: M g' b. O: C
if (n > theText.length) {n=0}
6 J$ V, ^+ o* h3 G& u1 b3 H6 S setTimeout("doWave(" + (n+1) + ")", 50);
6 o" t$ A' `- C- Y: x C: ?}5 y4 D; `- R5 O0 Q0 g ]3 M; r
</script>
/ d% r/ X% f0 g, \6 o1 s5 D2 x/ i<div ID="theDiv" align="center">9 f( {$ d5 h3 K) Z( G
7 v5 g& E& _ f0 d' d3 B5 w</div>( A. A0 }; Y7 A) n
7 c. ?# N- }. ~% x# B6 J7 p
7 W" m4 @3 A! n! ^/ w; i% O. r
( `( x: j; j3 @/ B' b( R$ t9 A
! y; {. ~: A/ p- D6 P5 U第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|