Board logo

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

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

脚本说明:
, {4 S" C2 W" D! [* R6 S; Y. S 0 V# _& Y1 D1 m. o# B3 Q8 t
第一步:把如下代码加入<body>区域中$ [6 w8 L' |' ^- [& z
<script language="JavaScript">0 f$ |* L6 i5 \- \+ n  s  s

" u  L+ k, j$ u" x" ?function nextSize(i,incMethod,textLength). R; a2 O- Y/ S( ]/ ^
{9 b: {5 Z. B& F1 F2 _1 ?2 X
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );( j8 _9 Y- f( {; k* l. b( l8 l
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));: q1 f: y( {. B6 L! m. q* D
}
+ y) N" n" \$ S0 i0 G% |4 a3 t8 _! |. T7 J4 i/ F/ Z. i
function sizeCycle(text,method,dis)4 G, K+ x! |( G* {6 P
{2 y2 ], A( _. a! j) u" z
        output = "";. w7 a3 L% L2 B/ b
        for (i = 0; i < text.length; i++)
: B! z" |8 \) Q1 s0 m" P9 P$ v        {
; C: X* }3 T$ q# `# l, ~! t                size = parseInt(nextSize(i +dis,method,text.length));
+ B5 ?/ K2 X: t# X* K                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
# o; p" J. m+ e        }% }/ E/ y( v3 X$ H3 Z2 L1 X
        theDiv.innerHTML = output;
; k9 C+ o0 W: Z8 D}" T7 f7 W% A# o
% }# M: o' {* x% O% s
function doWave(n) 9 \( r' ~6 [- I4 a
{   
4 R  {2 n! Y5 G' ?5 L- G; j        theText = "JavaScript";
$ U0 u, A; ~" _7 q' q; w' p        sizeCycle(theText,1,n);3 L0 d( \- C2 y1 n' O' f# y
        if (n > theText.length) {n=0}  z! s( L8 h" c% a+ O- n- a: u
        setTimeout("doWave(" + (n+1) + ")", 50);
( Q, f4 ?5 [6 z" l' ?) {0 i9 k8 u}
3 o: b) A6 R9 _5 }! y4 q8 F</script>
3 X! ?4 ~  A# E1 v8 p) ?5 }<div ID="theDiv" align="center">
7 q, n+ v8 M+ L8 h9 ^; H: n. q- w$ Q& v# w. [
</div>
7 c8 h6 {$ x+ y. H& E
  p. O2 G. {* {+ f) ]9 S; b2 O' k" M9 w
: n9 G) y* x. G' J

8 _9 i! e  {7 G; X  v0 i& W第二步:把如下代码加入<body>区域中<body onload=doWave(0);>




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