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

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

脚本说明: 0 J$ W( U+ @/ i+ }* T, U  I% g3 Z9 S

7 D& I; f! i9 y第一步:把如下代码加入<body>区域中
. B" I! H4 S) b( v7 V <script language="JavaScript">
5 a9 j0 g. i5 j4 v9 a
" x8 M* [0 `- n% ufunction nextSize(i,incMethod,textLength)
  N' p, W  R5 C& C+ e6 a{
6 X: U' ?# U# a  F: rif (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
  B/ I) E( m8 X0 X" Gif (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));1 f5 b3 I1 a$ t+ @( E( r# Q
}5 w; v- O# E4 ]) g

5 ~% u) F5 @+ _4 ?function sizeCycle(text,method,dis)3 S; p' q" P, H1 v$ O0 @/ m
{
  V) G; c' C* ^% a. x8 L# L+ t        output = "";
4 n$ t; u, V; |        for (i = 0; i < text.length; i++)
: b; F& o8 u) m& @' O        {
% }; k8 I( s' n  y& X                size = parseInt(nextSize(i +dis,method,text.length));
( w7 o  l, A2 k3 R  v                output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";. H: ]1 t" I5 e5 y: q  t
        }: e# g3 @2 @" S& s8 g' p! t. g
        theDiv.innerHTML = output;
  _, j3 P+ r  s% i+ H1 p8 o( ]2 N- M}
# y# h% s8 F4 ?2 c& y  Z1 {# i4 F' |; V: L8 |* E/ ~
function doWave(n)
: B! U6 w9 C" T8 c) i  x1 C{   
6 a/ J0 j# W( n. p9 B! e/ X        theText = "JavaScript";2 O% m! {; x$ s/ O+ Q+ B# J) S2 h
        sizeCycle(theText,1,n);, L' L! n6 U3 a' J$ I
        if (n > theText.length) {n=0}  e; }4 v# S4 t0 S$ ]9 |
        setTimeout("doWave(" + (n+1) + ")", 50);
5 j( p' q& p+ {}% b& D6 v3 P( m7 i4 e8 Y  f
</script>
; P% V6 v) v- V' g: [- @% N5 o<div ID="theDiv" align="center">) j0 Z0 z( f2 g. [4 O7 c

; Y" V! [) m% B+ ?</div>
0 ~0 p2 g. n; Z) A3 i! x* E  k' N5 l
0 J( z1 r- m& a
  W5 l7 x4 h& c; ?8 L0 V) f& r0 _4 a
" Z* Z) S+ T# a
第二步:把如下代码加入<body>区域中<body onload=doWave(0);>

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