返回列表 发帖

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

脚本说明: 2 m! J) F. Y2 n4 F5 ]* l& ~! `2 v3 F
0 `$ T9 `) h! V; N) w( Q+ S& _) X
第一步:把如下代码加入<body>区域中
+ G- a0 l9 h- U5 Y <script language="JavaScript">1 o; l& _7 _: P% d
: O9 `6 |4 |+ S$ C
function nextSize(i,incMethod,textLength)
' j: G% a; U) \- J" i4 Q7 d{) u/ c8 ~: y# ~6 q  Q: R' g
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
( m$ \1 E3 ?1 Z6 |& Rif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
1 n% O$ l- z; t5 ^0 u+ H}6 x! ?1 L- l; F2 c% r) _0 F- }4 ~! W
+ F. o; s# T% {
function sizeCycle(text,method,dis)9 L% c6 |, t. p! I& P! D: u* ~& N
{
, Y3 J4 h2 `1 U- Q3 t+ c5 ?- b* w        output = "";; X# M6 T9 D6 V/ Y: `+ A( Z6 u( w9 K" z
        for (i = 0; i < text.length; i++)3 X* Z7 Y. z% S$ G% S& J+ J  m
        {
: {4 i7 ^9 f2 R" G$ S4 v+ z! c                size = parseInt(nextSize(i +dis,method,text.length));
! B: K6 _, M# j9 q. J5 j                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";4 C& K+ S* C1 \! g0 T
        }1 P0 G8 f' f7 i2 {2 {
        theDiv.innerHTML = output;" O5 z2 |- P4 q
}2 _, u( M8 N- \% \$ q
0 S* }+ y6 L3 q2 N/ [
function doWave(n)
1 C$ a# ~! a: H$ x{   6 W( }# w# @( [6 p' M' G
        theText = "JavaScript";
1 m8 J; a; @0 W  z+ E        sizeCycle(theText,1,n);
2 d7 I, J. `5 M# T        if (n > theText.length) {n=0}+ r: X8 A5 C1 G, c2 P0 i
        setTimeout("doWave(" + (n+1) + ")", 50);
" y, C3 S) [7 S}
# ^7 u' ]8 l. S: C</script>; y0 U* m( N' l: b( @: v
<div ID="theDiv" align="center">
' X4 g# d( B2 y9 Q7 q( f- ]
  ^! t/ Y, k( _' N</div>: {7 }/ n" Y% @% Q
; {* ~0 [* y' Y+ F, V" E

9 z7 X6 C6 i7 t) g* M, Q  c- t: t3 K1 z( c' V

- y% r" Y. ?+ d: x; ~3 {第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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