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

|
网页之奇特的文字变化特效
脚本说明: $ O2 E4 V. R3 _ r* T% Q4 p
4 E& S, i# l4 b2 h c) L
第一步:把如下代码加入<body>区域中
" D1 h) V7 O$ i" e: X6 d5 ~# O- q& @ <script language="JavaScript">; t5 b& c G: }; y% }7 V, m" c
; y4 r7 N$ u. r! E
function nextSize(i,incMethod,textLength)
$ ?; ?- g8 |* p{
, M5 \# K3 x! [( hif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );; O, p) D) Y: m) d% X/ {2 |! D
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));( M- M+ D5 |- I2 C. r; L0 l
}
+ g/ J0 m- o' }% b6 O9 o; d* e+ L$ B% z3 ?& ~
function sizeCycle(text,method,dis)( o5 q) r2 m9 H V! d$ w6 U! H3 l
{" v2 }! W- ?' C+ u9 s, t
output = "";
( R' j$ {- s7 P; r. Q! X for (i = 0; i < text.length; i++)3 _1 ?5 ]. ]4 f, U: w0 q/ ?9 K
{6 O' T' W9 \; |0 b9 Z: n
size = parseInt(nextSize(i +dis,method,text.length));5 F% I+ l2 ]( O2 I
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";; V5 D! ` T' Q$ C! n
}
# y; m, p1 I! P theDiv.innerHTML = output;
: j, G8 t$ f' a+ x- n: \+ L9 z}- x" D6 @1 _1 F: Q- C% c, h" f. @ G* E
( ~% p7 O G1 d* } ^. S* m
function doWave(n) 1 T8 H$ S6 ~9 c/ u
{ 6 Q6 c/ T: U! p, X' `, S1 l
theText = "JavaScript";
1 K( l' P2 J" c sizeCycle(theText,1,n);2 A7 U/ c6 P1 r5 g; @, @/ P9 s
if (n > theText.length) {n=0} G0 C" r2 n h2 n) \
setTimeout("doWave(" + (n+1) + ")", 50);- D8 _7 ~& ]: f1 c3 W
}
7 N3 b1 U2 h; I( ^& L</script>
( {: t5 L- X1 S<div ID="theDiv" align="center">
2 @' P0 v8 x/ G$ u+ O8 @- W# R5 y3 }. r( B5 m8 i1 N9 V _
</div>3 S# e, W0 o1 Y# V0 `
8 T4 M7 d7 a6 E/ s% D3 i
9 e" A9 |" M- B d# e* ?6 E* w8 d- w7 W* b- X' T5 V9 i
( e* C$ h) G5 P) E
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|