返回列表 发帖

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

脚本说明:
. Z0 [& i6 b! G6 ]! _ 5 r  |6 g5 w) U5 J) a' b
第一步:把如下代码加入<body>区域中
, U- b4 t# z; i, B! u6 p# i <script language="JavaScript">
; |* L3 G6 @, \9 p  z4 d3 t: t5 Y7 b+ S7 L
function nextSize(i,incMethod,textLength)! K, ]6 H$ i- A& r5 d# k
{' ^- h9 F- x2 ?( |3 W
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
6 ]+ B1 j/ {, T0 J3 Aif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));' t4 n! f: A* Z; N2 l
}! Q' ~9 H" y' v, D; C% u5 m% h

  S' h0 K# Y$ Q. b  x( sfunction sizeCycle(text,method,dis); r% H) J9 s/ @  i5 l. H& _
{
. e+ F# Z% j: @' G$ h" A        output = "";& O' E+ \/ ]# n9 ]
        for (i = 0; i < text.length; i++)
- O( P% X& j4 |. |& E/ k+ a        {
8 q# i+ ~/ g- ?# _, w9 K: I" N+ u                size = parseInt(nextSize(i +dis,method,text.length));" q' D, g: }2 q5 `* \6 g6 U! _3 f
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
* G. r. a% Q) z" h& C9 _  `# B        }# |) }1 I+ a1 ^) ]2 T
        theDiv.innerHTML = output;
' S- c7 W" U0 M- v# s2 B- c& C}0 f9 a. t) p) n# U1 M( j

4 y+ a. c" H% }6 Z1 dfunction doWave(n) & |& f+ o8 j9 ?. G8 f1 e
{   
* W9 b$ O* w  J% r+ H! h8 y' z        theText = "JavaScript";
* t7 Z+ c) z1 U% l  H        sizeCycle(theText,1,n);4 }$ t& u- X4 d& N
        if (n > theText.length) {n=0}
& X1 g; f' V$ `7 Z+ h. P3 ]7 d# k  c: _        setTimeout("doWave(" + (n+1) + ")", 50);
1 n" X3 D4 U3 {: d4 N}- _4 h. G+ B- j$ t* c' x: L
</script>
9 L% u! N3 v7 P<div ID="theDiv" align="center">
% Z* _7 B! j! b! g: l4 g$ I0 N: L. G( z( C) G' q
</div>
- p9 B' A4 n5 R. r1 T$ a
) c3 k: U& M! q3 b) T. d8 }
% y, _! l* f3 E" N' ~. p/ r' d3 Y: m& j
2 m6 |3 l" G" K+ A# R
0 ~# u  [" s% A- P0 @2 v, N第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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