标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
, o: g+ _. C( Y( U6 H* e
var marqueewidth=300
$ `1 I& g& j& e+ |! W% y
//高度
) | {6 E; s) [) j1 C9 o
var marqueeheight=25
w: q& q+ L- F }7 Z3 F0 ]& W
//速度(1-10)
, o: ?/ k6 ~7 l; _0 d0 G
var marqueespeed=3
! u$ C3 C* }# v* Q
//背景颜色
+ `: s) _9 P' [& E& ^& j
var marqueebgcolor="#FFFFFF"
5 N; {; |* w) S- x5 _
//是否能暂停 (0=no. 1=yes)?
8 D2 ~1 r& A6 r t
var pauseit=1
; o& P+ Y. M, y+ W
% T; N) s- w2 y' s/ X& h
//修改显示内容
& W6 S7 B8 v) x6 f& |, @" j
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
- O2 Q I \# C' m
; j* a4 [, P r( [0 T
" E' h9 }! b. o F5 E. N& _6 ~7 O
////下面不需改变////////////
0 ~; U' c" C1 Z6 b! ]
+ I- h: ]7 L9 c" J
var copyspeed=marqueespeed
3 }! e J/ h- R+ ~
var pausespeed=(pauseit==0)? copyspeed: 0
, H4 V$ W8 o8 }& k+ H
var iedom=document.all||document.getElementById
. I5 Q) a! V! p9 F
if (iedom)
& k) r0 d. Z* j- B4 a* G7 G2 ^
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
" r4 i$ [9 _; R+ H* I
var actualwidth=''
h4 L3 f/ {# z3 k9 I
var cross_marquee, ns_marquee
3 n5 l/ q# L) g, C" w, k
9 [( {' k) a% |" j& b
function populate(){
3 o3 T3 p* B$ t4 P5 B
if (iedom){
# i$ J, s& t( ?; Y0 ^, H a
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
" |5 e! N& h& w" |
cross_marquee.style.left=marqueewidth+8
" N! _2 E Y8 O4 L
cross_marquee.innerHTML=marqueecontent
4 W$ p( I% t* I" \
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' g1 P4 a6 K) |! q3 Y8 @" | z
}
% y1 v- d% B' e0 Y! j
else if (document.layers){
3 |) R# e- l u
ns_marquee=document.ns_marquee.document.ns_marquee2
# U# i. A3 z3 w6 O+ u$ C
ns_marquee.left=marqueewidth+8
9 S1 c" c5 N7 h8 f
ns_marquee.document.write(marqueecontent)
* ^7 R2 f3 w7 k" i7 v
ns_marquee.document.close()
" Q4 R* k; X- d0 ~$ B
actualwidth=ns_marquee.document.width
/ M% m) b1 |9 I/ \/ H, p
}
B( f0 r; f8 @5 h9 a% m
lefttime=setInterval("scrollmarquee()",20)
e1 e4 E4 i( b- a& x% A; J4 E- v
}
7 A, O* i1 Y- p; t5 ?' d
window.onload=populate
& ^0 R% \9 G& o; ]& o: L8 I
+ E, k5 ~; {/ o8 B
function scrollmarquee(){
e" `& X* X# K3 [8 k4 |9 ]* _
if (iedom){
! B" R- ^3 w- |2 f2 m8 L
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
5 s1 P# H& L- }& D7 j% l% C/ H
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
7 Y2 `6 |+ j {8 |2 E
else
5 h, c/ G" p0 e1 g& y& _7 H; C* y
cross_marquee.style.left=marqueewidth+8
$ D/ A( {, `7 ?7 h0 p6 f
: y: Q! B/ l' X o
}
3 S8 Y; }: V) z( i3 |0 b. E: e
else if (document.layers){
! P4 ~- z8 B( C8 G- m
if (ns_marquee.left>(actualwidth*(-1)+8))
5 j, Q4 X0 n# ^. a% t( `9 l& d
ns_marquee.left-=copyspeed
; s' X, {# x r" x, F# b
else
- N1 n D( G) \/ i; h
ns_marquee.left=marqueewidth+8
J: q8 K+ r- T- j/ ~
}
M# O1 Q& j1 _/ `
}
/ V; y' P$ {, ? J: l- s5 m0 F5 U# u/ U
! @4 {' Z$ A) z2 }0 J# U' I
if (iedom||document.layers){
K0 z, C/ b! A% U6 f
with (document){
$ c, E$ ]% {) u/ l: f' _5 E
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ p/ A, g, @: m# h; R( G9 z, a' j
if (iedom){
3 H4 m( i6 \: c/ L1 X
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. E0 g4 B. \5 G U8 c! a7 V, Y- y6 g
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. }7 f+ ]9 z! Y2 B$ I" t% m4 x
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* k+ e9 y' R9 h6 O* E% l! Z. Q+ a1 [
write('</div>')
& ?$ f2 U& J u# |& n- J/ x6 p
}
, R/ ~7 V0 |7 |+ T7 z& b
else if (document.layers){
3 A( b2 [1 e+ M, M
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
7 }& F5 H0 J9 Q% n. i
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
- P) A# _- x1 d* L0 o3 P7 s
write('</ilayer>')
M" ^3 i. s+ n# d
}
3 |' k* f" i2 E! q& @) y# f1 {2 D: x5 m
document.write('</td></table>')
, R: J/ Z! b3 p7 \& ?
}
L1 |: l' Q5 B% H5 W3 E
}
( Z; e1 p1 E5 |9 [7 y0 p
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2