返回列表 发帖

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

脚本说明:
% H3 T& T7 ~4 Y% ^
# N8 F: |; V% M% h7 Y! D# C+ Q' p第一步:把如下代码加入<body>区域中# _$ |' k  Z" m( A
<script language="JavaScript">8 ~0 i% O. U- b+ ^3 _

, y2 J7 Q3 k; j+ a8 Wfunction nextSize(i,incMethod,textLength)
# L5 w, M/ T: f( C5 w; Y{: M" E9 ^; [* B  y) b+ G5 p
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );+ }" L, L$ U* Z5 d( k$ h7 t
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));3 }3 ]1 i9 z1 y/ C: Z% w# W* f# W, {
}- t2 k* z: l! K3 m5 r7 K
4 r  H5 ^) V0 [% v2 t
function sizeCycle(text,method,dis)
; O- D3 X, r# U4 E{3 W" U0 o  w- J
        output = "";; f$ K# ?  w: j) f+ d2 n  E
        for (i = 0; i < text.length; i++)$ A8 U) {& o. f+ H3 Z; e
        {  w8 l! @1 X. n, @8 {
                size = parseInt(nextSize(i +dis,method,text.length));( C; J% T3 L# S4 M' B
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";" Z) H+ U  H, A; H  V
        }
8 v9 Y6 X; J& J        theDiv.innerHTML = output;
4 \$ p& A6 @3 P+ u  o7 ^) R}
' ?$ K: V" N* q5 o& f  I: J( Y/ L# h+ G6 M* y) r$ x) v' _
function doWave(n)
& X! U2 ^1 B$ }3 A4 L  b  C{   
7 g: E( G( Q7 c4 R! w, g8 r2 }        theText = "JavaScript";0 Z: D  Q4 ~3 B) d
        sizeCycle(theText,1,n);+ G( M2 `/ [4 J* w* N
        if (n > theText.length) {n=0}" p; {+ `! |; _2 \
        setTimeout("doWave(" + (n+1) + ")", 50);5 c& Y0 q4 F1 T( F
}
% K& D& W8 F5 Z; [. P8 @</script>; N! q4 E% ]; O7 X
<div ID="theDiv" align="center">& H- K+ R& a' T: \

% H8 S9 D+ B. o6 Q) A# K8 E</div>$ X1 ~$ K, d; H$ C+ }

8 v5 a0 U3 W) x. Y3 u! s
1 ^! g2 Q( J" B0 a- ]
4 d# W( v- X9 w: K# f
5 `/ O( ^4 i6 `: Q8 Y6 V/ N& U第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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