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

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

脚本说明: ; A8 v0 S* `$ H! O

: T; c/ ^# Q3 G( L第一步:把如下代码加入<body>区域中5 J$ f( @% D- D5 r" E
<script language="JavaScript">& p+ e4 \- F) \( {

6 R- P7 V. O( q* |" T1 P" r9 u  Afunction nextSize(i,incMethod,textLength)
" O# x. f! R5 |8 O6 X4 m$ s! m( l6 x{3 k1 n+ h" D- m4 Z
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
5 o( ?" A0 M, l$ f* Z% zif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));5 X- u9 z- H7 G. p) q0 l) Z5 A; T
}
' X7 [$ `! m3 s! j( x6 Q. B- k' g  n
function sizeCycle(text,method,dis)
9 Y4 L8 X0 }* ?{
& r. e7 g: n. J- q) v$ r7 b8 Z# @        output = "";* h% B! y& ~, S% c5 `
        for (i = 0; i < text.length; i++)
1 S! K* I) p& _) ~9 i) y" N( {        {
& }! l: A+ ?2 q  O2 D  y" N                size = parseInt(nextSize(i +dis,method,text.length));( H$ K5 q. q! s# k6 K6 @
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
: ^8 T' @/ K) u2 j: E        }
2 L; ?  d( Y) `3 z) o2 R% f        theDiv.innerHTML = output;- c& f; P( \/ z" b
}
0 x5 g7 L! d6 n. B, ?" b. m# @! K7 M+ U. Z1 w$ d. b
function doWave(n) * z$ r% f. {: C) P0 a
{   # K# a# H" |+ n8 J% h* m0 {. k
        theText = "JavaScript";) _/ E/ w  i4 I+ e, c
        sizeCycle(theText,1,n);: z# v  F0 W. H3 e# k3 I) k
        if (n > theText.length) {n=0}
& n9 p8 J* f/ z& ?: W6 j7 L        setTimeout("doWave(" + (n+1) + ")", 50);
7 \$ [* V0 C. l; _}
: i$ J( ^) S; X7 J! c0 ~# P6 I2 D</script>+ I# m2 {( b5 }
<div ID="theDiv" align="center">
! g7 C, f/ |7 W9 o" Y  A0 T3 r6 U. G$ X! g3 c3 f7 D* W
</div>
4 J' @+ L& g  j- D  ]) X" L4 y! A8 y+ _) S9 s

# F2 i0 h% |9 @6 T/ R6 |4 B. ~5 c0 v( z) [3 ]

5 O( A- B* s/ C6 @. b9 m第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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