标题:
网页之奇特的文字变化特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:50
标题:
网页之奇特的文字变化特效
脚本说明:
9 `0 S0 f/ A8 l1 e8 l1 G# ?" `
& H7 ?% p, v2 W9 I6 n
第一步:把如下代码加入<body>区域中
D$ i) g3 n, O" b% L
<script language="JavaScript">
, Z, t" A: g3 F. u( ?( m0 }
" V& L2 c) X2 F% K
function nextSize(i,incMethod,textLength)
' _: g* U P: [% K+ @7 E0 h% X
{
7 ^1 i& _1 i) R
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
; k! }0 Q4 n Q; m: g
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
# q7 ^! { P$ G; v
}
9 A0 H) t/ a: f7 b( M$ T( U- w
( e: Q# H2 Y# I4 V8 b
function sizeCycle(text,method,dis)
& s$ l6 _7 l- R; b6 n2 s5 G! G
{
5 K' p6 G. H' `* K
output = "";
/ g+ ~+ r& _7 U$ F
for (i = 0; i < text.length; i++)
" ]0 i3 z; i6 M, r
{
7 n% D! _; @) d" O
size = parseInt(nextSize(i +dis,method,text.length));
% ~3 T; N- z4 Y t0 b
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
& z/ }/ H& b' b$ H! L
}
2 E) r$ k9 i/ G2 C) P
theDiv.innerHTML = output;
' P+ P/ h! a+ [2 Q
}
, t% v! ?' H# S5 D% |! w/ h6 E
$ L4 v3 v9 M9 F; I
function doWave(n)
# b& n+ i# n, \! O# V
{
0 S' Q' A$ B/ v3 M8 t
theText = "JavaScript";
8 W: v0 Z# B% f. t" H
sizeCycle(theText,1,n);
" M" K/ ?# e2 i" ^
if (n > theText.length) {n=0}
+ d$ d M- d& W5 {
setTimeout("doWave(" + (n+1) + ")", 50);
1 K! }5 `1 g' n! T8 P9 d4 Y" h* L1 _
}
# |) V/ H) _3 T& v
</script>
* U+ `' @& n& B6 [
<div ID="theDiv" align="center">
6 ` o1 H8 p$ c( q$ ]
) b$ z: ~ `8 _7 P
</div>
3 T. |; N5 N2 _7 y7 Y9 @5 Q
/ F& o: l1 O3 K
- K; ~$ G( Q& h# X- v5 O
, }5 I0 z4 ~# f
. \: }: M1 C5 q0 E4 ~5 r; L
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2