返回列表 发帖

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

脚本说明: 3 J$ H% t4 r, |# f; e

) C% w9 Q/ u$ [0 H2 d: A第一步:把如下代码加入<body>区域中( |' D( u+ h, v: o& G
<script language="JavaScript">
* M* p0 `- R2 x8 R, e/ U' H1 Q/ c- ~* k" c$ N
function nextSize(i,incMethod,textLength)) W9 ]6 h2 J# L4 o3 D
{0 V0 Z. C8 G* C7 H: Y
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );/ D/ v% [7 g5 z) o2 G7 N7 [1 N
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));/ Z; F# q  t+ [  L% d
}
5 i9 h) I! j0 B, `8 |* S0 a5 n4 N# @) K# c3 R6 X3 W+ c! B
function sizeCycle(text,method,dis)
& c% p! [& v% H" f4 g; g{& {. p# w7 @9 m" R
        output = "";5 y# Q# }2 y6 X( i9 e
        for (i = 0; i < text.length; i++). r/ e+ n9 o8 S- c% Y
        {
& Q' t' Y$ A5 F  ?7 z. z3 M& t                size = parseInt(nextSize(i +dis,method,text.length));# W: `  G6 }" X6 m7 Z* y
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";8 L! g9 Y/ f7 P
        }, q$ R3 }, t( ?" A
        theDiv.innerHTML = output;
6 m* c- `: b1 I/ G$ h7 f' |& Z}
. A& d* N1 s) t! i  G* @( ?9 w8 W4 B. e( c
function doWave(n) 3 t- F3 T2 G! G& i# x: U& [: K
{   
% `# T! u) s6 @, \" C        theText = "JavaScript";$ X( M$ J  ~" u: x6 F
        sizeCycle(theText,1,n);
- t, p1 w% X5 D8 }        if (n > theText.length) {n=0}
; z3 T$ d: l% T1 F# R: S        setTimeout("doWave(" + (n+1) + ")", 50);
% f! o: z) P( T. u# h}  l. [* f  H3 [6 W" b
</script>
0 ]1 n2 E! N! I7 w9 C3 G<div ID="theDiv" align="center">5 `5 I6 S$ d- _8 M) D6 Y# p# N
1 ^3 l0 f8 X0 f/ P% F, \
</div>
& Q* w7 H; y2 j* l, j
8 o! s1 I: y+ `, c( O) t9 O: {8 z- M9 E+ U8 V

/ }! Z* @+ |& d9 y  [. p" n3 H   Z1 P3 {- w: Y% M' Z# g
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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