返回列表 发帖

网页之文字的循环闪动特效

<script language="javascript" type="text/javascript">
9 j7 k: z9 j% h5 W2 {<!--0 w! S  b" D) y, F1 b/ k
// convert a single digit (0 - 16) into hex9 v9 c& J  l' T  L7 w
function enHex(aDigit)
. |" J5 A6 I1 c( T, n4 T% Y{9 d8 O+ F! }) b# {: Y2 \
    return("0123456789ABCDEF".substring(aDigit, aDigit+1))6 k* P3 J, e$ a8 `& x8 ~
}
+ R2 j& c: b  C( x* B: l( A% p9 j// convert a hex digit into decimal
, E# i# C- B% V4 j. O! vfunction deHex(aDigit)
0 w) z* z; S- r8 i% O" Q, P( G" o, q) l{" [4 r# D" `* w7 V6 p* L+ {* \
    return("0123456789ABCDEF".indexOf(aDigit))- h. x: V& H( x& c* w5 M
}
7 O" x( [  f9 ~+ N( q
/ Q. U4 d9 o2 p3 G) s+ V+ R// Convert a 24bit number to hex3 }) o' B& I# _
function toHex(n)
8 e& x4 Q6 y7 W% S{  n& W+ k8 ]' l% }+ g9 B7 t
    return (enHex((0xf00000 & n) >> 20) +
! ^8 R* z5 V0 t' y& D            enHex((0x0f0000 & n) >> 16) +
4 q. {1 p0 ^- v. ^            enHex((0x00f000 & n) >> 12) +
' X( G5 a" `2 g3 @  T9 Q            enHex((0x000f00 & n) >>  8) +
1 ?( _6 p" [; c) i* U* V            enHex((0x0000f0 & n) >>  4) +! r! s2 l/ M& P' @& y; u7 i) J
            enHex((0x00000f & n) >>  0))) w3 A0 F. U/ Q9 H& a# p
}' ]7 i7 _* z/ Q" p6 i; c% Z
// Convert a six character hex to decimal
( p8 Q4 M# y; e' ffunction toDecimal(hexNum)0 E: n8 U+ v& y/ y0 [8 b
{* ]1 o$ k& Y9 ~) U
           var tmp = ""+hexNum.toUpperCase()
- e* M  j/ v8 e    while (tmp.length < 6) tmp = "0"+tmp- y& l) ~' f; l5 S- _& X. G
           return ((deHex(tmp.substring(0,1)) << 20) +
) J& |' Q6 [2 O) g8 g# ~2 x0 {                   (deHex(tmp.substring(1,2)) << 16) +
' g$ g) P' c" C            (deHex(tmp.substring(2,3)) << 12) +
' O  ~) k0 y) j) X: z; b4 }            (deHex(tmp.substring(3,4)) << 8) +' L) x3 {# T/ }
            (deHex(tmp.substring(4,5)) << 4) +7 i* r& u4 y6 q1 Y) e
                   (deHex(tmp.substring(5,6))))
