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

|
网页之奇特的文字变化特效
脚本说明:
; I: U5 D( ^) U4 J 5 S( r4 ?9 k: ^, [; C: m& Q& N
第一步:把如下代码加入<body>区域中! i5 T% x! J6 t a! U* } S
<script language="JavaScript">
% ^3 u! H6 }0 j( V% I: R& \% i k' `) d* C
function nextSize(i,incMethod,textLength) m! A% h' }2 }0 d
{2 C5 |5 r1 t1 R. n) ]' _
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );. T" H! A% j" k' P7 ~' U- {! ?
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));% _/ R3 ?5 R" l6 q! D
}7 V) Y: S! s: w, f. K# N4 H
7 U6 G* j! l4 o& ~) afunction sizeCycle(text,method,dis)" J9 G0 |* @/ R+ S
{: N; Y. W$ q- y& {' L
output = "";
0 ]- W. l) f. r9 Y& k0 l+ f for (i = 0; i < text.length; i++)
5 |# E/ R4 b' r/ f: t {
8 n$ { o& X# ^: L7 g size = parseInt(nextSize(i +dis,method,text.length));
( x" p# T4 ?+ n5 s* [ output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";: t: }' E: X$ Q( t
}' P. Y& L5 e7 L$ U, ^5 l
theDiv.innerHTML = output;4 O/ v2 C; @: R H0 l5 N
}
1 Y9 u3 b5 Z3 E. {3 u2 x o- I+ j3 T5 Y& W+ H
function doWave(n)
( C. g8 I: s/ z- ?' k{
/ n# n' L$ Z# H n: S( O+ d4 ~ theText = "JavaScript";
4 g4 k% N; z+ n w1 _ sizeCycle(theText,1,n);8 Q7 N- |5 f5 e1 a/ ], b
if (n > theText.length) {n=0}
6 O: r! a8 s1 g6 G7 v9 |: s) n0 M setTimeout("doWave(" + (n+1) + ")", 50);
! z0 n+ w7 M7 B$ [; h: R}, G! I& u4 S8 _- N# v' S' Z% R
</script>
/ U+ t* y, T' U$ h/ X" C<div ID="theDiv" align="center">
; M# F" M# j' r: R
+ F8 @4 k/ D- v</div>
- l# D5 x& H5 Y" ~) P
' ~# h# `. O9 f6 V+ q b
( R5 D" R# r; c+ {. u# q' c) ?
8 N0 H, g7 Y e* E ! n% Z/ t$ h1 k$ p# I. i- q
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|