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

|
网页之奇特的文字变化特效
脚本说明: # a0 R( y$ O# B8 l5 j
- M, d+ j% l# ^9 r) b" d
第一步:把如下代码加入<body>区域中; ]0 M8 s' j" A" v
<script language="JavaScript">+ V1 ^( e. \3 w
0 I) f, J G* x; F* Y) r
function nextSize(i,incMethod,textLength)/ d* I. U8 P! _; b
{! U* e7 Y; B& R0 B8 o2 S
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );9 l [, O( D2 M, c
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
2 ?( H. v, H9 q+ C. Y}) ]5 a/ j$ C# i, C3 ~
# p/ C. O: u; G& ] {! Q" `
function sizeCycle(text,method,dis)
) p7 g o0 d+ N8 f{
. ]# {5 O) I% b1 f9 o2 E2 t output = "";6 P& G h, g a/ V
for (i = 0; i < text.length; i++). g- i) Q& G+ ~! X9 a( t+ M+ A
{
1 F( Q9 g+ J9 \) _) z; q size = parseInt(nextSize(i +dis,method,text.length));
) Y' Z! p# r9 o# y! n output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";5 ]5 p: M" ?6 A2 ~! b
}% P3 q$ Q# y1 d' v" ]6 p# W
theDiv.innerHTML = output;4 f2 C1 K0 Z: }
}' M/ x. b" i- k! z4 f0 \# t* d
& N! t. H+ v: S# A5 ~5 q; Bfunction doWave(n)
/ r) n# I" \, ]2 B3 |0 ?( T{ ' a t( [9 n# u' B
theText = "JavaScript";
# L7 @* R- v. ~" l; T sizeCycle(theText,1,n);
9 L- j* i' S% \7 W; J if (n > theText.length) {n=0} ?) j! f; z( I& v1 ^9 j9 s
setTimeout("doWave(" + (n+1) + ")", 50);
/ C" n; N1 B/ ~}4 n; s2 _3 \& D
</script>
) {: A; h$ A1 Q( O1 Q' a) G<div ID="theDiv" align="center">9 a+ j4 d* h9 A9 r$ Q% N
+ f+ V4 t- d. }4 R' A; z
</div>
& g! M7 X4 a6 \& n8 v' g& U
- x' _& V: c. F+ Q( P6 v# R) c; c2 l- i- C( I6 u7 ` U: `
+ ~5 \" L& ]( |2 t
" l4 G$ ~! E) |( |$ c) l$ f' }第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|