获得本站免费赞助空间请点这里
返回列表 发帖

网页之奇特的文字变化特效

脚本说明:
: x& N  }9 F5 q 9 D( V4 [8 `, N6 ]
第一步:把如下代码加入<body>区域中5 V8 s! D( |1 i! Y% [
<script language="JavaScript">
" x( r' p2 y! B9 [" _1 p7 \4 }" H1 z: t
function nextSize(i,incMethod,textLength)
3 I4 W; |+ ^6 [2 a0 F1 l1 P{
* l1 g8 c5 @( p7 V, ^* e/ H. d: V7 R- ?if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
! \- P+ D) f7 V+ x9 Nif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
3 S- r1 n6 R7 n/ i$ J. {7 Q- B}* H% k) g5 f, Y) z2 [3 E/ }4 p

4 W- [& p9 }# {8 {' R. \function sizeCycle(text,method,dis); A: l8 A# t: b2 w2 x  P1 C8 Q
{
7 W! V6 [; F5 e; b        output = "";, ?' ]  g; O" c0 v7 y' s
        for (i = 0; i < text.length; i++)
) K( W+ b" \% ~- w. t- q. v        {2 A- |/ ^( \: }( a
                size = parseInt(nextSize(i +dis,method,text.length));+ N& i; c$ B$ D. M6 p4 f/ y
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
- b4 W1 S8 `& X; G        }" R; t) H/ Y1 k4 C6 G
        theDiv.innerHTML = output;( x# h8 }: M& s" C( Z
}* {# E, O3 g0 J4 s% `

. c6 V8 v4 |" d; [$ c( z/ Rfunction doWave(n) * [+ S7 f1 w6 }' I
{     G  a1 R2 P2 T
        theText = "JavaScript";
8 W+ o$ j; c* n$ k5 S/ J- |        sizeCycle(theText,1,n);& T: ]3 q( p' P6 U4 `( J0 v4 V( r
        if (n > theText.length) {n=0}; T5 z( z7 ?. t; k" V
        setTimeout("doWave(" + (n+1) + ")", 50);- |5 Q0 H7 W  X- O
}, s" M( A8 p% ?# S$ K3 l1 \, ?
</script>
% \4 L8 {3 i: d1 B<div ID="theDiv" align="center">
8 `2 T/ D' V# l$ b1 s7 ]
- r/ k6 z4 m# b8 k* Z</div>. }8 w( L) g# B) ~& U
6 \7 Q0 p1 s  T: a& Q- n& V
2 G' x3 y# \) \( G) A

1 {/ o- I0 \6 T6 b9 t
6 _" D/ z1 x& {, [第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

返回列表
【捌玖网络】已经运行: