返回列表 发帖

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

脚本说明: . s; J. m) y( m" {6 w8 o

1 {; c- w6 O2 M  j& B第一步:把如下代码加入<body>区域中; i8 X6 H1 m9 ]6 c/ L0 i$ k
<script language="JavaScript">4 t" |. n* P7 ^4 N) t
% y2 E7 M5 l5 b0 t* E* |$ x
function nextSize(i,incMethod,textLength)
: ~  r" J, H, l) [  g; S. Z  y{
2 `' H8 X( X5 i  Q6 H' C8 \if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
% g! ]4 j% P4 I1 M1 e" r/ A4 Bif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));# s1 D4 Y) i0 U+ \% M, q$ N# s* [
}
0 d( |! s9 f, L5 P
$ y/ {) q. {& ~! I1 u0 p3 Efunction sizeCycle(text,method,dis)
0 r' z- _/ |3 k. w) L& G9 H" D{
  T( S) \: [* E3 P1 J3 a        output = "";
# y2 ^( L5 H0 l( z        for (i = 0; i < text.length; i++)
' V6 n( Y1 v3 ]% @. _        {  o2 N2 _: H9 _1 `$ P8 D
                size = parseInt(nextSize(i +dis,method,text.length));4 i; y* o/ h+ ^5 c5 h% Q' ]) N# i
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
) N% @# a2 s7 O9 ]2 T        }3 g" s0 ^& K' W
        theDiv.innerHTML = output;
: k4 z2 @  x+ q  S& q8 k) {}
, b& c, H1 c  ^& y( v1 @) k7 _, \4 ^) s( [  Z! P' W+ N9 R
function doWave(n)
' G! x6 F5 t# O" }' A5 A1 e3 M{   
9 L. R5 P: y% I( q! S; F# M' R  Y  G        theText = "JavaScript";
$ Y6 `- S. ]8 n& s- v) x! w        sizeCycle(theText,1,n);) g) i! r$ f6 |6 R/ _
        if (n > theText.length) {n=0}. h! f+ w9 Y0 \5 O; E- H. M7 B
        setTimeout("doWave(" + (n+1) + ")", 50);9 K/ G  t8 Y. F
}
' d* o' r& F- \7 K7 z( E</script>
7 B; ^, k$ P$ b8 E' Q<div ID="theDiv" align="center">! y2 Z/ A/ p; o7 R. e2 d

0 w, b" ^; Q* X& f* v</div>
% X. @, y7 u- U- G9 d) w- F
* d& [' ~* Z/ ~$ r2 S3 E" ~5 B4 R  \+ j/ G8 [  l. g
1 ]( P; m: n  A4 |9 A

* l& A$ ]2 p  O# F6 U第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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