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

|
网页之奇特的文字变化特效
脚本说明: 0 F2 \2 n4 l) c7 o5 R
* n; z, h U4 }% U
第一步:把如下代码加入<body>区域中
6 c5 Z0 j) Q5 {- M, n <script language="JavaScript">0 z2 u+ ?2 a# I- J x [1 w- \
5 o% U& U* [! ~) w! ^4 P& p
function nextSize(i,incMethod,textLength)3 D4 ~; c: J! V- S+ D6 H5 c
{
) B0 V: `: I% U, N, G& T' Qif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );, `/ @& X' o! d& R0 ^1 M, }
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));& h: e# u, M! [5 @
}# N, g: V: t& @. I
1 i2 C0 l( R' Ffunction sizeCycle(text,method,dis)! ]! Q j$ m* h4 E4 Z; d# S1 I! O
{, R( T3 \; t: S9 G% d
output = "";. ]" o9 K2 x* b
for (i = 0; i < text.length; i++)& Z( t: L6 n6 O. o: l0 V& S
{: Y4 d3 b0 a% z7 Z) l, m
size = parseInt(nextSize(i +dis,method,text.length));! j* |# B' ~& p8 N
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
$ ?: o% o- j( w+ G I/ O4 m: ` }
" M# K# a3 |; m" u2 X+ s0 X, N theDiv.innerHTML = output;9 t& I+ C5 `" D$ y# P% Z3 ^" X
}
C1 H6 @% Z7 u9 N3 ?. B, M0 {
" U' W9 g+ K% p, [$ g/ X! gfunction doWave(n) # }2 Y, P6 K+ Q# S" ^: H; w
{ 4 M0 @4 @: P. x' L" Z7 V
theText = "JavaScript";+ I# ~7 D- t- [
sizeCycle(theText,1,n);
8 M2 Z4 _" f4 u* @: G* x* J6 m if (n > theText.length) {n=0}/ d3 T: x! D; S2 X
setTimeout("doWave(" + (n+1) + ")", 50);" \$ Y$ n; d6 B2 H
}5 N, e7 r* c, p. j
</script>
+ B0 d* {' j' \* ~' y6 w<div ID="theDiv" align="center">) Z8 `% U+ p* c0 A
- ]( \5 \2 l- y& b5 J$ P4 b</div>! n& _. S3 q' T+ @8 b3 s q
( |; W* V: \& E& Z" d6 b- s& v
0 c6 ]% A3 _; Y' ^7 m, K
4 Z! W7 J& W; l
5 z+ c u) g5 H4 d第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|