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

|
网页之奇特的文字变化特效
脚本说明:
4 s" {, U2 [# u4 f: Y & b" _1 \8 r, R) J5 l
第一步:把如下代码加入<body>区域中: r9 w/ f8 M# Z0 D( ?
<script language="JavaScript">
& N ?" P( h& A) E* a K) t" J N7 t$ x
function nextSize(i,incMethod,textLength)
& {! X2 q" A' ~0 {3 s# C+ V{
2 } ^. t- U/ Rif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );2 z/ f5 }# G. t5 \
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));$ W8 e& m6 h2 X0 q
}0 {# d! Z; E& p
( D. T5 a. k0 K( b+ Q' k' D. ^, c
function sizeCycle(text,method,dis)
- k& N( M% M* ^{1 H4 H3 u" v/ a7 g) v# {6 h
output = "";
6 l" i G6 O) m; C for (i = 0; i < text.length; i++)) A3 v) @; c0 A6 E
{8 i: m( x, v: a' H1 L" }' ?9 H0 ?
size = parseInt(nextSize(i +dis,method,text.length));6 \% W# |6 I( u- B1 V- `3 F6 D
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
/ v% b; i, N" c7 E" l }7 E7 N2 [& }+ }& c0 W. c' X
theDiv.innerHTML = output;% K5 @- h, e+ L6 ^/ F1 V% t& \. Y
}
1 D+ S7 ^% w8 I1 V6 `2 ~, ~# o3 F- k& v9 h$ @# S2 {1 U
function doWave(n)
: ?4 v6 f! k* b{
9 ~, q/ O2 \( u- @ theText = "JavaScript";
4 @/ V* l: z. U: F sizeCycle(theText,1,n);
) v- {1 [9 | M( G if (n > theText.length) {n=0}* P9 y9 H0 ?2 ]) v, R
setTimeout("doWave(" + (n+1) + ")", 50);0 E( B8 ^8 k; I0 s' w
}
7 [* c7 \0 I# ?6 y. L</script>$ x1 `$ f8 B' a$ L& o0 {& C" i
<div ID="theDiv" align="center">
, t$ s( A7 e! O4 |. U1 F, E/ h/ Q. m+ ?% w$ P5 Z/ n
</div>
" n, P4 u: T2 o
3 N' X; J; V* U# r; X% x
% I7 J2 O G3 D( L
$ W" L8 O( g- \* H! D! g+ C : p) d+ t( v) C7 F1 f+ D
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|