返回列表 发帖

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

脚本说明: 3 ]5 U0 X) U& _
/ _) i# _9 V% g% p3 h; t9 T& P
第一步:把如下代码加入<body>区域中  p* j% J. L" b/ G, U" [2 p( V
<script language="JavaScript">7 h) E5 h6 z8 ^$ ^) b
% t5 D: A6 M. n( Y/ z/ ]
function nextSize(i,incMethod,textLength)
# P% g1 A  D3 v8 x* G6 J{
$ B# [8 g5 e+ H8 r% l) lif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
. Z: e: K+ P+ K( N+ Gif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));& ?' A9 o: L3 d& t- u6 m
}/ J5 p- H( n( F. a6 ?& S
9 C% }; D9 F' x: Z
function sizeCycle(text,method,dis)7 u- n' k4 e0 c
{/ w1 t0 ~+ H8 J& I9 L
        output = "";* b6 Z  j, z! w4 b6 n- y3 N
        for (i = 0; i < text.length; i++)7 s. c7 \7 s9 Z0 O$ B
        {
' r8 O+ Y( Z& |4 p' Z" g                size = parseInt(nextSize(i +dis,method,text.length));
" K9 s- B* Q# ?( K& [( w                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";7 i1 s1 J! w% R
        }, }) [6 q# ?8 V9 v( }. A* e
        theDiv.innerHTML = output;" b. _, M, l# j( S7 O
}
: n3 @9 C4 i; x( \2 n! l
5 n& J8 P0 _. c2 f- t' V0 wfunction doWave(n)
8 R" ^) t$ A' f5 k, c{   6 Q" J( [/ y3 S- \6 r% ]! E6 f
        theText = "JavaScript";9 g6 x" F, V/ e+ n% k
        sizeCycle(theText,1,n);
/ q% Q$ H. y2 U& P% ^* c$ R; v        if (n > theText.length) {n=0}
4 h, D. |4 q  v+ c1 c1 `        setTimeout("doWave(" + (n+1) + ")", 50);6 u- O. T2 J4 \& D* F
}9 B5 L6 Z' O6 B! R8 D, ]: Q0 y: a4 d
</script>- ^; M! B' f4 z$ Y% P/ N0 A. e
<div ID="theDiv" align="center">
, S8 ?( N+ F, I$ t
0 U' D; F: P6 J! V1 h* a3 E/ g</div>4 u( x; U& z  I1 T
  {- B/ v' y% D; ~' u" R; X) F

6 n* p" s/ [- ?9 x$ X
6 Z/ j8 c( b8 z) m2 J4 U ; u9 h0 h3 E$ I8 P0 W
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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