标题:
网页之奇特的文字变化特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:50
标题:
网页之奇特的文字变化特效
脚本说明:
& _' Q3 h6 N; V' c/ F! z8 I
2 Z- l5 L) \! }' V4 h- A4 I
第一步:把如下代码加入<body>区域中
2 h l n, X+ [' f
<script language="JavaScript">
5 j4 a- k" [8 K2 E5 i
% k. D3 Y1 C2 a
function nextSize(i,incMethod,textLength)
/ Q% V6 y+ F& W! b
{
" g. Z u: `/ n3 [4 c) t! F. t
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
, v) Y6 g7 z, ?' q% D/ Q: r& R0 x; n
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
8 \: p0 C+ f, F
}
4 w1 V% X9 j' k+ U! U
- v% g% N- b$ m
function sizeCycle(text,method,dis)
8 l4 }' ~; P0 V7 B
{
$ L1 O* \, B' [+ f% U
output = "";
- X9 r e2 d' J; Y' }$ k3 a4 s0 K
for (i = 0; i < text.length; i++)
' f1 }8 h( i) R/ q! T3 l4 H) k
{
- H7 j: ]& ^' h9 Y
size = parseInt(nextSize(i +dis,method,text.length));
) k2 P V6 _4 Z; P K4 a$ Q# i& g# r
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
$ j+ m8 S' e) F3 t# `5 v7 V
}
5 E" T) `3 F7 T! Z
theDiv.innerHTML = output;
; Z; T0 [9 W- I3 s% b
}
: F- D E! v: Z. I! p
8 `% d7 \0 w+ D2 o4 z
function doWave(n)
7 E1 A9 _4 b5 W$ o4 g! k/ G) V. s
{
$ {$ r1 t! X% K
theText = "JavaScript";
, k) _- ~5 F" i, Z' z
sizeCycle(theText,1,n);
" P( d+ W z8 t& \% ?
if (n > theText.length) {n=0}
, H( V& O# ]* k: o3 ~* g
setTimeout("doWave(" + (n+1) + ")", 50);
2 Z% A" ~0 W& i& i6 K
}
8 A% k. a! [8 @/ @
</script>
$ f x/ R% a! u$ Y
<div ID="theDiv" align="center">
3 b) T* B5 y0 K" o* A' p# J9 j2 w
' I; V! X/ t8 ], f$ G5 m% e+ `
</div>
{9 H m3 U' d; x- ?
9 k& n: J# q- _
: ^0 \) Q7 X. `$ M
7 G* {+ j- j( X( `$ w: x9 ?
, Y( a6 {2 a& K' O$ }
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2