返回列表 发帖

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

脚本说明:
+ x6 m3 J7 d4 ?! v 0 Y1 b: N3 v  o
第一步:把如下代码加入<body>区域中
2 n9 B; x0 s; U' @2 \* ]% S( Q <script language="JavaScript">4 j! p" L  j/ f5 H1 Z

+ f& j: i) E' H$ B1 }2 mfunction nextSize(i,incMethod,textLength)% e# k5 f) n+ ?* p4 ^
{
) V3 R# d$ }1 G3 N: A; zif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );1 t5 h9 Q7 }6 s+ F, n. }8 z
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
7 W: F2 E" E, K; Q/ E2 G}
2 s* V; n, B+ Y/ j, L/ E8 f) ?1 [0 p. g
function sizeCycle(text,method,dis)
  V; ]. y- e4 }1 `+ [: M{
  u0 t; d  e2 k8 e        output = "";% K1 |/ I5 ?% g9 z7 f6 p5 _
        for (i = 0; i < text.length; i++)
( i6 @8 V/ q7 ~        {4 c: g: C6 ^9 P: Q
                size = parseInt(nextSize(i +dis,method,text.length));
" e* {* J& z9 J: P& }                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";! h4 p! l' |' ?# s6 R. @4 P. r' k
        }: e- Z: w+ s1 C) I5 z3 I6 z' [
        theDiv.innerHTML = output;
/ n. z; C9 h# m}
, Y8 A. g8 Q! o# B6 t
8 F2 F  [3 {$ R/ D! |% nfunction doWave(n)
* b! v7 k( D2 }: L, X1 D3 V{   
, G0 f; R) T7 w        theText = "JavaScript";
/ l- G: o3 S' U: X& O        sizeCycle(theText,1,n);. q' N5 I/ @7 t' K
        if (n > theText.length) {n=0}
2 b; K2 L8 O* ^, _) m        setTimeout("doWave(" + (n+1) + ")", 50);! T; K2 X8 j) s
}
2 o# m% J( ^+ L* A</script>+ H5 L6 L4 u& k4 e0 q
<div ID="theDiv" align="center">: S( ]8 y1 o7 ~" B: i( p
( r* j0 Y# P! h* g% s- ~9 s
</div>) d2 c. P8 C1 w9 _1 k

4 R9 l7 u9 K5 N; H* U* X$ t: I/ j+ G: A. p" d

1 U5 o+ n' ~9 ?# L3 P5 ?# K# w + H0 T( t5 D. K1 M' A
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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