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

|
网页之奇特的文字变化特效
脚本说明:
; E: Z0 A& d4 M' \/ m 8 a1 [3 d& ]. w0 d- ~
第一步:把如下代码加入<body>区域中& ~( n0 M" m: |4 U
<script language="JavaScript">
% r9 w9 X. g8 q5 U- K$ g7 ?/ x
) X% K6 G5 i0 I* mfunction nextSize(i,incMethod,textLength)
: v7 H# i1 E r8 M ^2 T3 y! y{
% k i! B$ l! M/ S) Qif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );/ u. f7 ]& |' b8 h
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
- o4 @! b" p' f& ]+ F4 Q}
Q. S4 U4 X; h* U* k
( B% B8 j W8 u/ @$ g2 M( M6 g3 wfunction sizeCycle(text,method,dis): W! U# U0 d3 f( K- p
{/ {. N) p1 w& f2 w2 t! ?
output = "";
% v6 S8 H1 N5 o+ e/ R$ v for (i = 0; i < text.length; i++)
3 q; e* J9 d* T/ e/ R8 U% x- t6 _ {9 q( X4 {; M$ H3 F# q2 z& v$ E
size = parseInt(nextSize(i +dis,method,text.length));: }) f+ [( R" F0 b& W8 Z; O* E
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
I+ N0 L& v7 d5 n }
; l/ l4 V$ B( e* \+ } theDiv.innerHTML = output;
7 {2 e: D, z4 |}& L4 ?+ C5 {. A7 e9 y* c
% y3 z0 e" e- E" p, q, k' q
function doWave(n)
& o: d' `! f1 n/ i+ j{
8 ~& n5 o l( b# f theText = "JavaScript";7 S. ]# l/ l* y& c
sizeCycle(theText,1,n);) m) x R6 g2 r F
if (n > theText.length) {n=0}& ~3 a" i2 D( M7 G! W
setTimeout("doWave(" + (n+1) + ")", 50);
# }* L' S! p6 m/ P4 f; R" W}4 f( O/ h6 a8 \% `4 ^0 V; u* s/ b
</script>1 F1 Y7 D2 t( X6 @
<div ID="theDiv" align="center">
& T4 ^2 y: `5 @9 C7 e- F+ |
( H# X' `9 P/ L2 c</div>
- J0 V% Q r4 v; A; x& G$ E2 s
& R7 m. {1 M, S
: a" @5 a' V! X8 h, x
1 c/ f% G3 N' k" ^5 B. \
3 R2 ~/ n. V. @# ]第二步:把如下代码加入<body>区域中<body onload=doWave(0);> |
|