Board logo

标题: 网页之奇特的文字变化特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:50     标题: 网页之奇特的文字变化特效

脚本说明:
) F  e& K. I" t0 Q! F 7 N0 L! C$ V  c4 D; M- `9 S
第一步:把如下代码加入<body>区域中9 N3 g& h* O5 j5 U7 z! t
<script language="JavaScript">2 K. R  W1 i; g7 I1 r

9 j# e$ O7 B  v3 a  V# z" R( Bfunction nextSize(i,incMethod,textLength): u  f! W0 H  Z7 }
{  r/ p0 a( L7 V- {
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
0 J0 m4 k) S; Z) v/ W1 @; Nif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
( c- b$ _, k! B5 |1 ~}
3 N  t  i1 C+ s! L
. h' ^5 M* G# Dfunction sizeCycle(text,method,dis)
5 J4 h3 [- N7 Z/ @: z{* X; r1 R. d6 j' J) H: u5 J% W
        output = "";
/ `4 B4 a! J% f7 i" T' E9 b        for (i = 0; i < text.length; i++)1 Z* a. |; ^1 ?$ I
        {" g9 Q9 ^  A) t- W+ P
                size = parseInt(nextSize(i +dis,method,text.length));. F9 M7 \) X9 e! ?* _+ \  x1 X
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";9 f' e1 M9 ~6 a! r/ {2 ^6 S$ R: V
        }
+ v; L7 f# {2 D# y8 Y9 n; x3 ?        theDiv.innerHTML = output;
8 G2 w8 T3 d/ |0 L. ~1 t}) ~/ z3 H/ }4 f# _# |, i

- D8 i% x7 u' B0 R4 z! wfunction doWave(n) 3 w8 a; R9 r7 N' y1 _( @
{   
6 q* p2 |+ a  h! a        theText = "JavaScript";
) [% R8 S/ d9 v4 ]/ V        sizeCycle(theText,1,n);
8 t- g0 j# H) U" O/ O        if (n > theText.length) {n=0}
5 Z( g% ^& s+ F2 {: }        setTimeout("doWave(" + (n+1) + ")", 50);
9 b8 k" ^; f! p( B9 P: a. @}
1 ^& h$ L9 c6 Q" i1 T  _5 E$ c3 C0 a</script>
" e3 T: u- p! f* S. y<div ID="theDiv" align="center">
5 R7 @' p+ [% r" r( z1 B) ?. J; F1 E5 r8 V
</div>
* P  W  W' @. G/ Q1 U9 _) S% U' g( ?" q
: f$ y$ R) G) R0 B
' e  B& h% e. t. b! a; k# b  \5 _
9 t, h/ J( X, l+ U' Z
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>




欢迎光临 捌玖网络工作室 (http://www.89w.org/) Powered by Discuz! 7.2