返回列表 发帖

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

脚本说明: 8 I( E: O. M6 H% v
0 t3 y% R( n, E: i7 ]
第一步:把如下代码加入<body>区域中! C4 W/ n+ Q/ `1 j. I: h$ q
<script language="JavaScript">! k' t$ \: |# P  z6 d

+ M% Q6 `+ ?" p+ F- V) wfunction nextSize(i,incMethod,textLength)* k4 l' j0 @6 [1 V
{! O" I) a: S2 ]4 M4 Q
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
6 K1 V; S1 e/ ]1 Y/ I7 Qif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
' z+ ~3 |- x$ b; F}4 J; K9 V0 h+ q; v2 y* b

1 }4 ^! e2 Y/ A5 `2 B6 ofunction sizeCycle(text,method,dis), Q% |' H! F: _/ \
{
) i5 }1 f6 u2 Z  L# c5 y        output = "";) p: Q7 X  k) P% E* Y# [6 L8 l7 O% f
        for (i = 0; i < text.length; i++)% s4 @! g9 a! d6 `' n6 h% |
        {6 [! @! A1 D4 `5 o' _
                size = parseInt(nextSize(i +dis,method,text.length));
4 [/ T0 P+ v9 S                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
8 i$ d$ C4 {. u        }0 l( t2 f1 R' {* A  D) U
        theDiv.innerHTML = output;
& |% S9 X+ N% K0 ~2 C6 \}
4 v7 _8 |) U$ P0 }* c  z9 A9 I4 n! [& H, ?, F9 b3 _# j& z
function doWave(n)
  ~* K+ F- b9 L" D% P$ L3 o! S{   
; V( q/ Z; o, \0 V+ y        theText = "JavaScript";
+ ]( \# k5 g: g) m% {' L3 ?1 G' O& E( [  m        sizeCycle(theText,1,n);7 y1 Z7 m7 x; l+ k" c) j! E
        if (n > theText.length) {n=0}
9 I: M3 {( {; b2 Y        setTimeout("doWave(" + (n+1) + ")", 50);
% |! _( v1 g  z}
" a+ r% i) ]1 B+ C</script>9 ^' v5 p% y9 B& t- F- ~" Y+ ^
<div ID="theDiv" align="center">
/ A/ T! w! H1 ]" ~! F# {! P0 L; ^
. P1 Q" ~! Z% v8 n, f7 _' m</div>
# N0 r$ R6 q2 m  i2 ]/ E9 E$ B  d, \7 u2 X2 h2 m

+ T0 H6 G! G; s* O+ Q+ ]" b" o
! f3 I, Z  d# @+ |9 V' n9 D + @/ J6 k! L1 O8 `
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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