标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
6 R% J" A* ~- c' ] J3 h
var marqueewidth=300
8 K1 N& a6 o0 G8 T1 }- K7 \
//高度
6 b9 Y4 e/ `6 r( J, S0 T: X
var marqueeheight=25
8 V, m- F' v; C% t* s* i1 C
//速度(1-10)
; T* ~+ g6 b3 L t
var marqueespeed=3
2 q1 w3 O1 ^# G5 j6 C. M# T
//背景颜色
9 Y8 L. N( N- P" D+ c, J* `
var marqueebgcolor="#FFFFFF"
& o# W' e- i3 w. ] G
//是否能暂停 (0=no. 1=yes)?
& E% k! f: ~/ ~* r- C# x
var pauseit=1
0 a" l$ ~ k; l* k6 p$ i/ D3 W7 Y
& F, G( e9 l, m. s# N. f
//修改显示内容
! b+ b; W. _" p# o0 R$ `
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
) j% P, E1 [0 Q* c j
; i) j! W+ Z, k+ T: _: N1 [
4 ]# T' }; ~' h: e" q
////下面不需改变////////////
7 T& ]/ q& z" i9 E# G
% S! N- X) f/ |4 O. X3 I% ]4 S
var copyspeed=marqueespeed
4 ]. k3 M) H3 j& p
var pausespeed=(pauseit==0)? copyspeed: 0
2 X: T2 x+ i3 }! B8 U
var iedom=document.all||document.getElementById
$ K+ m6 N9 s& Z7 I
if (iedom)
" C0 `4 N m" X0 v- T6 f% w* J
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
7 T1 I- }6 A6 }" z' Q
var actualwidth=''
, i, v# a# j7 S: P0 @- h- y, X# l
var cross_marquee, ns_marquee
$ e# L( i" Q h" i( c$ B. n' a
- R; Q" r! o. L! ?$ ^, v" c/ r+ w
function populate(){
w. b! I8 g: k* R. D
if (iedom){
9 r# Q0 L5 J" ?7 X# M1 E
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
" ~/ ^6 x, i" s4 V6 h) Y( L
cross_marquee.style.left=marqueewidth+8
' Y4 Q0 E/ ^$ w6 O: l6 x
cross_marquee.innerHTML=marqueecontent
" V7 ?7 O3 Y# k6 W7 z5 ^3 u& `
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
9 O: S9 j: ~1 R, Q' k
}
- ?4 G# M$ t# O/ x8 W) \
else if (document.layers){
# ?7 Z0 t; |7 q0 }( J" ?
ns_marquee=document.ns_marquee.document.ns_marquee2
6 a. R* l' ^: {6 x
ns_marquee.left=marqueewidth+8
2 H+ s3 _+ m, o9 ^: Y
ns_marquee.document.write(marqueecontent)
/ |' I% t$ h) U2 I8 h
ns_marquee.document.close()
# j1 `' Z$ R# L' }2 }
actualwidth=ns_marquee.document.width
& Q6 ]& x$ H! a0 A6 w% g* W7 A2 _
}
3 \0 Y7 k. R$ N1 ^
lefttime=setInterval("scrollmarquee()",20)
8 P1 a, I! [% n4 T& e' y$ @1 R
}
( i: l" n& d2 R( \% w2 n
window.onload=populate
3 a" f: Q& i! C( y- ?# s) e6 ~
2 Y2 n2 k+ \8 B9 P
function scrollmarquee(){
3 _6 v* u+ a# V1 t% {6 G! z
if (iedom){
0 g. k- x( Y+ L) u6 ]
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
/ f0 _; b+ i) `! e
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
7 @: p- g. {# V5 q
else
5 C+ g7 |; Z9 T X, g
cross_marquee.style.left=marqueewidth+8
% w# ^1 f: Y B( ?9 a5 o- V
( q) ~& W5 t% k: n$ C) l
}
4 n6 z1 H, n- R) v
else if (document.layers){
4 k3 r* W, i; q2 A5 f5 [" E7 \" S) O
if (ns_marquee.left>(actualwidth*(-1)+8))
, I9 b5 A0 ~( d" @1 t4 ]
ns_marquee.left-=copyspeed
- k) X1 D0 g& Z3 V" @
else
9 n8 F0 S4 h8 W. ^3 T* I$ g
ns_marquee.left=marqueewidth+8
) ?+ S% b. n0 b7 H6 n& e8 z- O
}
% o' V& u) g; Y2 ]
}
% x- L4 U; K3 e* o
$ b. ?2 A7 v- v& x
if (iedom||document.layers){
0 Q/ O3 g9 f) k5 \! g
with (document){
. j. ]6 _" t: v9 [# Y( x5 h3 Y, C
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
; |: \1 i* p) s% Z' W/ ]+ ~
if (iedom){
X4 \) T; w% k3 a
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. X' p- { H2 ]% ]0 {6 o5 o
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% d9 u1 ^9 A4 F* |8 t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" G. t" n: N7 p# ~% q" U
write('</div>')
& D* ]* {/ d& P7 l
}
, ~( O/ C3 A7 W; H) D" L
else if (document.layers){
9 I* a2 Z4 @. |. S! m T
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
s* ?: t* G4 H2 C& R
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 a! I) R# j. T& E2 B' U* _% G1 U% F
write('</ilayer>')
& z& p6 v/ l1 Q
}
8 O3 Y) i( z" |
document.write('</td></table>')
5 a. M* b) U3 b/ R
}
; n# @( M6 n% w) @" ^
}
( K' W" r' n; L4 A( w
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2