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

|
网页之奇特的文字变化特效
脚本说明:
. a# E# x- z% j" L4 p% @ / _/ ~) @; m7 g
第一步:把如下代码加入<body>区域中
; [$ h7 ~/ U+ C <script language="JavaScript">) |% Y; A1 }2 }8 Q1 t
) d6 ~* a. T% u% A G
function nextSize(i,incMethod,textLength)( P' }3 @8 d* G: H
{7 q3 ]% d3 N4 y9 h
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) ); {9 q% \$ s$ l9 g! t" M
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
5 a' P" {4 c, w% [; o}
( ^# _9 ^ @: Y4 r( I
5 Y' h3 S/ J. u8 N! n6 Vfunction sizeCycle(text,method,dis)
4 o' {$ F7 [0 L{3 ?# I! O1 E, c4 m# X2 h, l
output = "";. Z d, F l; `& C8 B9 |. u0 p
for (i = 0; i < text.length; i++)' E* K& `" i% t; F% k
{
0 M0 K4 k" }% `/ } size = parseInt(nextSize(i +dis,method,text.length));
' u: \. X/ I( b4 \ output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";4 m1 O4 r0 Y" ^
}* Z, m. r3 ^4 I% w
theDiv.innerHTML = output;" r( b2 t; r( u% F6 F5 U* C
}
' p4 n5 j7 p, C2 m: R; ?: ?4 z" ?- o; j7 A
function doWave(n)
- z1 M* L6 {% v* _4 A- \: k{
( ^4 P. a) Q3 T* q( C/ X, g theText = "JavaScript";
" S& V+ ^" a/ D4 q( J4 H sizeCycle(theText,1,n);3 O5 u T9 ~3 k7 g1 ~- C
if (n > theText.length) {n=0}& h5 ^4 A" Z! o/ @
setTimeout("doWave(" + (n+1) + ")", 50);
# O! j$ D" A/ ^ y}( V, o1 B& b1 a8 F" d
</script>& g: n6 A4 K- z3 K4 W" H, T8 M
<div ID="theDiv" align="center">
' _, k: v' ?. g& r
* v- y9 Z& _4 q* g( @# S</div>5 r' Z4 Y6 B) a2 ]* o
# {' Y$ d1 d. P- D" k
3 i+ P, W: H9 i6 S& g
! e$ t3 Z# R6 c) B; M
' l0 ?/ S# Q3 b& w2 j第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|