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

|
网页之文字的循环闪动特效
<script language="javascript" type="text/javascript">
3 @( | p5 P; |) q<!--3 Q( O O8 o E; Q$ K1 w! h
// convert a single digit (0 - 16) into hex
2 I N6 H1 ~ B1 a$ K1 Bfunction enHex(aDigit)( F: f0 }* C# `0 @. |! J$ O
{
" U/ W) L8 I& i3 {4 t6 |/ e+ { return("0123456789ABCDEF".substring(aDigit, aDigit+1))& d; p( |) ^1 c7 ?! b. R
}
: V/ q, E5 n+ l5 B5 ^// convert a hex digit into decimal
% }6 v& G: l3 N; Kfunction deHex(aDigit)+ F6 p7 h& k& c! W+ b
{- K( ~4 K$ `! e
return("0123456789ABCDEF".indexOf(aDigit))" P9 l8 A3 H+ Q0 ]. A# e
}
& [; L& a/ z6 ^/ S- \
% |( ^1 D) i/ g- u// Convert a 24bit number to hex
8 ^1 Z$ Y% G4 _ z& Bfunction toHex(n)
; Y' e+ m% q$ s* i{; V% x# O W/ G( h f2 d
return (enHex((0xf00000 & n) >> 20) +
$ _% D- P' B/ p2 H+ z enHex((0x0f0000 & n) >> 16) +3 h7 }& V+ f5 K
enHex((0x00f000 & n) >> 12) +
4 w0 }4 B. l/ o7 Z enHex((0x000f00 & n) >> 8) +/ V1 ?6 k4 {6 J; a/ i5 ]' p! ]0 [! v
enHex((0x0000f0 & n) >> 4) +
; e! V# S7 U( Z, j$ ^# H6 U enHex((0x00000f & n) >> 0))
0 {1 E4 j! H. F}
- ]. s' p# l6 B5 r4 Y/ V// Convert a six character hex to decimal
4 V0 ]3 l# V/ X9 J6 e: e& W; ifunction toDecimal(hexNum)) I( g- j" }$ ]2 b. L
{$ c' l9 K# p- t
var tmp = ""+hexNum.toUpperCase()8 _$ l0 Q4 o, V3 i
while (tmp.length < 6) tmp = "0"+tmp
0 U$ F9 e9 H7 E% [ return ((deHex(tmp.substring(0,1)) << 20) +* b/ G3 L9 v3 M, B1 [, |) Y
(deHex(tmp.substring(1,2)) << 16) +
' W/ s& r% y0 m5 t3 v* _ (deHex(tmp.substring(2,3)) << 12) +; i' T( c* w; X& s, o' u
(deHex(tmp.substring(3,4)) << 8) +; T6 |/ Z# m* V: T
(deHex(tmp.substring(4,5)) << 4) +
# U6 T, U( |3 t) W5 \) d4 g (deHex(tmp.substring(5,6))))8 C$ V9 t# V( j& D* E: |
}
$ ~5 f+ ]) o2 e///////////////////Shimmering Links/////////////////////
$ b$ t) t2 O+ N" b) j6 W7 ]- x//global variables1 O8 n; e7 J; A& o" R
var hoverColour
/ [2 s2 V% k4 u) z/ D, Hvar numLinks;* }* z" X. N' o
var rate;
- b" {% d2 e; c7 cvar numFadeLevels;
/ Q3 e# ?) x) }* U% wvar bgR;
3 T" e. Z5 J2 ?* e, x H, A% B+ mvar bgG;
. n; T( H! k V l' c1 R7 Yvar bgB;( H, y9 o0 P5 |8 b
var currR;: M3 f) J& C4 v& r
var currG;
6 O8 _" O' G) c4 \5 \0 qvar currB;
7 @1 \4 @2 }1 N8 [var count;
' c4 B' F! J8 Lvar fadeOut;
& A5 c1 w. p) L0 O! zvar continuous;
4 v2 Q+ ~" u1 G5 M9 mvar newColour;# Z$ U6 n+ o1 j* _
var tID;* a1 |! X8 s; b- F
var redInterval;
) P- f9 L; n* g8 v) hvar greenInterval;
2 r4 z* [5 e; J& m, v% B7 t! b0 Zvar blueInterval;
7 T/ T$ ?! Z; Q8 k3 [function initLinks(mouseOverColour, numberOfLinks, fadeOutColour)
4 l! [7 T! ^6 v, A. c{9 C v4 F* T7 U! m
hoverColour = mouseOverColour;
5 i: c# o5 M0 R1 F: _0 ~: p) } numLinks = numberOfLinks;
% [, {3 C/ ~2 C! S+ E rate = 1;
9 [( s- P4 p( n) ^5 u numFadeLevels = 30;
, M9 ^7 m: j3 p function initArray(theArray, length, val)5 T& [6 ` p5 H& Q) a$ z
{
+ A2 Q+ [' H9 I$ D: E8 h3 ^ for(i=0;i<length;i++)& Z) u' J8 Y& I4 ?5 s8 e
{
6 |- c2 E @3 _. @, J theArray = val;
! I9 z. Y1 r' `+ E1 _ }
- \2 g6 R; O; S- j7 s8 t }
/ x9 p/ O4 c, m+ S% l# ` bgR = '0000' + fadeOutColour.substring(1,3)
% M n2 y* x" x' V0 r. _; v bgG = '0000' + fadeOutColour.substring(3,5): l! b0 `: k. L2 X6 }! z" V) v: U
bgB = '0000' + fadeOutColour.substring(5,7)
, V( k7 C" \/ n0 v5 E currR = new Array(numLinks);$ `; e3 V/ |0 D3 r
currG = new Array(numLinks);
7 N6 l7 B9 @2 b8 O. d currB = new Array(numLinks);7 ?8 S& M9 |5 C2 q% \' K" Z
count = new Array(numLinks);
& H1 r1 c, \6 p8 L7 t fadeOut = new Array(numLinks);" T: c; u* n/ A; P6 ~+ x5 J
continuous = new Array(numLinks);
1 M. Q$ C1 a( s8 ~2 \% E newColour = new Array(numLinks);# q: d( J) V3 i2 y5 i: u4 {
tID = new Array(numLinks);* Z1 M8 _( }: f) C+ H- p
redInterval = toDecimal(bgR) / numFadeLevels;
% v+ {; c7 L- E9 Q& B greenInterval = toDecimal(bgG) / numFadeLevels;
$ M: H; {: t: p* P+ j blueInterval = toDecimal(bgB) / numFadeLevels;
; W; s& j9 ^7 ]$ B( X initArray(currR,numLinks,0);
( \% M' }4 q* g! `) x initArray(currG,numLinks,0);
+ Y$ G3 O: h3 r4 c8 c2 U4 {5 _ initArray(currB,numLinks,0);, F( o& @) c) H0 H& [
initArray(count,numLinks,0);
* F" x# y6 R8 g initArray(fadeOut,numLinks,true);
, Q# P- y$ \# i initArray(continuous,numLinks,true);. ]+ K6 O9 N8 [4 }7 Q
} 9 l1 }3 `. l" f2 a8 w1 g3 _
function startFade(id)5 g3 C& q! r; w6 N+ E
{; o3 X' ^9 |) u, d$ X# S. X3 v3 a8 i: s
if(fadeOut[id] == true)1 \8 R# b% n3 M- P" Z0 [: b
{ /*move colour towards background colour (increment)*/
* d+ J& T" p8 M3 o& y8 @0 } currR[id] += redInterval;
) h8 ^6 q# G5 l% R5 v/ V currG[id] += greenInterval;
. T+ i) D8 K' C/ q2 s. B% q5 N8 | currB[id] += blueInterval;6 o- X( l$ `: G" {0 _9 E1 S
newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);/ d2 n4 _4 z- d8 g" z% b% g
if(++count[id] == numFadeLevels)
' X `' R6 K2 \! `( a i; r {
2 y- y# b2 G3 c3 \ K4 D fadeOut[id] = false;
3 M8 U* T% k# Q: O4 F; U& ~ }) K; T. i) u2 J) B$ B, `1 Q4 v9 S
}4 f% I2 ^. y8 N
else; w$ S, f" a/ f5 k" D: } x3 `
{
0 v/ I: b+ p$ V9 d8 Y currR[id] -= redInterval;
: |6 W3 S$ b8 u) u6 C2 u' O6 G1 s; O6 G5 l+ f
currG[id] -= greenInterval;7 w- K4 P4 |* x& [
2 g+ Q+ Z( V; n* F4 Q
currB[id] -= blueInterval;! J0 n; T: ^* m3 r% U6 s
: U+ m4 ?4 o/ W# R# h+ P
newColour[id] = '#' + (toHex(currR[id])).substring(4,6) + (toHex(currG[id])).substring(4,6) + (toHex(currB[id])).substring(4,6);
- j2 a( S; S. A$ O; H
3 P3 R; c# H* [# F1 [ if(--count[id] == 0)6 b7 g6 g$ g$ @* Q J4 R# S% d
3 \2 O& t+ {* F7 t
{* j4 @+ w* ]' T1 c. ^! y4 r
q6 ^4 a6 [9 ]9 p8 |, m
fadeOut[id] = true;1 f3 P* D; Y+ P
! o, Z; x1 y% H
}
; T6 a- \9 A8 y8 M* K+ X/ x: k) M. I% L( S4 h9 g
}
b: D }8 |9 }' J$ e9 U; i" y# G: m0 C" e
if(continuous[id] == true)% j* ^* m) R" K7 [
+ F v; @ O& \- _
{
, t9 x. t6 d- t5 b' D7 T
! J+ g2 |3 d# I% _) w! A document.getElementById(id).style.color = newColour[id]; $ F# O2 h; Z5 P w9 j" L
2 D1 N7 ~& a$ r8 {- @+ b1 Z }
0 G; @/ j1 |. O9 a; X$ Y* \2 l! n4 j2 n/ N
else
& M2 C% J/ q0 M) I2 f% O" T' v+ j8 B+ t- g' D! V. j
{
$ `: a- w& |1 a7 p+ O3 G, b2 \; R( G0 o8 a9 P- b5 ^# Z0 P
document.getElementById(id).style.color = hoverColour;3 Q! Z- E1 s& a5 z0 y# F. _+ @/ m) o
6 M' z+ H% L) }3 \4 j5 i! W
}8 z$ T0 Z) Y; R% O" _8 H
0 @# e: Q/ v" T+ p" O- Z% Q: g1 Y clearTimeout(tID[id]);
, \5 V/ G' x3 N& S# V
( P# I6 n" m& A tID[id]=setTimeout('startFade(' + id + ')', rate);0 h3 f$ O' M9 l5 E0 M/ a
) t2 Y9 J8 K) T* j
}/ `; G, l* @$ r+ X% R& A& L
5 y% @: l: |5 n8 G: i9 n, o# _function continueFade(id)
% i' N" c; |( h: V$ V
6 x1 h" C9 p2 y{3 `; _' T# q _
: z# R8 `3 K6 B- Q continuous[id] = true;
. y" l3 l$ }; K* J9 E6 M
3 P; a4 F* t1 l1 f1 Y: W9 C}' y, Q' X, m0 }" B) {8 J( B& V
- ~2 g" w q" ~' l3 W0 D7 t: nfunction stopFade(id)
! S9 O3 y ]! Q0 Y. q, a8 _* u
2 h+ q& C' m9 `" v) Y5 S{6 E+ n/ t0 J: [8 T9 j. ~4 a
1 r4 o7 ^% _4 s3 z( ?" P continuous[id] = false;
0 O; h. F2 c9 V+ \$ U# w- O: m v( o
}+ c2 N) G" n! ?& b( b, k8 y8 t
) y7 Q, l [8 A8 Zfunction StartTimers()
* N p9 R) |9 @/ w' c; W' T. V9 H1 p
{ //set up an initial set of timers to start the shimmering effect
) V8 \# a: U E% m3 t& b% F$ E0 F
3 [, ^" }+ M, ^ for(id=0; id<numLinks; id++)
" o, T* A3 y, i' m5 A! ^- |
8 t1 B# a7 f9 _+ | {% x! U i7 r& I
* R& `6 g4 e6 Q1 L! p9 n t=setTimeout('startFade(' + id + ')', id*100);# g6 l* _4 _+ d/ a! m- E3 A
# V/ W9 u# J. a W2 A }. b' C9 Y8 Y) g4 m6 v2 y
8 d A8 {: b0 R8 T}! m; A4 c- K, G& E8 y/ N9 a/ H
, n k5 C2 b" z) R7 W
//format = initLinks('mouse-over colour', 'number of links', 'fade-out colour')( g1 z( D' ^# A% ^. d
7 R+ b z! X$ b9 W# P
initLinks('#FF0000', 6, '#FFCC77');9 L. q% f8 ~4 K8 a
' ~3 o" k) S7 N+ b' N//-->+ r& }/ S; @3 ]2 }, h
- _2 b4 _ c1 B3 w4 v4 B/ [</script>% ]1 f( v B1 `0 u2 \
<a class="links" id="0" onmouseover="stopFade('0');" onmouseout="continueFade('0');" href="http://7wind.com/">国际域名:58元
1 }( |; }/ u7 |8 F) l1 I+ B</a>
/ h6 l e% K" J" _& }1 i4 F<br>
* U3 M$ c$ l* w- k0 _" B<a class="links" id="1" onmouseover="stopFade('1');" onmouseout="continueFade('1');" href="http://7wind.net/">国内域名:110元</a>5 A- I0 Z* X/ }/ s. G: j Y+ j( r4 W9 p
<br>
j5 z8 z2 i$ `$ W3 v: O<a class="links" id="2" onmouseover="stopFade('2');" onmouseout="continueFade('2');" href="http://7wind.net">新一代企业信息系统</a>7 `: K9 T, d5 o4 n7 V, i
<br>
( X/ e# ~, N) \" G. u<a class="links" id="3" onmouseover="stopFade('3');" onmouseout="continueFade('3');" href="http://7wind.net">新一代网络商城</a>
5 E9 v/ k1 I: ~) i/ f<br>
- l! ]9 V& E4 ?' y. y<a class="links" id="4" onmouseover="stopFade('4');" onmouseout="continueFade('4');" href="http://7wind.com/">全新的自助建站方式</a>
3 R3 i' T$ Z2 d<br>. g/ h' R* i9 w' a
<a class="links" id="5" onmouseover="stopFade('5');" onmouseout="continueFade('5');" href="http://www.webdevelopersjournal.com/">全新的设计理念</a>
9 b" K( a3 r5 {0 h; ~8 }/ l. r<script language="javascript" type="text/javascript">1 P/ H! q* g4 @4 J/ L0 O2 v( j: {
<!--, s6 D" |' f6 d' _
setTimeout('StartTimers()', 1000); //initial 1 second delay to allow page to load and ensure smooth shimmering
4 b! l* U2 J% R' B. z- @6 E//-->- ?9 S8 E m5 l, O8 B( t, b
</script> |
|