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

|
网页之奇特的文字变化特效
脚本说明: 4 b7 d4 g! R4 n. i3 i$ I
- _% Y8 {6 R' D/ [- J1 w/ p% k
第一步:把如下代码加入<body>区域中
# E3 l& z% B# L: |, `- e <script language="JavaScript"> `5 h. S7 {9 s3 n6 T
4 G0 L- n ^8 x6 y% I7 Afunction nextSize(i,incMethod,textLength); W" A# d2 t3 O( d4 B2 r: @
{; R: t) Y) ~$ h) m$ @3 i( ^! G6 J
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) ); y2 o1 F6 R) q; H# _& H
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
2 k/ r9 O H, a: X% a}8 g. B6 x+ }) h. y# b" A
1 A5 {, O! g8 L1 D! X2 H6 Y; Lfunction sizeCycle(text,method,dis)* o6 Q3 g4 h" {6 D9 J
{: q! L% ?5 ], g1 ^5 I1 T- b
output = "";8 `0 y& f* g! W# ]. y- A. W$ s
for (i = 0; i < text.length; i++)
8 j3 S; `/ [- j* J1 q {
5 J2 C( }7 g& j2 F6 |2 e size = parseInt(nextSize(i +dis,method,text.length));
, F. H4 S0 q1 _! h9 o- |8 g$ ` output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";) q4 S$ J- a5 O6 X1 b( f9 E
}
/ N, ~( S# `$ t theDiv.innerHTML = output;" K! S5 {6 I% X
}. N) C n5 E* T& R
, I2 j4 m2 |( o% N, cfunction doWave(n)
& A& Y% r l+ G" V! l{
' I6 _, G. h2 `4 Y! M! W2 Y theText = "JavaScript";7 B, L7 B2 a9 P: s
sizeCycle(theText,1,n);
$ o7 H% e! W! b/ W if (n > theText.length) {n=0}! h8 C3 j6 y0 ^, q2 M' k
setTimeout("doWave(" + (n+1) + ")", 50);
/ X; P9 g, K. F# q4 e}
) ^ Y7 h+ u. ^</script>& c5 @; z0 U& a9 n; d% Q
<div ID="theDiv" align="center">
; d5 N% d. n( K- L& S3 C: F( c6 W) p8 ?; u
</div>
X: _! }" u! V# ~( d/ v3 [9 X8 @2 T1 F7 h6 H6 W
, S5 ?. I6 e) A& }; U" L( x7 Z
1 j7 Y g+ o, e, j$ a0 a
9 L- i4 {! ^& J" i/ N2 t第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|