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

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

脚本说明: & B7 Y/ T9 V, m- w3 S

) x5 x, v7 n  H" S. Z第一步:把如下代码加入<body>区域中2 X/ I( o) P8 Q) i8 P# R: B+ C) U
<script language="JavaScript">  R! {' l# i9 U+ S* p" y

" I, \9 V% C: lfunction nextSize(i,incMethod,textLength); C0 Y' U3 h9 x- ~  S9 ~
{
2 _' @+ @) j6 s- v* W! eif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );* U6 n! f' v4 K4 ~* v
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));9 O, J$ g8 o- p9 I4 U5 E
}
6 }' ?1 y' P( O9 ~5 W' o. e, J" `3 d* P/ P: c; w+ M" l# C6 @
function sizeCycle(text,method,dis)- i" r% X2 t( Y& j5 C# g3 r* q. G5 r: V
{
: b7 j0 R1 \2 e4 a% B5 R        output = "";
& W$ L! l) x- n1 A8 F        for (i = 0; i < text.length; i++)( ~, H; z# c* U/ N/ F
        {: [2 p9 @7 K$ u( j
                size = parseInt(nextSize(i +dis,method,text.length));- v9 g! t) Z7 Q! ^) U2 Q6 a  P8 y% n
                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
- i6 f6 M& t! n5 P- y; t        }# _' ]* ?+ @; q9 X. J- U* M
        theDiv.innerHTML = output;
( e6 i8 R# `* `( n0 I! x, e; Q}1 E1 H5 x4 M! E5 A4 \8 S- ~/ s

7 R; z/ P- ~) ]function doWave(n) # p. C& {' K% W
{   ) ^2 {2 p) {; g# q' R( {! y
        theText = "JavaScript";
8 p9 p* g* ~3 }2 p$ z        sizeCycle(theText,1,n);
- l  ^+ R7 Q1 e+ L+ m7 z9 @) b% g        if (n > theText.length) {n=0}7 _/ d8 F' }* X' \9 O
        setTimeout("doWave(" + (n+1) + ")", 50);
' m5 j; w  e5 I3 G}
0 s  O$ L# v4 D0 x1 u. E</script>& v5 x1 S; R8 o9 B9 k0 d
<div ID="theDiv" align="center">7 g: K1 Z- a$ C, i2 d: k: `

& G4 r& P. |  I7 l! G</div>& D+ i6 S1 U$ |* ?0 T2 v( H

) B5 E7 o4 A8 F, q/ c% y
2 R2 E/ v; i5 [) M+ I1 T, Z+ m! W% `

& D! j% J4 \, {: N/ g. ~9 q第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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