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

|
网页之文字的循环闪动特效
<script language="javascript" type="text/javascript">
( k3 B$ N. _( b5 s+ N7 G; v: p) r<!--* w% t. j) A- ?# F/ d3 @5 A
// convert a single digit (0 - 16) into hex8 K8 c2 ]7 i8 t6 Q B; j- w$ k& N( @
function enHex(aDigit)( b) E* C/ ?3 e1 K- ~$ B8 B1 }
{$ ~- ]: [& C$ g! h \) f
return("0123456789ABCDEF".substring(aDigit, aDigit+1)): B$ \, A3 \7 u% G# F4 B) b" P
}
' |2 t$ I" _2 ]+ k// convert a hex digit into decimal
5 ]! a2 O: Z8 e" g3 {function deHex(aDigit)
* {+ R" ?5 v' R! C( S% T{
: z: M- B3 ^- a; h* E- c return("0123456789ABCDEF".indexOf(aDigit)), f+ v3 r' P$ j; q
}
9 ^. A7 M1 d* |5 s
9 q u$ k- Z' J// Convert a 24bit number to hex3 f9 x. C) L, [6 r
function toHex(n)/ w: D/ S: Y7 y# R8 f
{" d! Y' I* S5 [9 Y, @; Q# u
return (enHex((0xf00000 & n) >> 20) ++ m, J- f9 i6 R4 h# P
enHex((0x0f0000 & n) >> 16) +
7 A9 [" t* c5 l/ z( Y enHex((0x00f000 & n) >> 12) ++ y' w# J; ~0 O$ C# R" I Z
enHex((0x000f00 & n) >> 8) +& {" F4 F8 ~5 q
enHex((0x0000f0 & n) >> 4) +9 E6 z! N3 f A% ~" g, D9 J
enHex((0x00000f & n) >> 0))
6 w- E3 @0 B6 A! Q}/ S" }' y0 T6 r: o3 ]" T$ J: G: t
// Convert a six character hex to decimal# m: }% ^( u; ]
function toDecimal(hexNum)
* p: H4 U8 @, c% N; p# x{
( e% G! x8 U+ d. S. F var tmp = ""+hexNum.toUpperCase(); a- q) B9 c! w; t
while (tmp.length < 6) tmp = "0"+tmp6 E- r4 h$ M+ T$ u* `& F8 G3 f
return ((deHex(tmp.substring(0,1)) << 20) +
$ |8 Z$ Z" v6 n9 j (deHex(tmp.substring(1,2)) << 16) +
* b1 e% U2 x6 I9 W N (deHex(tmp.substring(2,3)) << 12) +: {8 g P: g2 H% _& ^% H: g
(deHex(tmp.substring(3,4)) << 8) +
9 a) y! K# a- J$ a. U8 F (deHex(tmp.substring(4,5)) << 4) +
1 f) V3 j: [" |' c0 M (deHex(tmp.substring(5,6))))' r; h" |/ y8 o- k) M( \" j a
}
; J' h& w+ z1 `! b: U; G///////////////////Shimmering Links/////////////////////
0 l! o# N" n" Q# t3 s! t* Y0 T- Y//global variables( b" l* ]3 A# n5 d" V" _
var hoverColour7 H6 E- F3 L$ T/ w9 _# L3 \; S/ I4 T4 \
var numLinks;
" M+ Q3 m% d! ^, }var rate;
: O, `7 s8 r7 ?8 W9 L# z% cvar numFadeLevels;
, w$ G4 F: Y0 B. tvar bgR;
/ c9 H. C! f2 V! v. Xvar bgG;; A5 ?, x, ~7 q8 P! P9 k
var bgB;
# G* S- A9 @: jvar currR;
3 z( D, k1 L4 Lvar currG;; A8 h. D. A7 {- G
var currB;
9 ~7 g5 W8 m9 u4 e, [0 P" |var count;
3 P. H, }, w. ~; u, Vvar fadeOut;
, e& Y' H8 v z6 h+ G$ [; g6 U, Yvar continuous;
- I/ ~5 i3 c# B3 L- @! _9 O, g: R0 H6 hvar newColour;4 {# f, T5 P; G/ V2 S
var tID;
4 P5 h' H& I/ C9 b/ m1 y1 Xvar redInterval;
( M7 p; F, _5 x/ ]1 u- Wvar greenInterval;
) d6 {4 v3 P" a; F2 cvar blueInterval;
! I! S* [6 D+ Z5 c- qfunction initLinks(mouseOverColour, numberOfLinks, fadeOutColour)8 h" ?. _8 W# ~1 C+ s
{
+ i% ]% ^" P1 D hoverColour = mouseOverColour;
4 X' q$ h; X7 e2 I% A' J" @' i1 r numLinks = numberOfLinks;
: @9 i) g. n0 V: {2 i rate = 1;
: C+ S. D7 D# i: d I! K( j% J numFadeLevels = 30;0 I5 w9 V: F$ p& Q* z2 |8 T
function initArray(theArray, length, val)
- Z; ]. w2 c! ?3 F, c {4 c# k6 {3 b3 E+ ~/ L9 K
for(i=0;i<length;i++)
* H2 n) Q9 F8 t5 A { p. X! A: j, s* C' r# ?7 |9 z
theArray = val;
2 l1 g% n, s. C+ F( A }$ g% \4 ~0 M; D
}; v3 X' a* Y! B9 M; T4 y1 f `
bgR = '0000' + fadeOutColour.substring(1,3)$ x* I: b* T* K5 L2 x" S9 {& j
bgG = '0000' + fadeOutColour.substring(3,5)9 A- ]0 f E6 C2 d% Y) f
bgB = '0000' + fadeOutColour.substring(5,7)3 O8 X M: p$ W, W+ D3 u
currR = new Array(numLinks);7 T m) \- b2 Y. P
currG = new Array(numLinks);1 B* G( D1 ~/ u7 l
currB = new Array(numLinks);
+ `# l* @0 D0 P t) s count = new Array(numLinks);
2 ?6 s0 V- b6 T1 s5 T' n L fadeOut = new Array(numLinks);& T4 v. I/ {. _8 T6 s
continuous = new Array(numLinks);
: y" S) O/ p3 d: M u newColour = new Array(numLinks);
& d3 c# s! R$ S) e/ d2 {$ I tID = new Array(numLinks);
4 b) o% P7 H& o0 e redInterval = toDecimal(bgR) / numFadeLevels;
5 @4 h# q5 t9 h greenInterval = toDecimal(bgG) / numFadeLevels;
& H$ s) e9 g3 G4 K- z blueInterval = toDecimal(bgB) / numFadeLevels;& t6 G; L8 J, w' p7 Y' \! t" _: c: P" q
initArray(currR,numLinks,0);
' }9 s5 i- K3 a; I. E initArray(currG,numLinks,0);
) h. W x# |. P4 t4 c# b5 \: c4 V: l: x initArray(currB,numLinks,0);- h1 s" O% ^$ r5 \
initArray(count,numLinks,0);( M& G0 c) f( `6 P* \7 e5 v+ q
initArray(fadeOut,numLinks,true);6 c0 ?# \! X% G x* H% e. j
initArray(continuous,numLinks,true);1 H% \. N/ W, l; s
} 6 P d* M) Q% a) e; s/ k
function startFade(id)0 @# Z: K" i* A& V! I
{1 i; P4 d1 J0 l- @, c# E7 N6 C
if(fadeOut[id] == true)" k {. O3 V+ ~( Y- s2 x5 Y
{ /*move colour towards background colour (increment)*/
, x" S; j8 A5 B2 ? currR[id] += redInterval;
) H+ _* n6 E8 Z/ {, p" G" s3 `1 m currG[id] += greenInterval;6 U8 x- A% Q7 Q, F
currB[id] += blueInterval;# I+ z- X. I# N7 v6 M7 T
newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);
1 f2 m2 I8 `0 i* v% P9 s8 ^1 v if(++count[id] == numFadeLevels)7 @. U+ b# E/ u* M/ S
{% ^' b$ G1 I1 L3 U( g+ T
fadeOut[id] = false;" v% \! v) j' D1 V
}
3 @5 e5 k. r4 S& ~8 x }
: H6 t+ ^ c" @: h# ] else
* p/ {$ r# c: K {
0 } ]9 m" x' Z, A( ^0 k currR[id] -= redInterval;) D O N3 {9 x! B( ~) W8 X
* J: D2 `: V" E$ q
currG[id] -= greenInterval;
9 i1 Y. Y1 {$ L" Y9 R+ q
~0 Q4 Z7 x- W) `$ N currB[id] -= blueInterval;2 E7 Z- O4 k0 Z0 v& Q0 e+ Q
l. @) P' Z. N1 ` x& \$ A newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);* [9 a% n8 }5 l% e* {$ U. w& ]
4 ^: e j+ D. u6 Z" O- a. ? if(--count[id] == 0)8 H' v4 A' r) @' _( ~+ x+ L$ i
; ~, i( q L! a0 Z( e! R9 p {
5 F6 ]( c8 h: \1 N
5 o' ~! B: }) q$ p3 J# y fadeOut[id] = true;
! [2 }8 i6 ~' i# m, n1 N4 ?/ }4 J4 k
}
: C8 t' [! ~5 E
. t; W a7 W3 _, d }
3 S' o2 U8 }( d# q" M" }+ V
' f5 Y8 [+ |& h d9 E7 f" q if(continuous[id] == true). h& m5 F, e% _: I
3 J+ z# m+ j3 D' f6 f
{
; Y* J, v8 ~, P6 _3 N* g" B1 @& g# N6 f
document.getElementById(id).style.color = newColour[id];
2 B1 Q; ?! r2 O, ]+ Q8 P
6 a8 d2 X+ \3 P }$ M, P* }+ R) b! P. k% Z
! X% s' q' I/ v else
$ D$ n' k/ t. W5 y- l# s( f0 Q$ [: f; g- p) v) ~! H
{7 {2 B. x$ D- m' ]
3 b/ {( b ^9 U3 e+ }8 g! f document.getElementById(id).style.color = hoverColour;
& t% c8 c+ O* G& x* j0 K7 m+ C4 G) P2 W& [- \6 L" ]& r3 D4 S, X) P
}
/ ^3 J. t& E. [4 ? e0 r/ m* ^2 \ A# c9 X
clearTimeout(tID[id]);
+ e0 x9 I, u) Y( y9 w' V1 W. \2 b: x
tID[id]=setTimeout('startFade(' + id + ')', rate);4 T6 r8 a0 a7 C" ^' r6 d
0 ~) O1 ?( l H0 B; e7 Z}. S9 Y' ?+ c& m1 e
1 e* O- r' f4 a. b4 `
function continueFade(id)" b$ D- G! h( Q, l& T
9 y0 M& a! l; I{
4 }. c& M, f* o. \/ W' F6 l: W8 N
continuous[id] = true;+ W4 c" Q/ X) ~/ Q
# t7 y4 c2 a5 z' k$ v' M% |# I( \! e
}5 q# r' A* ?; V! T* q8 t6 s* u
3 [) y, D6 q8 ~" }
function stopFade(id)
4 Q0 Q3 S, M& Z0 Q( k0 B7 M* Q5 y! d S; {% T8 f
{
+ f5 d( W# H9 d! v, o
' C0 L3 [ M) [ continuous[id] = false;" }6 ^2 x* x2 e
7 ]# E& |" G! l5 P2 @4 L- p% r}
0 H4 l/ i: a# c5 W2 `+ _# g8 |+ j& U
2 }+ w: I$ s( D" }$ x* E/ ffunction StartTimers()5 I; N. t0 r' O- \+ {: c
- ?; L! u- T4 ?. K7 k
{ //set up an initial set of timers to start the shimmering effect
- g) P: ^4 \1 D# Z. m3 c" a( n
) s0 A5 @( g; L; T for(id=0; id<numLinks; id++)
. W) @4 U6 p" i( r5 P
8 a: u Y. M2 l. n+ @ L {3 z: K) \3 M* ^' F3 ]; e w
2 z* K6 ?7 |. r/ @+ v% R9 q; \ t=setTimeout('startFade(' + id + ')', id*100);+ N1 P1 v! E$ g; w. w
# _+ H! s& {0 n5 i
}
; M" _# ~! E& J6 b$ i/ U* ?* \$ o1 |3 J, d
}2 b5 I5 k# p. u9 L
6 { N9 l3 _8 V
//format = initLinks('mouse-over colour', 'number of links', 'fade-out colour')# s, q3 L- J: ^6 z z
9 ~, T9 S! W# _) e" T. w, y' vinitLinks('#FF0000', 6, '#FFCC77');7 z3 j! N/ v& B; k% g; z Q
& h9 P3 K. m& q
//-->2 l+ |7 W8 Q; l. E0 B& U* l: h6 B
5 `' s1 U" |: k( ~</script>
: c" W' ~) ?7 V& `* w( Y<a class="links" id="0" onmouseover="stopFade('0');" onmouseout="continueFade('0');" href="http://7wind.com/">国际域名:58元
8 c6 ]; ?! A+ n. g6 J& o1 R* x</a>- S9 R# K" A3 k, B0 \# t/ W6 y; H9 k
<br>$ }. f, F9 T, W) S3 d
<a class="links" id="1" onmouseover="stopFade('1');" onmouseout="continueFade('1');" href="http://7wind.net/">国内域名:110元</a>
p$ t C! Q* o3 S3 i4 }1 n<br>
) z% T. S/ U4 _( O<a class="links" id="2" onmouseover="stopFade('2');" onmouseout="continueFade('2');" href="http://7wind.net">新一代企业信息系统</a>
. \( `" i8 d# u1 K' H" r<br> & {- m) z# [: @$ N# t4 c" @# L
<a class="links" id="3" onmouseover="stopFade('3');" onmouseout="continueFade('3');" href="http://7wind.net">新一代网络商城</a>. H3 W/ Q% T) ]! Q- w
<br>% k* P4 I) M" ?! }
<a class="links" id="4" onmouseover="stopFade('4');" onmouseout="continueFade('4');" href="http://7wind.com/">全新的自助建站方式</a>
& y, A( I1 t0 E. ?<br>% s- N0 p6 r" ~$ B% G% j
<a class="links" id="5" onmouseover="stopFade('5');" onmouseout="continueFade('5');" href="http://www.webdevelopersjournal.com/">全新的设计理念</a>
8 \* S' Y) m; }. o, }<script language="javascript" type="text/javascript">
; |2 B5 C2 C9 _( Z<!--
u# h$ N( R5 f3 k. y VsetTimeout('StartTimers()', 1000); //initial 1 second delay to allow page to load and ensure smooth shimmering
2 m2 M' |& i# Q+ \( `% { ~- \//-->
2 @- R' U4 l( `0 v</script> |
|