返回列表 发帖

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

脚本说明: 5 I' U, S: M8 `/ e# L- J- `' G  j

3 h. d2 J7 o% R第一步:把如下代码加入<body>区域中
& |3 k" d. V; D3 }' b$ x* P0 A <script language="JavaScript">
0 J7 ~. c' E/ x! I8 B% U0 G1 u! u3 H$ b' I
function nextSize(i,incMethod,textLength)% K' p4 {. Q1 I" ?2 W
{7 `9 h+ ^# ]; ?2 [$ L+ j" k7 \* J
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );" m9 N6 p7 s# d* c  Y- j
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));2 P) N/ \, L: h+ a
}9 y, e8 V3 M% @1 V+ ~; n9 g1 l
/ e9 Y6 U2 C! V: j
function sizeCycle(text,method,dis)
( {+ O8 w* e% R4 J" a3 A' `{
  Q# |( B  s1 O3 ~8 @% Y' T        output = "";3 ?& S" ?- ^5 R5 I
        for (i = 0; i < text.length; i++)
4 S2 E3 {* O) y+ r% S; \6 Z& _        {
6 o' z% m1 Q% Y4 x# {) m! S- h                size = parseInt(nextSize(i +dis,method,text.length));# z) t  R% @3 f( }9 ?$ }
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";  H5 A7 r0 y4 x+ {
        }
! Y8 z( w: q+ C4 g' d        theDiv.innerHTML = output;
$ E7 x' U/ y3 q}
" ?8 U5 A& o: Z8 T) E! B
' ]  S! ]9 {& ~" ifunction doWave(n)
- ?  Q9 G$ t" \8 r2 ^{   
1 P2 h  u  h4 C        theText = "JavaScript";
% G% M+ u& M1 G        sizeCycle(theText,1,n);
/ J' a5 _+ X6 j% f9 C        if (n > theText.length) {n=0}7 r9 ^3 x6 s: i! l, N5 S
        setTimeout("doWave(" + (n+1) + ")", 50);  Y. ^2 _# V' X# t- C) C
}/ f7 U9 R2 M; p6 k7 V' I% Q
</script>
0 X- }$ z! X+ x! V<div ID="theDiv" align="center">8 A: P% v3 f0 n) m1 J( e# V! \
, m% a0 H4 U* ]  G# a: d" j
</div>, C+ S+ `( _; t$ M, ?: X3 y

* j, g) D" c  y4 T5 c" L# R# E3 K! t* C8 b% Z7 B
9 G4 |# t1 Y6 d: t* v, C
8 f" H6 X; w9 {& q- F
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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