返回列表 发帖

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

脚本说明: 5 e, x4 n6 V0 F- u/ N
/ w5 W$ `7 m: V( A$ q
第一步:把如下代码加入<body>区域中" Y9 W5 p# y3 m3 W" P& F5 g
<script language="JavaScript">
3 i  ~9 }  L) l2 I. b) q7 F. i/ t" a7 L5 b0 X/ u: w
function nextSize(i,incMethod,textLength)& o5 n+ {/ q. K* h: C: ^6 U
{
9 e$ \6 C/ L" g1 R7 U6 b# Q( eif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
- l& m6 d, B- e0 @5 ]! N0 Yif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));* T5 m, {# K& P" s4 T
}
5 Q! p2 J  O6 Z+ d
) l1 x; d  T2 P/ cfunction sizeCycle(text,method,dis)
* T  N2 {$ k4 |) l{
& X3 `! V4 k% Q        output = "";
9 P7 r3 O8 Z# Q$ N* \$ e        for (i = 0; i < text.length; i++)) E$ c1 G3 _: H* J/ z
        {
- w; X4 N; N5 I8 R$ K9 j                size = parseInt(nextSize(i +dis,method,text.length));' g% s$ ~7 k' o# G% M1 @, j
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
, ?: x% ?5 K8 R- P        }
: g3 K" b' k+ z6 o6 @! G        theDiv.innerHTML = output;
( r) c) Q" h2 p( [; A' d}2 h, w+ O6 F" r+ g$ v' W8 p; q7 O3 {
/ q- {( j! C3 p3 Z6 S
function doWave(n) % t" B8 _! ?9 P( V
{   
1 h4 J+ K# `  ]; k7 g, s9 {4 W+ q9 w- X  z        theText = "JavaScript";; g" L" i  _7 m9 @; h
        sizeCycle(theText,1,n);* t6 [" z1 t3 {$ `  D9 ]
        if (n > theText.length) {n=0}2 Y) O+ V/ ?/ D9 n0 I+ D, q
        setTimeout("doWave(" + (n+1) + ")", 50);3 _) H0 @' s' ]9 C1 q0 m
}# w  n" J% \8 f# ]( g  u
</script>/ ~0 Y  D5 |9 S! o3 U  E/ ^
<div ID="theDiv" align="center">6 ~! x* d' y0 t/ |" d1 a
5 u$ w  b7 [( r8 d( k
</div>
1 ?/ P& |% B9 o5 W1 g" z. S2 U/ _# J# _2 F1 Q9 l& t
: g0 I0 l6 [, ]9 ~5 l$ t

$ x) i5 `  w  {/ d' Y( \  I% M ' W' U( m1 i8 Z0 s& V* ?
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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