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

|
网页之奇特的文字变化特效
脚本说明: 7 i: E- |1 a- Y7 j
# g* |* ^% a! U$ X, v0 Z7 O6 I& Q
第一步:把如下代码加入<body>区域中
3 ~$ P% G& V2 p, B% d+ ~ <script language="JavaScript">- ^6 }% X$ {1 j! t# W
$ p( P+ Z) m0 I4 M" Z, W' N
function nextSize(i,incMethod,textLength)' C* Q. O& X% h
{
! b3 [& J3 Z3 g$ Mif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );7 ]; X" u% H- _6 ]
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
% l, q5 e+ D2 B' W/ o}
. }) P& c! F) y. C5 S. l3 s* E: \
! o% O6 G! K, N# n) Y' _, _function sizeCycle(text,method,dis)
' ^7 S$ T+ `5 n7 x+ d% D2 g{8 q5 Z) E) C: p0 s) O/ N" U0 l) t
output = "";
" L, Z4 f: p4 e for (i = 0; i < text.length; i++)
0 ]+ K0 U, Y% b6 i' [# b* W {/ y; F6 o$ ^, p
size = parseInt(nextSize(i +dis,method,text.length));
7 X7 ]* N& g; u+ w8 J4 Y: x; F3 B B output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";" o3 @% h* L# c$ v. u1 S( z8 p
}1 r" W8 U+ a) J; Y! p9 C4 S- [) D
theDiv.innerHTML = output;
5 T0 l% J9 j( G}! l$ d, [1 D$ n1 u, d, G- ~
0 \" H. j- {( A' n: _8 H1 h( ~6 G
function doWave(n)
0 p. E' G, e, g9 ? r{
' {/ d! U( m* C, l" C# i* i4 P' N theText = "JavaScript";6 s% C. m5 n) @9 U, g# j4 |; f4 d
sizeCycle(theText,1,n);
9 z' J* R) D: m. c( E- N if (n > theText.length) {n=0}! ^; c* p, G. g, G' o- O6 h
setTimeout("doWave(" + (n+1) + ")", 50);
" M2 y' V; S4 U( c7 c, N}9 p. g% ?5 p5 Q) G5 s
</script>
& Q% r+ V4 x7 O9 ^<div ID="theDiv" align="center">7 {; I" {* @! {+ d
% X: }, E4 r \1 U% g
</div>, Y) t, I/ V5 B t
2 `9 y8 Y6 C7 E3 q+ w E0 S. [+ g! ]6 I0 J4 ~ v. t' W
6 r; Y7 R @0 Z5 M
* j$ x$ c. x4 O7 s1 U第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|