  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之文字的循环闪动特效
<script language="javascript" type="text/javascript">
4 ~* y3 x+ @& ]<!--
Q& c# | D& z; ]// convert a single digit (0 - 16) into hex
- {6 j$ W* N9 |function enHex(aDigit)8 |% ^; i8 A4 H2 z9 V" }9 ^
{
3 V! S+ i1 J. F- H' {; z- Y a return("0123456789ABCDEF".substring(aDigit, aDigit+1)) v) u. g+ ?- H& B% p0 n. b& c
}
" k, }/ L4 d H* w% |- k: [1 F// convert a hex digit into decimal1 l9 e% |3 k8 p, U! [# L
function deHex(aDigit)
' |% T5 G+ h, S1 f) L+ L{. N! A8 u2 L+ }1 I- P
return("0123456789ABCDEF".indexOf(aDigit))4 G x. f4 s" K8 y" N$ a7 c
}1 Z7 }6 `" v9 ?/ B
! S* }4 w8 Z& e) l! S// Convert a 24bit number to hex
% \# x" x* p2 i. J! Y2 t9 Mfunction toHex(n)- \ p6 C4 R2 O: }
{
2 D7 ]5 E# L% q return (enHex((0xf00000 & n) >> 20) +" [& }$ O3 ?& R
enHex((0x0f0000 & n) >> 16) +0 k* y* l" [9 u1 ]+ w5 ]; K
enHex((0x00f000 & n) >> 12) +6 T- f; T1 f* k- K$ |3 X4 R
enHex((0x000f00 & n) >> 8) +
/ Z' }: ]/ P/ V1 l enHex((0x0000f0 & n) >> 4) +
5 h8 d6 X) w/ s' _ enHex((0x00000f & n) >> 0))
5 O% g$ W, t3 y$ t h}6 b' \" |7 Q# Y0 a- I4 f5 J
// Convert a six character hex to decimal2 A. s9 h7 Z4 V3 a3 R
function toDecimal(hexNum)
8 y/ ^ } @# M4 X; _{ f3 x% U0 s; b" P+ t" m
var tmp = ""+hexNum.toUpperCase(). M& K' w E( _7 l
while (tmp.length < 6) tmp = "0"+tmp# o/ I$ Z% Z2 v$ @" G3 U3 X0 b
return ((deHex(tmp.substring(0,1)) << 20) +
$ }5 R2 F6 M0 ` L& o% Z (deHex(tmp.substring(1,2)) << 16) + 0 l! R4 \% J X; K8 C
(deHex(tmp.substring(2,3)) << 12) +
' @& ?. C2 r- j; U2 O$ _& y+ p (deHex(tmp.substring(3,4)) << 8) +
! T. F |( w$ M/ A: Q! C- ] (deHex(tmp.substring(4,5)) << 4) +
6 E' @* e: Z/ X8 u; b! P (deHex(tmp.substring(5,6))))0 ]7 N* s+ Q* \/ l& X
}0 Q8 k7 m( B. q2 Z; l% W4 J
///////////////////Shimmering Links/////////////////////
; ~6 Q8 k* w* Q% W2 A% ?, v7 I//global variables
8 v2 M9 a5 u d9 M! Hvar hoverColour( _" o, y$ b, J" x- g. T
var numLinks;
c9 T4 J" D/ ]/ @( @ w# X! {var rate;
& f3 @. C' n( J; k9 Q2 t+ Xvar numFadeLevels;
) X3 i% F. ^' d# O1 B' A* y% _8 D/ Xvar bgR;
3 q+ \ P/ C# S! M- J- A% \* wvar bgG;% h, m9 i: j; N9 l. [/ J. e
var bgB;) A$ {1 h8 ]9 h" C
var currR;
1 c' k% y- E) Hvar currG;
; V9 D( c2 w, X/ T/ Vvar currB;" v0 p% `9 ?& }2 q
var count;9 J2 m. [3 N: I# q
var fadeOut;% M, e) o7 v- n
var continuous;
& N: \1 s$ Z( c' Q! |( Dvar newColour; h/ y' I5 n- m1 x0 Q; u2 O
var tID;) D5 F* O5 P$ Y2 S
var redInterval;+ Q" L3 N3 d1 m! j3 |" m
var greenInterval;# p) Z- [& M u/ `6 \+ s) x
var blueInterval;
3 ~9 Q% K) m5 A2 }0 ^function initLinks(mouseOverColour, numberOfLinks, fadeOutColour)
: {, I9 T4 }6 A{- B) B. ]# V3 K
hoverColour = mouseOverColour;
/ F l, h' \. l8 G numLinks = numberOfLinks;
+ p4 v. R8 d. [/ ^* K1 U rate = 1;& C" B$ K, n. d3 s% C$ u
numFadeLevels = 30;
A( K3 b! ~. z) @8 m! \6 l function initArray(theArray, length, val)6 W" `7 [2 }( ?
{1 N2 w' s1 p1 Y
for(i=0;i<length;i++)2 F( e; ^ [0 h
{$ C! n- H- L% l! m$ g6 H
theArray = val;8 o, _/ Z' W j( [
}
7 `' Y; j% R; }( u# _ }# u( e' {+ `+ `0 u. l* p0 h* z$ Z8 b
bgR = '0000' + fadeOutColour.substring(1,3)
1 n2 f# J# u9 G4 ?( E bgG = '0000' + fadeOutColour.substring(3,5)
1 H8 ~2 H3 p+ N' d4 f8 k+ e bgB = '0000' + fadeOutColour.substring(5,7)9 @; c2 ?* S# d' a
currR = new Array(numLinks);
. O" k# M# c9 s. Y3 S currG = new Array(numLinks);3 V6 ?% d# b8 {9 i# I k
currB = new Array(numLinks);
8 A( W% ~1 r: P5 S0 I( w8 s" p9 M count = new Array(numLinks);. ?. ^4 {- n- T) p7 \ q
fadeOut = new Array(numLinks);
1 Q; g# v: x2 E3 F continuous = new Array(numLinks);" W9 Q0 @- _2 C; S" F/ Q3 O
newColour = new Array(numLinks);
. X0 P/ }8 p& L tID = new Array(numLinks);$ A6 p' ?2 l. ~7 a2 H+ v6 C
redInterval = toDecimal(bgR) / numFadeLevels;
3 g8 M* ]$ d8 q, R/ f7 c greenInterval = toDecimal(bgG) / numFadeLevels;) c3 Y9 P3 s9 e" i e: N; F
blueInterval = toDecimal(bgB) / numFadeLevels;
* N4 O+ N+ j' V" V9 x initArray(currR,numLinks,0);
; D' ^) l! |6 u6 ^7 W. i initArray(currG,numLinks,0);% g& k7 t7 T, k5 ^) E9 i
initArray(currB,numLinks,0);. {' x2 j/ b) P2 z9 _' V
initArray(count,numLinks,0);
m) K3 P4 b) Z$ W initArray(fadeOut,numLinks,true);7 ]* I8 @( V! w& v0 S) ~( \
initArray(continuous,numLinks,true);
5 c2 c7 E9 @4 ^}
! D8 i. L- S: z5 P6 J7 e1 s7 y3 Kfunction startFade(id)5 X' `: r5 J3 J- |0 ^9 |) ]
{0 w+ c" N( h* A4 v3 c. L0 x h
if(fadeOut[id] == true)+ p8 U) R6 J& E/ n _- M) q1 j. E: Q# ~
{ /*move colour towards background colour (increment)*/
) I [, R/ m. a7 l* W# j currR[id] += redInterval;3 G6 E3 H( b) \7 t1 A5 D. }
currG[id] += greenInterval;
& e8 O' Z( d( B" f( f* {; p currB[id] += blueInterval;+ O P- O2 Z. o! t! x0 t5 K. u
newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);
. u& q- Q O* O if(++count[id] == numFadeLevels)
6 e% k! V0 B. C" g# ]/ e1 Y {1 N# W2 P/ ]+ S5 H; E
fadeOut[id] = false;
$ q/ s% c6 R- r8 X3 y9 l }2 o; S8 f U. s* w
}
0 N0 ?& K0 s6 v else4 W. v" U a' _6 S
{
d) L$ T) E) g% s+ g currR[id] -= redInterval;0 Y3 e, m/ N0 C& f! \
( W& |& F; G: z. o currG[id] -= greenInterval;; c* k/ O$ [( S: @ [7 k
: ?8 d' a" E5 Y- H- e+ H currB[id] -= blueInterval;) [$ l7 L, x' E
1 ?5 C; X+ X; G9 Y Z. Q newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);& c2 n' i- T2 }. w x
+ {' `1 r1 D: |, t, Q. A; R- M7 F
if(--count[id] == 0)! _5 @ K7 E4 j4 p/ o
% ~' Z) g% Y y8 @
{# F" O* M5 z @" T# H& k) T
6 T4 P+ C! a* W0 e fadeOut[id] = true;
7 I G' s. q5 K, X2 [
2 u0 o6 G8 s' H) n }; D9 Y/ O0 x* x7 D# s' U# l. \
# W9 Z" [' B" W0 H0 q" e
}
( [ ]( Y- \ `5 a7 I7 g# a
; C% s; |% p7 ~8 ?! X if(continuous[id] == true)
) @' k. M K# R' g) G" A2 C m& p7 Q9 G- a" S
{
6 e9 }+ i) e1 c/ ?
- `1 V3 v4 J2 }5 n6 s. W: J document.getElementById(id).style.color = newColour[id]; ; s, W$ U' P- g2 [2 t8 L
8 h! z1 X- ^5 n3 U0 s3 L3 t, y7 M }+ L W: V! o- i
7 @5 S7 v" F7 ^' `# f else8 t K! g' i, a/ j( i5 y% e3 }
2 G# G+ X% k6 G* k+ @1 ~, F. w' k
{
E, O* i* K$ V$ Z# [% l+ @
`+ X! G, t; D( [' X* l document.getElementById(id).style.color = hoverColour;
1 A4 Y5 T0 b" h3 Z6 V. ?' V2 I6 w: g+ ~$ l0 H
}
' q2 {# a2 h% e8 H7 ]: M5 v5 B' `0 u; r4 Q1 T
clearTimeout(tID[id]);
/ |/ p" s6 H$ e$ c) V/ V; y
- B3 R/ [1 e8 I& ? j. b! V tID[id]=setTimeout('startFade(' + id + ')', rate);
! `5 `, P p" N& ~1 D- K: D% B2 `) e+ k
0 M: e# S! E+ t/ l' e' _} C3 k3 A2 Z5 K. D: M1 d% f- m
0 @$ T0 [, p! t, lfunction continueFade(id)! r% w0 I- i8 u2 L `' V8 A- W- H
# V# z: s. g3 }
{
6 P, G) |, {+ g5 @; X/ s
' @8 G+ M( s# T+ e! x. \ continuous[id] = true;0 ^" F# Q# q5 l- z: n* V+ @. V4 p
( w5 Y( G! a6 W* | Z
}
7 f, p( z6 s3 k/ Y2 r3 h( P' L. z& X0 \" J1 i* m
function stopFade(id)
* }$ Z3 Y7 U! _7 c/ Y; d+ @- t8 r+ t
{
$ c! z% c- T% }8 C6 p ]. z" y9 j8 p$ K% r
continuous[id] = false;- B# i( f" m! a P# i& B
2 h3 ]: D1 q( \5 J8 c. @; R
}; L! z+ Y) Y$ \: @
" x5 y; O$ K9 f" |) k; y
function StartTimers()
0 L* o$ J' Y# Z4 u9 p& R& }( c# ~3 B; x; w8 F! n/ m' s
{ //set up an initial set of timers to start the shimmering effect& T& n" s- }# S# N
) Z% T7 ?! e# x" G d8 U for(id=0; id<numLinks; id++)3 K6 I" \) i8 \% y6 J
' a7 v$ J! B/ ]1 S: G {, K2 F$ `, ^9 Y% w0 ]
t: u. V5 S' }! n$ ` }: |! k+ g. ~ t=setTimeout('startFade(' + id + ')', id*100);
2 s5 C, e3 Y. I1 b
5 L4 p1 i. k/ ` I5 C }9 c }' t& J. S- V1 p. c7 L" f* j
: R p" p! n1 |# `! `}
% Q, l' }; k& a- l- [1 D
: \6 @$ w. U2 L* ?0 l0 ]//format = initLinks('mouse-over colour', 'number of links', 'fade-out colour')
# B5 _7 ]% Y/ b' g" F, ~( @4 s) z6 O: w* O: |3 v
initLinks('#FF0000', 6, '#FFCC77');! Q" h& q; N$ I* z, }+ B
+ D- z* C9 D% b+ Z* b
//-->" I5 m6 t& c! X1 N4 U! c L
% U3 g2 F) h% g" V
</script>
( l. B* H6 d$ \<a class="links" id="0" onmouseover="stopFade('0');" onmouseout="continueFade('0');" href="http://7wind.com/">国际域名:58元
1 U. y2 h$ i) r4 K</a>
" c& w( y8 L' D# _( b, ?<br>1 I+ a7 f/ n; U) I8 D2 f5 s
<a class="links" id="1" onmouseover="stopFade('1');" onmouseout="continueFade('1');" href="http://7wind.net/">国内域名:110元</a>
' u3 h. P4 n! f2 @( `<br>
: N5 ~" Y7 ~% P' X<a class="links" id="2" onmouseover="stopFade('2');" onmouseout="continueFade('2');" href="http://7wind.net">新一代企业信息系统</a>2 R8 b; D$ @' ^6 T
<br> 8 ]5 A# y( L3 J' s
<a class="links" id="3" onmouseover="stopFade('3');" onmouseout="continueFade('3');" href="http://7wind.net">新一代网络商城</a>+ D M. J) S8 a' Z
<br>6 H4 y1 s1 d0 X9 x! t/ d
<a class="links" id="4" onmouseover="stopFade('4');" onmouseout="continueFade('4');" href="http://7wind.com/">全新的自助建站方式</a> h6 C3 p( K( b! j- w
<br>
: n) Z U4 P8 a( Z<a class="links" id="5" onmouseover="stopFade('5');" onmouseout="continueFade('5');" href="http://www.webdevelopersjournal.com/">全新的设计理念</a>
. O$ U( b- Z$ P0 R5 v5 K<script language="javascript" type="text/javascript">
* Y- z M5 G7 g<!--
2 i: v( m+ K! [setTimeout('StartTimers()', 1000); //initial 1 second delay to allow page to load and ensure smooth shimmering
) x, ?$ a! z* h3 \5 w//-->
. o) [) {1 E: r6 m/ `! K</script> |
|