|
  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之奇特的文字变化特效
脚本说明: # D" I9 K9 y* \, y
, r3 {" ~7 J7 n$ V! e
第一步:把如下代码加入<body>区域中
( H8 I$ |+ {) k0 `8 e* J <script language="JavaScript">
8 N* K( P# E: I) [$ n
/ F& F4 }! j. ~1 z! Afunction nextSize(i,incMethod,textLength), h5 X1 ^& w$ E8 n. Q# V$ f
{
# B% a9 Z: l7 N* O& h: iif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );) B( u; h7 } A9 X1 m( K% f
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
1 R \8 u" J/ }. v2 k& j; Y}
# A& m; N/ s2 B9 C/ b v8 c4 z3 I. @6 ~+ P! B3 G/ q3 d
function sizeCycle(text,method,dis); n) a) _3 H/ U/ K+ Y
{- D R3 N: {4 Y2 h( V- n/ Q
output = "";
. p- b* b5 Y8 S; s1 E. ?3 w for (i = 0; i < text.length; i++)
3 f { c! x9 }/ n- M6 q {& ?8 J0 M1 ?% R6 } M0 W
size = parseInt(nextSize(i +dis,method,text.length));6 t/ @3 A$ U3 F& X0 U- l
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";# i: B& m6 U7 a6 O
}
& R+ S" u/ Z1 b$ y theDiv.innerHTML = output;! z3 w6 s1 v% X
}, t. {. O0 A/ V3 z9 s r
# x1 w5 W8 m# k" {
function doWave(n) ! Q! P% Z% ^) S( u8 m9 V% Z" {
{
5 v& r9 K4 [7 ^0 }% Y! I theText = "JavaScript";# Q2 K; p$ C( ^$ B% f9 d4 S" J
sizeCycle(theText,1,n);
3 |" ?/ c; U- a- a* A; j7 @ if (n > theText.length) {n=0}9 l, Z b' c# b% P8 W+ `
setTimeout("doWave(" + (n+1) + ")", 50);. X8 p6 S& G+ J& E- M
}
* R8 K3 G& R0 t( e</script>/ g# [2 h7 u9 I" x5 o
<div ID="theDiv" align="center">
, N! ]( y/ C" f1 l, _) t
7 K. u9 O& J( V8 Z</div>
, ~, P0 B* C: s( e, {6 _" S0 l# ?, f: t- H3 B
; B0 Y+ e: F% m v4 g. n" d& m- j7 U* o
3 Q( u4 w" t) {% v* N- W; m) U
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|