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

|
网页之奇特的文字变化特效
脚本说明:
& t. [+ c. j/ s, X+ U, X! g
j1 g5 ]0 O# q& v: @* }第一步:把如下代码加入<body>区域中/ j* V7 w) B v+ ~3 X4 j
<script language="JavaScript"># q% I# `& c4 Q7 e6 |
$ s2 h; d6 L# K& z+ V( `& @
function nextSize(i,incMethod,textLength)
6 C5 ~6 X2 n$ T, }7 q8 m, I{# E, g' g" r! o+ S$ r" r5 ~2 q
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
6 _# i) d2 V) P5 Z+ wif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));# ` d7 f. p4 Y8 A7 |; d' t+ U
}
" ]+ i/ P' v1 ]7 a) `/ ~1 C/ D- Z+ t
function sizeCycle(text,method,dis)6 P* d$ I! [4 H- P
{
. W# u( g- o1 w output = "";& J/ t* n" l8 g4 l+ G) U0 a, d& |
for (i = 0; i < text.length; i++)1 A7 Z( Z% z* l
{
/ {; s: N0 Z/ \& C+ \ size = parseInt(nextSize(i +dis,method,text.length));9 K! H1 G* t4 f$ Y
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
' ?: K- H: J) z }. {/ R4 t+ g, w# m' s' a1 s) G' s
theDiv.innerHTML = output;
, S- \0 E9 V- x, J( d8 b}
, v" ^8 p) O( V* n. t
% [8 o6 {4 X! R$ I4 \+ n ]function doWave(n) 9 Q z5 `' S$ } J( z M- ^
{ + V: a0 e/ {# g. C7 z! u; L( [5 f) z: u4 J) T
theText = "JavaScript";. _3 ?7 G1 i. g! K$ L# g
sizeCycle(theText,1,n);) {( ?% Q7 _$ n5 \
if (n > theText.length) {n=0}& P0 L* d6 Z# `! n) M
setTimeout("doWave(" + (n+1) + ")", 50);6 ^+ B, r" ? |/ b7 Z
}: v) H( S3 N$ u) H9 K' N
</script>
: ?/ v1 g: }' P" W2 V<div ID="theDiv" align="center">, _+ U. P4 `# N9 z5 t
7 S! z( |( g' N+ Y
</div>
' R1 r, l) x! T3 R4 D: ]
$ y! \5 M" b9 O; ~# b- U
5 F' w, f/ @* e) ^8 V" O! |
8 L! [+ N4 m' F : _" E9 ]! B7 R$ ]" @
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|