% e" O- k: C! |0 j# H0 B0 p}. {1 V0 {" Z& h& A6 |) Z' K$ n
///////////////////Shimmering Links/////////////////////0 u: _2 r: W, e5 H7 ~( N6 H
//global variables+ V! ~0 b2 F0 V* B( U
var hoverColour
# W; _& t6 |- f, S4 z- Y7 z9 {/ y: b; h5 R* avar numLinks;
8 o+ M" }/ F  ]" c4 Gvar rate;
9 V" V3 g8 L- j* b# Nvar numFadeLevels;
& ?: \) E+ U. g$ I, L7 u& Dvar bgR;% O, Y! t  R, Y$ a) z. B& W% R& {
var bgG;$ O& R9 `  s, E2 }/ \" j  O
var bgB;
, ?/ |. U$ F$ Vvar currR;; {5 c' X$ M8 q9 [( }2 c' a- P8 D
var currG;# f( z3 g2 F# _3 H8 U+ _3 e+ S1 n
var currB;- @. w* b5 I! j5 {
var count;
# p- p; b3 L& R+ ^0 }var fadeOut;
! ]  Y4 c, Q# k0 b) I9 Fvar continuous;
5 o$ j: K0 p5 l9 B3 {0 o' `/ wvar newColour;- v( T1 j% [: ~- P
var tID;
/ H: U* k3 g: Z. h2 ?var redInterval;' B& g0 ~. |8 }3 `
var greenInterval;, q' T& _$ K7 _+ D
var blueInterval;3 V5 H9 n# f  j
function initLinks(mouseOverColour, numberOfLinks, fadeOutColour)
( M  I( G2 A" P{
! I; w0 R" d6 e! J7 j4 g: e& `) u        hoverColour = mouseOverColour;
8 z5 n* U5 _. b! k. b1 q        numLinks = numberOfLinks;, X" p! c7 K, ~3 t/ A
        rate = 1;9 \, V$ k* B! p$ n$ R& |# o& V  U
        numFadeLevels = 30;
! K5 A9 ^* T8 W0 J2 f        function initArray(theArray, length, val)$ a3 k) B6 n# }: f& v- f  G
        {! }, L) U0 U% {" L5 D& U4 K2 p
                for(i=0;i<length;i++)
5 r0 D+ o- |' @9 a" _1 Y5 Y                {' R: ^, p; a1 {; W; y' ?
                        theArray = val;0 H1 |5 g8 A& {- m* b
                }
" Q8 c; s# s, D1 v+ V. F        }
7 [0 j. u6 C" x! J, m& R7 C" ^4 y        bgR = '0000' + fadeOutColour.substring(1,3)
8 m, p- S& k6 q+ q% k0 F2 w  h  f        bgG = '0000' + fadeOutColour.substring(3,5)  W4 _3 x; {# \' ?) d
        bgB = '0000' + fadeOutColour.substring(5,7)) o8 ~0 ?* T! c: b+ r; F- \  i
        currR = new Array(numLinks);- C& l$ {  Z! {, n
        currG = new Array(numLinks);
1 D  `; L! f7 |- j        currB = new Array(numLinks);
1 d$ j/ J1 |! E8 Z& S$ k- o/ e6 Q        count = new Array(numLinks);  P( O0 _* P) ~4 F4 r
        fadeOut = new Array(numLinks);9 L+ B; B5 O" K4 z
        continuous = new Array(numLinks);
" n% M/ ~! B  X        newColour = new Array(numLinks);
& x% u5 \2 e) Q" c( x        tID = new Array(numLinks);
) a  p& K* M. G: R# A. f; ]        redInterval = toDecimal(bgR) / numFadeLevels;* v# _# v! A' i* q9 t+ Q0 F. r
        greenInterval = toDecimal(bgG) / numFadeLevels;' S/ a8 m' _; R4 C: ]& W) a5 e9 E
        blueInterval = toDecimal(bgB) / numFadeLevels;
& H/ `2 Q1 A7 v! V7 e0 ]3 I        initArray(currR,numLinks,0);( ?8 w* A. D" D5 D) R0 n: y  z
        initArray(currG,numLinks,0);1 M9 C) W: W8 N" F6 o# Z* T" l# h
        initArray(currB,numLinks,0);
/ y5 ~. n4 ~' U4 [2 \        initArray(count,numLinks,0);/ o3 i6 U0 S1 Q0 Q
        initArray(fadeOut,numLinks,true);
, ?5 E& `$ M- i# A4 h        initArray(continuous,numLinks,true);. p' u" \# A, t" F
}       
; S; s4 ^0 `. [& Vfunction startFade(id), d6 N6 g" n* n$ R
{9 [/ b7 i" ~6 S. b2 U( w6 w8 m
        if(fadeOut[id] == true)
; f7 g/ a8 S; b6 [        { /*move colour towards background colour (increment)*/2 P) r8 x* e/ ^$ N6 W1 A3 w# K& p
                currR[id] += redInterval;# J0 J; w3 K; r8 a- u7 ~1 b
                currG[id] += greenInterval;
3 r4 M! h9 V8 d. M+ W# Y                currB[id] += blueInterval;8 B2 F; a6 P0 b* D2 n) H
                newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);
# U# z0 b- Y5 o                if(++count[id] == numFadeLevels)
$ E" u$ Z" \/ V                {5 ^5 w- _& r3 ^! n
                        fadeOut[id] = false;( d% F# y( D! |
                }" G( Z' ~" \# a. `
        }
4 Y  B' B7 s$ f/ D# o, h0 ^( u# s! \        else
' \% Z1 j2 n: z  g  |        {7 D; f$ a. B# H" i7 w5 [* ]3 x% S
                currR[id] -= redInterval;
. |& z4 y4 D3 W1 I) i+ D  U% @
% t0 H, ?. T- q$ H5 @: D4 S: U& j                currG[id] -= greenInterval;
" j6 v3 q2 B$ F  s; w* q
7 p/ C$ {7 I& W: @. R                currB[id] -= blueInterval;$ e5 _) p: Z+ Q# k
! k& R* ]  S. [' U& C  B
                newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);- \* ]) M1 Y8 _
! N$ X, _, V8 |0 x0 m
                if(--count[id] == 0)) j* C- p; E3 y+ v
, s" C( I; @" t% F- r: H1 n
                {; x0 |5 o0 j9 o) P. \/ {

( [% h& c, ]) Q% N1 y  d6 T- w8 L, p                        fadeOut[id] = true;
9 W3 J( W' o, \( X2 a  P! u
% f1 ?6 B/ h& o/ W, C                }
+ C  f* }& w3 |7 m2 q4 Y
+ W. o( e  ?1 d, @, q1 r3 B, C        }
, a3 \$ Y7 M5 x+ A
0 A" J* I4 A+ p) `) S        if(continuous[id] == true)+ h( g4 Q' H* f+ H

! E9 t6 Z5 r3 E' n4 X  i        {
2 N0 @5 E0 _6 o5 E
: i( }: n! E+ Q4 h& L" v; o$ F$ L                document.getElementById(id).style.color = newColour[id];               
; v0 Y4 m3 l( u# O, P9 g
( `' V( o, `" w        }
  Q5 ?  Y1 j) |/ e7 B+ k& e: P& Z1 i3 \$ S! R8 W
        else% E# g, n; b6 B6 L1 I( P; G

4 B; K# u& K/ {) y# w+ ?, t        {
; H) }; e9 V* e
/ y# Q/ f/ ?) R0 @7 d6 A                document.getElementById(id).style.color = hoverColour;
7 \1 q3 d) ^# p2 ^! E6 W5 o+ o1 o2 ^& d' N
        }
' y, I1 }+ {- m4 m/ D
: N. m0 \+ W; e2 |        clearTimeout(tID[id]);
0 c* q# Q# M3 }
2 e' o/ {3 K3 x* {        tID[id]=setTimeout('startFade(' + id + ')', rate);
* U" S' ]$ X, I, C3 \  b
* `- b$ C0 r2 W1 H: R' X' k}
, k! U9 K5 k+ N7 A, {$ y1 M  _/ G4 t
function continueFade(id)
- W4 q' Z1 F1 S6 A( f
# o( S9 r: q; p{' l) @& S+ F5 {

# H' ^' _* I7 C6 x9 g) u1 S: @, F: H7 [        continuous[id] = true;8 J- `* N) Y# {9 `( z
2 W, Q+ ~" c! _6 S2 {& q) ]$ z1 B
}
0 G/ [3 N. M4 M5 N  N, C6 I
! M& W$ p/ M3 nfunction stopFade(id)! f7 U" x) S* E; j  G/ u
, M2 [" @2 a' b4 ?  ^' j3 f$ G
{+ t6 u* c. _6 U5 B  G- ]
: ?: X8 j, |4 }+ X; H4 u, {8 k
        continuous[id] = false;
6 k0 S: g$ [' ]" V& ~% r9 y' }2 H' E2 N  N
}
) c! N2 w* l: P7 U3 s7 |7 J
( ^5 h4 S  Z( lfunction StartTimers()7 g: J$ g( k/ d- Q

0 k2 v6 z; k; A( v" ?: l6 \{        //set up an initial set of timers to start the shimmering effect/ m! d' L9 ]+ R. F( U4 O
$ m7 ]' N2 [2 e% L  a5 q
        for(id=0; id<numLinks; id++)
1 l! h1 ]: ^' o; Q+ `. w9 Y
% J* K+ B) ~1 M4 G4 O        {
4 N/ m4 n5 Y, F# M* P% q$ l2 k6 r( d2 _& u( ?7 s1 F
                t=setTimeout('startFade(' + id + ')', id*100);
8 b2 s8 I) z) d9 F" W* U7 ]3 z* A+ d2 v0 ]! M2 Q
        }
