返回列表 发帖

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

脚本说明:
$ f% I% O" Z- u& ?  u* C2 h
0 ^" r6 V' @" [6 e2 n/ H/ ^' d第一步:把如下代码加入<body>区域中8 h# U4 p" i' ]/ b- J
<script language="JavaScript">
& h# ~% g& t- H! a) t  l2 Z, }7 q0 u, e$ T3 F( T$ h
function nextSize(i,incMethod,textLength)( y/ \8 `2 C3 {5 x9 X  }1 H
{
# g4 V- T  L9 `- W5 cif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );& o3 v- g0 s- c4 k* P
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
  P, N2 t0 ?+ D) m% E}
3 ^* t" A; S# M. e& o2 u4 |
! q: u: `! a( \1 J2 Mfunction sizeCycle(text,method,dis)$ S3 t& H' O; ^' q! o3 x
{
+ [( r: ]8 T: [% ]& X) {0 }$ D: R        output = "";, z: d3 t& O9 N1 T% G- A# B
        for (i = 0; i < text.length; i++)' G& K* @( S8 ^" G* M  `
        {$ J# R. a7 e2 v
                size = parseInt(nextSize(i +dis,method,text.length));
. z0 m! {) k  g                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
& {3 l0 g: l9 B7 B        }
! m# P0 J/ f  |% _0 c, a- P        theDiv.innerHTML = output;
* U# O. T* b2 x2 {8 `% T0 C8 n4 h' s}
. K' }6 o# e) c, |3 z: F2 v
# ~7 P( E! a9 ~8 Ofunction doWave(n) * e" c0 i# |  v% m
{   
1 R- U$ n: Z. e- c9 x, }5 o1 M        theText = "JavaScript";3 K- h- b+ p/ R# p* s% F
        sizeCycle(theText,1,n);/ ]9 V. _5 L8 L0 N9 L
        if (n > theText.length) {n=0}4 S2 h% P8 L" Y0 N( w
        setTimeout("doWave(" + (n+1) + ")", 50);
/ Z5 L5 ^8 G6 Q- x1 W2 G}
) Q$ j, y( G8 M3 P4 \5 a</script>8 ^. ]5 X6 E7 d0 V
<div ID="theDiv" align="center">
& O8 c8 @' l1 }! j2 G" H9 {2 i, u. k$ _9 G2 U5 X
</div>- D  o; E/ P5 y  I0 @
5 r) i$ [9 [0 T2 t) a' ]0 v

. F' h2 R  K. r7 g5 q( e
0 _6 |! s% b' F  A. q * R% @/ ]1 P9 u1 }0 I  {
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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