获得本站免费赞助空间请点这里
返回列表 发帖

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

脚本说明: 3 n3 Y* v4 V2 i7 r; r

, S) l) S2 l4 ^: ]! k) s' O% u第一步:把如下代码加入<body>区域中
' t& Y3 s. M7 W! U1 ~1 Y <script language="JavaScript">" ~$ c' D( ~7 P, O
0 d$ \4 j# B1 |/ h4 H$ ?. ~
function nextSize(i,incMethod,textLength)
! J* a5 R) |  ~$ u{
0 P& e( B! m( b/ Hif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );* ~4 V! n; j: }
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
' `9 O4 b6 j9 i8 t}0 q8 P* I/ ^5 u2 }8 Y) K

" F7 O" t- W0 F4 }6 o+ R. Hfunction sizeCycle(text,method,dis)2 B" A( H$ V+ l6 r, a/ l
{$ v! n* ~2 B/ Q. ]* Y
        output = "";! u) V8 Y$ a0 O! B5 X3 _
        for (i = 0; i < text.length; i++)
5 M* v5 K& U1 r$ ^; @; s        {
# m$ y2 c7 d7 |                size = parseInt(nextSize(i +dis,method,text.length));) G( f  w& I* z+ P; w
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
( p, G6 ?$ i, Q! v* E        }- Q& U+ i" ]4 I# j
        theDiv.innerHTML = output;" {$ Q3 f7 b5 C
}  {. r" B0 V1 v$ q. w* |
8 l. K2 a  D" t5 M+ i1 Q
function doWave(n)
: l, n% L5 `; ^. S) c{   
! J: Q3 e1 U! L: J; J  x% V" [        theText = "JavaScript";' Z# h, ^. \6 `; H6 D/ j5 b
        sizeCycle(theText,1,n);' @7 M# W& f7 Q4 ~( h/ n
        if (n > theText.length) {n=0}3 F7 L' {( i  E. g# S( T
        setTimeout("doWave(" + (n+1) + ")", 50);
6 W9 ^4 `1 B* m3 b4 x}! w  z: W) C! F2 e
</script>
8 s, P, x, j( J, M( M<div ID="theDiv" align="center">
( s1 x$ ^4 ~8 W1 u4 d5 b
, O' p  L7 e, h0 i& W</div>
, b. b* i, s: @0 d& k# b/ n1 X+ U% y  j& I
5 B4 Y9 O$ g' \! `5 {! K* ~' }

5 N8 r3 o' P0 i- f . `% L" c" _5 j4 c
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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