返回列表 发帖

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

脚本说明:
4 z5 h# Q+ o, H3 z7 ]! f. ?
; J' F! G9 Z/ \第一步:把如下代码加入<body>区域中# y9 X. \# g/ n! y0 C
<script language="JavaScript">' M( I9 A. S0 T3 r% i$ V- ]
0 ?; \* V8 C! e, t( ^
function nextSize(i,incMethod,textLength)! w2 w' h4 C9 \/ v
{
1 c- A  \* e1 Eif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
& C  o; r0 B/ D- f5 qif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
* T! R, ]2 W" U9 x! s}
- M/ W5 R+ m* L* Y
1 i% ^# ]; a) p; }; ~) q+ ]+ }# ^function sizeCycle(text,method,dis)+ M/ q: ~( n0 u# n8 q: T' W/ [
{, C  c9 r9 j* {* P6 [' e
        output = "";7 C& V7 V9 V2 ?$ s0 Q7 e  I+ s
        for (i = 0; i < text.length; i++)' S  e0 J9 M9 b+ r" k# U- C
        {/ _6 z# i: w8 v9 I
                size = parseInt(nextSize(i +dis,method,text.length));; b+ A$ d6 G& f& V, i; q) i
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
$ c" A5 o; ~) i5 B2 s% k1 a) G        }# r! b# h# q! q% m
        theDiv.innerHTML = output;. \% f/ E7 \* Q3 c% a/ j
}
3 t7 f( [$ ?9 R" d! \
. D# [( l. P% R" T$ E  afunction doWave(n) . _, Z  {1 d. l" A$ w' n/ z
{   - I5 {) W; X" \" |5 s  k
        theText = "JavaScript";/ d3 }, z# Z( z) ^" N+ o* i3 _
        sizeCycle(theText,1,n);
2 L  h/ T- B5 ~9 x- b$ T1 ]( ]        if (n > theText.length) {n=0}
0 }0 f7 C. j6 F# T( M        setTimeout("doWave(" + (n+1) + ")", 50);6 D  j+ c. d1 i% _
}
4 h( n: m; n" K5 Y; G</script>  j9 @, p  o) o) O" S
<div ID="theDiv" align="center">
9 b  s, @" a6 X0 _
4 c6 O+ T( |8 J% r</div># n% J9 K2 n! x# l

+ I! B( ~! F% C( ^& _: d, a' W! K* ~3 [+ j/ U* c
& E9 M/ q. a# s' ~0 @0 E
3 x3 D; S' F7 V, w8 B( [5 |
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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