Board logo

标题: 网页之奇特的文字变化特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:50     标题: 网页之奇特的文字变化特效

脚本说明:
; p: r$ _8 {- Y  I  H
3 h) Q  t( F& U1 S  f, z  Y第一步:把如下代码加入<body>区域中* l  X% p) S7 d" [$ E* e
<script language="JavaScript">
6 F' j5 E) c4 j: b- U  _; I: ^" A8 @" R8 u! ?  A( l( ?8 o* N- u
function nextSize(i,incMethod,textLength)
; u9 g7 {2 b' I7 S) G( i{' B/ c1 v/ B/ {; ^0 W; Z
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
8 `' B$ z' Q/ H6 _* k$ |! ?5 Fif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
6 w- k+ p$ [. t}
7 E# f5 S* h, t& M  {' I2 i2 U# T8 x* p- r% c' V" S
function sizeCycle(text,method,dis)
. Z6 D( c3 S( U* y( Y{5 r; h7 n$ ]& U
        output = "";% Q+ r2 J. z% g% n  s' Z7 D) U
        for (i = 0; i < text.length; i++)
1 G) ?$ _5 j9 W3 u/ n: ^1 m# c0 F  l        {" v* U2 q/ n6 d3 `' w/ j
                size = parseInt(nextSize(i +dis,method,text.length));4 {, C) Q/ M# o6 b: x# b2 g( ]
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";1 b& y' y9 r0 V+ I; n( d9 H
        }( F3 o5 c7 S% e, V  j2 v1 G' q
        theDiv.innerHTML = output;
6 W0 t5 I9 P% n. Z}
6 s( f1 h/ |0 |# e& \' t( ^2 z2 P* i1 ?  Y& p2 {
function doWave(n)
1 D+ W) j7 `# G{   
8 f4 B% S3 n8 G5 ^4 p        theText = "JavaScript";
" S6 M2 ^! T/ A; T. e+ b# f        sizeCycle(theText,1,n);& g5 k  ~, P* f4 U2 M8 B  _
        if (n > theText.length) {n=0}% Q' ]' A4 q7 C2 V
        setTimeout("doWave(" + (n+1) + ")", 50);
7 a' }" x" h/ X! ?# H4 b}1 Y7 C' u% H9 f! a" c- Y1 z
</script>3 p3 X% K3 B7 Y! M% r$ t3 Z6 o
<div ID="theDiv" align="center">
# f4 G, S! U4 p+ N, p6 q  H0 V3 h7 C. g+ K1 W+ |' A7 q
</div># ?7 N5 H0 i: I) K

/ j0 c# q. }1 e  k* ~' p
# N2 F/ Y& Q0 v( R4 H) X: s
8 |4 [- ?9 y: e; A 5 U: _2 M0 K2 o8 v. {  X( b
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>




欢迎光临 捌玖网络工作室 (http://www.89w.org/) Powered by Discuz! 7.2