获得本站免费赞助空间请点这里
返回列表 发帖

网页之奇特的文字变化特效

脚本说明:
% p& V, k* I- e2 W% n* T+ B2 R! n % g) A& a0 X3 V3 o- S8 _$ k4 L
第一步:把如下代码加入<body>区域中
6 Z  r3 C) ^( t' M <script language="JavaScript">5 \2 B' e# U: }4 N" a' e2 ?2 D

/ v  c- g2 g# r% S2 Y7 L, u) Yfunction nextSize(i,incMethod,textLength)/ S* ]7 W9 V( p/ Z
{, g# O9 b9 r* k* s, t
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );/ d* W0 Y/ y) ^, [0 D1 S
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
7 o5 E& u: G& ?9 }- ]* x}3 }* C" j3 Q6 a# r* P) t8 N7 |4 s1 G
: T2 g) `* w2 k: d! [! S: I8 s# v) {/ ]- k
function sizeCycle(text,method,dis)
5 Y1 Y6 L2 d4 B# X{2 i3 E! V6 V; y$ H1 n, B$ R
        output = "";8 Z' X, |/ M4 T4 @2 B$ ~
        for (i = 0; i < text.length; i++)
' n. L" n; T6 P: Q        {
5 T: x" F/ \2 o' b6 E                size = parseInt(nextSize(i +dis,method,text.length));
2 @* Q8 V4 b3 ]                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
2 S% l% r3 E* w0 G- w        }
' Q: b6 a& A3 S& X        theDiv.innerHTML = output;
! P% Z* f" ]0 ?8 s; w+ b}
& Z, l8 }: f0 b
2 m0 B2 \- @- Z8 Jfunction doWave(n) 3 B8 d  d; o- \& f, S
{   
  y/ m& r/ A+ N4 r! @+ ~% p" v( e        theText = "JavaScript";7 d3 N; a' N- r5 N" A
        sizeCycle(theText,1,n);
; F( R5 X* N) r# V8 s+ v        if (n > theText.length) {n=0}' D0 m. O; f- Y6 |& r
        setTimeout("doWave(" + (n+1) + ")", 50);
8 M. [. _1 g9 n( J2 @}; B3 i; Z6 w' P  N
</script>9 O, f0 H: y) E% y0 P6 |6 c- l# J4 B
<div ID="theDiv" align="center">
- X! j5 x) r1 B6 |
4 }/ a1 T. [6 x( W; _2 R</div>
) o* L# ?* q! v* B2 L2 }" M0 `# S9 |7 Z0 a

% I* ]% q1 s& Z3 J  A
# P$ [2 B; ]' F2 O1 }( N4 [( z- t , [; n* }4 o  Z
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

返回列表
【捌玖网络】已经运行: