返回列表 发帖

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

脚本说明:
. w+ B7 P1 p1 z' ? ( y2 a3 s" \& D, B: D- D# k
第一步:把如下代码加入<body>区域中' K( v3 u" x" P' R: c
<script language="JavaScript">
, e' _) h* p; c4 m0 C4 S" q2 \. m( {7 s3 `
function nextSize(i,incMethod,textLength)
, s& t0 h5 C& W# ~{" [. H/ h: x) g
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
/ U. L, ?. D; V# e* B- Fif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
6 \3 @9 e6 x3 u- a}
' [' l+ L0 T' A  y& k/ J: Z
, W" O9 E0 m0 _& w9 Vfunction sizeCycle(text,method,dis)
/ R. k" g9 `* t2 l. W5 ^{. W0 F, I. `. b9 S* w* w% P5 g$ y
        output = "";
. a' F2 z8 I+ ~, p        for (i = 0; i < text.length; i++)- n( @2 r' |: e. ^) Z- E% E+ D
        {
4 J  F, K' H4 j7 y( Q                size = parseInt(nextSize(i +dis,method,text.length));/ `. H% N$ M4 l: o
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";/ p7 [/ G6 L& z! }# C! t
        }
! ?1 K: X3 H; h& U; f$ ~( X        theDiv.innerHTML = output;+ z. u/ S! C5 m. {
}
7 ^; ~: ?. o8 e% G7 [$ U4 V# ^8 h2 A' D& O; h
function doWave(n)
' d* a& s* u8 \/ N{   
, ?# J7 [: }  k6 ~9 L        theText = "JavaScript";
3 x9 Y: W# w( G8 A        sizeCycle(theText,1,n);' z6 p- ?; Z! ^& A! k  P
        if (n > theText.length) {n=0}( {6 e8 L' }7 s; n9 W
        setTimeout("doWave(" + (n+1) + ")", 50);
: j. {' w+ X% }5 l}
* R9 c8 ]" c5 C  |" n$ R( R</script>
$ c( h$ ~) n  ]* g) D1 p6 c% E<div ID="theDiv" align="center">4 ~7 x2 o% ]3 X0 H1 E1 k+ \4 |
( a7 s! |2 ]0 t! e8 j1 X1 h+ O  F
</div>
# x9 ~# |% |3 @' v4 I1 E' d/ ?8 c! M) O* E  i5 D6 K
; P; d1 d5 V' |: Z  C- |. Q* i

& T: {8 E4 \9 R5 f( y+ d
% y( X0 q  `. k4 B, H& p第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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