返回列表 发帖

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

脚本说明:
# @, _; D4 F5 b% M4 _ 7 U: Y. r$ b. S, E. B- m! o
第一步:把如下代码加入<body>区域中
+ _/ P* k% R2 H9 v4 B) s <script language="JavaScript">
( Y0 Z+ q3 ?5 T, K7 \/ n3 u  Z3 @1 A+ P) @  P2 D
function nextSize(i,incMethod,textLength)
7 m+ Q( s$ u2 t! [2 H! t{- D3 o* {: z/ h2 y# d0 k
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );6 Z/ L' L8 \5 f$ d% T6 c# O
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));# l8 ?# _# u/ R# Z: a
}
& T) X# |' V6 b, y/ J0 J5 w0 T2 ~/ A& Y- G* y: {; k# i3 O; M
function sizeCycle(text,method,dis)
3 r4 ]; c0 N: b/ Z# \# \{7 K3 k, e7 X9 ~" U0 |
        output = "";
5 G1 w3 a( B( n7 i" W9 e        for (i = 0; i < text.length; i++)0 N" f, \" u9 b
        {9 a$ O* t/ C' m; Y: {( k
                size = parseInt(nextSize(i +dis,method,text.length));
; |: G( E9 ~, J3 }                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
# [' p6 _+ o3 }: y        }6 ~7 ^! x5 N/ [3 ?! ^
        theDiv.innerHTML = output;0 x, ]7 O! H" m
}: i$ ?3 v# U7 D# e7 {
/ d# W/ Z0 L& F2 X# E
function doWave(n)
2 Z8 r' ]; \$ ~# h{   : Q0 ]# N4 W# h' b& o
        theText = "JavaScript";
) y' H5 D( _9 v( q5 k. W, q; O        sizeCycle(theText,1,n);
9 x5 }( r% m; R. i% P        if (n > theText.length) {n=0}6 X% n9 m8 Y+ K  F
        setTimeout("doWave(" + (n+1) + ")", 50);" ]3 e0 ^3 h) c# ?& {* ]( [
}! m: Q. f3 h# i8 O
</script>  Z- f! U/ u2 c
<div ID="theDiv" align="center">! x6 n4 g' Q; c0 H; p
( Z9 ^- _" q# x9 m8 k8 T8 M& ^2 F
</div>9 A0 ]  B7 @3 Y% g1 a6 P; w" F. u2 q
& W3 Q  Z0 Z7 i" u$ {. o2 z

8 `: k9 Y! v4 ]" T& S2 _* p: q- i) a* ~! Q: A0 d6 g+ [

& n, q- }  M3 \, _第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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