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

|
网页之奇特的文字变化特效
脚本说明: 2 C& o# @/ n" l$ P# W; h
( M+ Y* d, Y; {2 q5 {
第一步:把如下代码加入<body>区域中
5 K) u: i8 a$ H% @ I# ?% m <script language="JavaScript">
' u6 e7 [( g: B: D' ~) C2 Z
/ _0 I& h- @4 ^function nextSize(i,incMethod,textLength)
0 z+ S' n& k/ z6 G" k{
8 n5 a* U5 X* Z P. n( Rif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );3 V- I1 S. f6 a2 K
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
* O! T" S; i' e5 F- k7 h}) m! S! P. @6 R6 o: q6 n
0 |% C. X/ p- @4 R! t
function sizeCycle(text,method,dis)
1 f+ i: f# X6 @" q{
6 O% J3 `' ^3 i3 ] output = "";
; x7 q4 r9 ]! ?. b! e for (i = 0; i < text.length; i++)* V. S( m2 Y# ^4 N' `$ N* S5 b
{. z" t# Q# G3 F, [+ H, X& y
size = parseInt(nextSize(i +dis,method,text.length));7 I- @* r- u8 ?* I9 r4 S
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
3 i" H: [% r; c5 \5 l }0 B" A4 K4 L( o) k8 ? t$ S
theDiv.innerHTML = output;' X, g! ?8 i0 {" P8 U4 d' Y7 ?
}3 x3 b( E( T& M& i" ^7 e! B* T1 \, S
0 s5 V: u# V- `3 _0 a' A6 v' f
function doWave(n) 4 R% z O( X& X9 A4 j; [" |7 e, \
{ 3 o+ `. G" B$ v) E8 e. o5 p
theText = "JavaScript";
7 s1 v% \4 o+ t$ J1 D! W0 e sizeCycle(theText,1,n);3 q+ ?2 `% `0 H+ c* p5 ?
if (n > theText.length) {n=0}, o b j: c4 s
setTimeout("doWave(" + (n+1) + ")", 50);
7 F3 o& {3 V8 s k' \6 v. G}3 X, [5 A7 r2 V9 L0 ~
</script>
& o3 x- z1 C$ l0 R<div ID="theDiv" align="center">
6 G9 P- O8 R/ J; v! s+ k# Z' w3 G. L
+ m! f, Z+ O$ J! B</div>
9 c! U( x0 L h. a9 B1 M5 q
4 u+ R5 K s1 \0 g; m5 Z- z& d. p/ m5 T
2 ]* Q9 E' E& f2 O; f
- l$ G" m3 Y9 w& m
第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|