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

|
网页之奇特的文字变化特效
脚本说明:
/ e* x- u+ T6 i* Z; p # b- u" [3 L5 {6 F6 S% K4 O
第一步:把如下代码加入<body>区域中9 t+ h3 b' k, E! j1 b/ n4 M5 ]3 l
<script language="JavaScript">
+ k/ C/ T; r# [6 d
3 _" T/ S4 \ h1 t5 Yfunction nextSize(i,incMethod,textLength)
- L5 _, h) t% N6 h3 j{
/ o7 g: ~+ N, h& O3 l( d. Eif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );% l6 w' b; R$ v8 K$ p
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
) z) X( W3 o* G& B, i}2 {4 E$ C7 I) f( A1 r* v2 J
: M5 W3 s" H: H' afunction sizeCycle(text,method,dis)% B) }* B" Q. D7 }8 d3 v
{
8 I- \0 i0 k( M output = "";$ ~. {4 ^+ l+ {# u. X
for (i = 0; i < text.length; i++)& r) K8 x, ]# G8 E% [
{
& a1 H+ V3 \! d( ]! A& g$ A7 c5 V8 o size = parseInt(nextSize(i +dis,method,text.length));* m! `2 C8 g, Z9 ?0 i k
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";2 {- L+ t! o" g5 Y( d1 E; s6 T# U
}' W+ L' e5 Y$ q5 A! h- p
theDiv.innerHTML = output;
( ~5 y1 ]+ L7 H( b}$ [7 z( |! F9 P+ ]6 \
4 G/ V) p- o$ ?/ g- r% S
function doWave(n)
# e n0 }/ r* E. B7 [{
& G3 d" n, p W O2 i theText = "JavaScript";
2 S8 u9 F; o9 W$ U sizeCycle(theText,1,n);
; ~1 @, P/ ~0 [ J" B9 E if (n > theText.length) {n=0}
2 |+ ]) q* V* S! M5 V4 R- j setTimeout("doWave(" + (n+1) + ")", 50);
4 f: t* |2 f+ T% J3 I8 S}3 h% e6 l6 r+ s! C4 K6 ~+ |
</script>
. {' |2 x4 l8 S* v<div ID="theDiv" align="center">) N3 y3 g4 S5 L! I% @; J0 V
M9 H" c1 _7 j! w; }% F6 l
</div>3 ^3 \7 l; O' }/ m
' f5 s4 | v) f g
3 n* V a# h& X) i7 t6 R+ w1 f; Z5 r: {0 u* P9 y
3 Q& {" h, |6 A# x
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|