返回列表 发帖

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

脚本说明:
8 o+ a0 n$ z. l  h) i0 [. `
# b. @% m; |" r' O# [7 t( t第一步:把如下代码加入<body>区域中( j: Z5 u' i* b' u* E" P& B9 ]
<script language="JavaScript">  f# X; _) V. ~+ |+ Y
. \3 m5 S& U/ R( q, _1 g
function nextSize(i,incMethod,textLength)& H' R; x& c5 y
{2 [9 z. _, g( l  H7 v- |* o
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
: n' x: S3 ?1 B! N) D0 I4 Vif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
# F. Q# g9 |# Y}. c& J$ I, d9 B; g

/ F& B& t, B8 c/ v& Sfunction sizeCycle(text,method,dis)% ?4 |- n+ ]% T$ G! v% y" S
{
7 Y0 z. Z7 S9 ^# U, }- m        output = "";7 L2 P& M6 q3 t/ l; I$ V$ I
        for (i = 0; i < text.length; i++)8 k# @% V& d8 e! T
        {
9 R5 i6 g3 i! O# [) w7 i                size = parseInt(nextSize(i +dis,method,text.length));" {' z; `* Z% r# W" D1 d$ k
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
+ Q/ F4 c! Y* X/ E. O3 L+ @# @        }+ ^, t2 B; h& z% Q0 l. |# E& u+ M
        theDiv.innerHTML = output;2 b" ~7 @3 s8 }/ }& |8 u: ~
}  \+ o' [& _! f$ j& P

' L1 ^) H! }6 H4 [function doWave(n) 9 K. S0 l+ B, h7 G
{   
) V+ ?" t4 f& ^  S        theText = "JavaScript";
: ^. T& U* F1 ?3 G) ]7 {, Q7 c        sizeCycle(theText,1,n);# s. o( j0 d' d1 x( d
        if (n > theText.length) {n=0}
( S3 P" ]% k9 v' s9 @9 B        setTimeout("doWave(" + (n+1) + ")", 50);
. K3 z% J2 X: s% s( V% T9 E}
" I! [6 D# Q0 U</script>
8 A3 _# R) a/ B$ J<div ID="theDiv" align="center">
  q# c: R0 ^0 l. \3 ~" r. L$ h+ o8 V9 t) Y6 Q
</div>" d. @$ H6 v! i* A! `
! G+ V& E/ a( Q
2 j- s+ _. Y7 n! N4 o) W8 Z
! c0 `2 A' y# k: \
; l, z9 k5 p+ G
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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