返回列表 发帖

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

脚本说明:
4 i7 C( C/ I/ i6 D# h% b 2 A2 f, r& n2 [& ^1 h. l
第一步:把如下代码加入<body>区域中
" P$ l6 }% ~) j2 s5 I2 x+ X5 c <script language="JavaScript">( H: X( Q- f! E/ |- t

' R3 A0 \% f. M. _$ {: {! Lfunction nextSize(i,incMethod,textLength)" K4 w1 m1 t5 X5 L, Y3 p
{
1 ?% O/ c3 E+ Q' Iif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
0 D7 w- t8 ^. G) B" T) F/ oif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));! ], ~8 i  {7 Y; a- k' K* R
}
8 g) L8 f- _  A, T# d7 a5 L% s7 T" ?$ g7 M
function sizeCycle(text,method,dis)
$ ]4 d( {7 P, u4 E' |5 H. k+ _{
" u4 A7 P4 f0 Q& v3 a+ C. o& w        output = "";! y& x- f- V2 e  n. Q
        for (i = 0; i < text.length; i++)
  @4 O8 g: \8 |# s& H  V- w2 ]) k        {
# E; ~$ e7 Q$ Q4 f                size = parseInt(nextSize(i +dis,method,text.length));
; \% c* T/ \. Z                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";7 T* n  A" D8 a
        }
0 C$ J- ~1 r& r7 e; _% ]1 N8 P% ]        theDiv.innerHTML = output;/ T5 P, q' T) |+ A0 C  \1 t  I: N0 i
}
+ a9 ?3 B+ L" z/ C; K1 `! L* y, E8 l2 u; _& ~: c" b
function doWave(n) + O3 M. G. J+ T  M) N5 Y1 ?
{   . e# h7 O+ }% `+ ~( G0 q
        theText = "JavaScript";. Y- U3 I/ Q4 b# h6 u$ Z- c3 _
        sizeCycle(theText,1,n);
3 H  l9 c* K! T0 C. P        if (n > theText.length) {n=0}8 b  K4 l1 I5 e4 P7 D: q
        setTimeout("doWave(" + (n+1) + ")", 50);" }+ [4 D' R  ?) ^% z( |, s7 D
}  X; S8 m  t1 r
</script>
( T6 V; m9 J4 t/ b+ w<div ID="theDiv" align="center">. U+ `# [6 e1 [" d) W+ @2 Q/ @
- |" l# v1 S& s& e/ D
</div>
& i6 Z3 D' d% e' j/ x6 ]$ U( `, |# z7 B- A

; b8 Q' y* G6 f6 B+ {
4 c5 N. m) D5 O5 y
; }8 o) e  L; N4 ?" U1 C+ Z2 [第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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