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

|
网页之奇特的文字变化特效
脚本说明:
! W! i1 y! l$ f) l: k6 |5 z5 | ; k+ }9 ?4 t2 |! l; _- |5 C0 k
第一步:把如下代码加入<body>区域中& S5 o. x( O4 E. H1 D+ |
<script language="JavaScript">
) B/ i' G' y* w5 |- J$ f
/ T% V6 O9 u5 s. i$ Gfunction nextSize(i,incMethod,textLength)& @6 c5 F9 ^1 S
{
# [ V% l O3 w) T Jif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
5 {4 P8 Q3 \" H" @- Eif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
" e& E& n, Y1 P" H5 {}
+ Z: h# Y* [$ ]! @; v. v8 I3 }) |( I: ~
function sizeCycle(text,method,dis)
# _2 e8 G0 b# q, u{: ^! x6 [% _" w! J
output = "";
4 @: I% a" Z4 z3 z0 | for (i = 0; i < text.length; i++)
) {/ _, b3 }8 W+ U {
8 a, j8 W8 I0 e% c size = parseInt(nextSize(i +dis,method,text.length));
& T% H7 ~# V2 |5 R" `7 W3 o3 s# g output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
' r; d$ V7 I; _8 ?0 x- |5 Y9 x: s4 ` }
3 W' j9 Q! T9 m' c+ @5 T" v1 V theDiv.innerHTML = output;" @, Q4 Y( Q* d
}
f& ? D, B, [ [; N" G6 w: M1 w& a
function doWave(n)
Y K9 |6 Q: X7 M1 I4 ~2 Y{ 4 N5 Y6 z: \. O* k/ Q3 H
theText = "JavaScript";
! d; D* j( h8 O$ ]2 ?# C sizeCycle(theText,1,n);
9 u" Z# ^+ z" h2 e8 Q' W if (n > theText.length) {n=0}) P' u* D2 S# H9 Q1 I S- c
setTimeout("doWave(" + (n+1) + ")", 50);
$ O# @6 L. t( P# g) W; d' E- J) d/ e}; x: Q9 X; U+ B9 @& y% q' T# k
</script>/ b9 @5 M; x6 z, L0 |/ W
<div ID="theDiv" align="center">
7 q, x9 Z- A& Z/ T- M$ r( x, L c& x; P
</div>6 W% _- F5 V) I& T( z% p
! k# p( j, n! v) ?( t
# c0 ^) i! u: H$ W6 h* g
' z0 }5 ^, }) P# l: u% S
6 f4 F3 D. K# ~( c
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|