返回列表 发帖

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

脚本说明:
" Q0 c* ~! t8 j7 ~
2 l! J& I3 `; n. b  Y$ \) D第一步:把如下代码加入<body>区域中' D. O# n% l. A7 ?$ L6 n! ?5 T
<script language="JavaScript">
' V. @- w9 U* B$ C$ S, E$ w7 J) j
function nextSize(i,incMethod,textLength)& U1 P$ ]' c3 b( q
{. C' O# H/ \- S2 m* m8 D, h9 V5 s: m
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
, c8 ?- \6 ~- R& q9 }if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));$ o9 b& g. r. @! H. S( B; l
}
9 w& Q/ R0 k3 t" m7 N) U" d9 Y( ]1 g" v# ~/ ^4 l+ f
function sizeCycle(text,method,dis)
  }- U2 D2 G) g2 K6 l# s{- @8 @3 C3 I% P; x& u" g+ _5 ~
        output = "";& W: j6 d: u' U: p9 f7 c8 O
        for (i = 0; i < text.length; i++)2 S+ ]( o1 m( m2 c
        {
! P& ?  U6 O$ [0 W9 j7 y5 u; \                size = parseInt(nextSize(i +dis,method,text.length));
, W4 [0 V8 U; Q) |4 K; }: ]6 O! V                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
) `, q/ |# M' ^6 a# _        }
. Z$ g5 g& e1 a& m" z        theDiv.innerHTML = output;% U+ |( @( q/ B7 w
}
3 v( t- a9 k* V& O: i0 M: r% e. M
( o' y) v# G+ U) [# ^* Afunction doWave(n)
- I3 C" {* n' m% O! t, h{   
: f% f: H; a4 u/ Q7 e        theText = "JavaScript";7 Z/ v5 i7 p+ {: q- m7 r% m
        sizeCycle(theText,1,n);
# B6 B" b# G1 n+ k5 P% j. w        if (n > theText.length) {n=0}/ S1 L3 b) ^4 p/ |9 o5 c: Q
        setTimeout("doWave(" + (n+1) + ")", 50);
1 q  Z5 h2 i2 u}2 m. v- o4 o( X6 m0 i% w2 |( s
</script>9 t- |" @7 T& A( C# @
<div ID="theDiv" align="center">
+ W: _. p0 p9 H# u- y) s. ^( o' J0 `
</div>
  J# v3 K3 Z+ S% Q4 U6 F" r6 }( R% G, K" `, C9 q. @- h

( j- \1 a  ^( |4 |/ m% a
* a5 {" k0 E( {- U& v! w" |/ J / m; P; t' N  {+ k3 D# {
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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