7 K  x' A3 n  p7 u4 z3 v/ Q/ |7 g' c
}
, h' e$ ^( ~5 c% s2 j( ^. ?, C, m. b9 C9 p2 }1 Q6 Z% [
//format = initLinks('mouse-over colour', 'number of links', 'fade-out colour')- O( Q) r6 @* ]
- b1 k& ]. g4 e( M1 H3 S7 b! F
initLinks('#FF0000', 6, '#FFCC77');) S2 s, d3 H! T: P- y

  k1 m9 B( A7 G9 c$ u7 M//-->
# b* K$ P+ M! O4 D+ n6 T* C
, y6 D. ]+ f0 m! K$ R  E</script>
. _( S# G  q! @" [4 |1 S<a class="links" id="0" onmouseover="stopFade('0');" onmouseout="continueFade('0');" href="http://7wind.com/">国际域名:58元
. b; y5 V' z3 J" J/ _- x) m</a>
; Y2 [* n: v7 s: U<br>
$ `$ D  Z% e( x3 O* i  x<a class="links" id="1" onmouseover="stopFade('1');" onmouseout="continueFade('1');" href="http://7wind.net/">国内域名:110元</a>
5 P- {* A0 A! L: ?( w0 ^: K<br>, C& M( Q4 O( D& u7 A
<a class="links" id="2" onmouseover="stopFade('2');" onmouseout="continueFade('2');" href="http://7wind.net">新一代企业信息系统</a>% f! [( M0 t3 [
<br>        ) E+ k- h, v4 q' i& u
<a class="links" id="3" onmouseover="stopFade('3');" onmouseout="continueFade('3');" href="http://7wind.net">新一代网络商城</a>
1 x" O9 g0 f1 E- S3 {<br>, G) w3 \' o! ~" h% V7 k/ W" h  b- }
<a class="links" id="4" onmouseover="stopFade('4');" onmouseout="continueFade('4');" href="http://7wind.com/">全新的自助建站方式</a>8 L/ l* k2 D; S. v; p
<br>
3 r$ B5 x) Z5 V5 _0 z$ l6 ?8 h<a class="links" id="5" onmouseover="stopFade('5');" onmouseout="continueFade('5');" href="http://www.webdevelopersjournal.com/">全新的设计理念</a>  R7 h% b! x3 b. K" z! v: G
<script language="javascript" type="text/javascript">3 P$ P5 g) Z6 r
<!--0 y2 o' H/ ~7 z) [$ Y8 |8 j
setTimeout('StartTimers()', 1000); //initial 1 second delay to allow page to load and ensure smooth shimmering9 v4 a1 E$ J8 V; G  ]9 Z7 h
//-->
$ ?2 U: x; s' m. w; v</script>

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