标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
" m$ ]7 X& C& E1 J/ C
var marqueewidth=300
" W. ^2 r4 v7 ~' Z/ U
//高度
! `7 X' Q: Y- Q2 |5 I
var marqueeheight=25
0 v# h8 d/ f: U; p" i
//速度(1-10)
4 T" y0 k/ X( `0 a5 P; k) h' s
var marqueespeed=3
& U( t5 P8 D! h6 _/ v
//背景颜色
$ ~' X1 J4 T3 p# I3 V! d
var marqueebgcolor="#FFFFFF"
/ g( o- Z, n' @! [& d. A) v1 N
//是否能暂停 (0=no. 1=yes)?
" E8 }; W# F, v4 I% X3 p
var pauseit=1
' x; k7 C, A7 L; x! t
; h+ a9 i1 d& H% c! W, e8 L
//修改显示内容
0 ^4 A; h5 h) A% Q! |
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 L- [4 E% c& U- E
7 M+ [$ h, R" L7 v7 R
$ Z- y' T9 V0 M& v) ~8 S
////下面不需改变////////////
& Z8 S- v( a- j R2 o- j$ z
6 c0 a/ M" c, A& O! p
var copyspeed=marqueespeed
% a6 j% R2 W; P$ w& B6 C% a0 T
var pausespeed=(pauseit==0)? copyspeed: 0
: N" O# T+ ]4 A
var iedom=document.all||document.getElementById
" Y, y+ x ~! i: g
if (iedom)
" C2 s$ b) i, B& V/ j
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
( [# f. v6 Y4 {# j6 e: G
var actualwidth=''
6 ?# W$ |6 w7 `' g3 t
var cross_marquee, ns_marquee
2 @, A7 I1 T, n$ `6 J
( {5 |1 n# [) f+ R# F
function populate(){
9 h' m. A" j* c
if (iedom){
, w. h$ T! ^3 S9 K; |' o" |' k: \
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! q, q* Q0 e. }/ I# j* W
cross_marquee.style.left=marqueewidth+8
; k; W) @% O! E5 P- B1 ?1 i, N; E
cross_marquee.innerHTML=marqueecontent
5 J+ Q0 |, H2 J- I1 y( e* R* g* ^
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
g* E# X9 c0 c+ Q, W
}
8 d1 a1 Q& I; k3 F( i1 f6 Q
else if (document.layers){
1 B, H. W) f o$ I7 V
ns_marquee=document.ns_marquee.document.ns_marquee2
3 _& S7 y# A* \) e' ^
ns_marquee.left=marqueewidth+8
$ @( f. _: ?) k2 I2 K# |3 P# t
ns_marquee.document.write(marqueecontent)
7 j" b ]' M7 M2 L# O4 o1 ~6 _
ns_marquee.document.close()
. C2 X2 y* @1 @/ j% P. ?5 H6 Q
actualwidth=ns_marquee.document.width
8 q" j, a$ \3 s3 P
}
3 M5 s. w0 g$ L5 Q" r, c3 v3 {. y! D
lefttime=setInterval("scrollmarquee()",20)
: t+ I7 @; P1 j5 s0 ~1 N
}
# k/ u1 \+ T; e# x/ q
window.onload=populate
$ ]* f/ G; G) C3 o( s3 W2 z
3 E! f8 V: n& k" ~" z" h8 M4 r* ]8 G, c
function scrollmarquee(){
+ I, A& V& E3 {1 H
if (iedom){
3 I* l4 X$ d0 j0 z' z/ i8 q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 B' r+ ^7 r* ?& @
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
8 y$ r& A* L# P1 j6 d6 E
else
9 d& P3 t/ V6 L
cross_marquee.style.left=marqueewidth+8
4 F ?6 ]% B+ r
7 A4 }/ R+ K- p: J6 j
}
" h& U1 i0 C) R+ B/ K
else if (document.layers){
% C! Q* K* d0 N% O
if (ns_marquee.left>(actualwidth*(-1)+8))
y U5 M$ U& ]& b- r4 Z8 [" O
ns_marquee.left-=copyspeed
) d5 i# |4 ?. K c q, {
else
/ G6 |2 z' c' l R5 {0 G
ns_marquee.left=marqueewidth+8
+ p2 A1 y% E, o7 i: D D
}
& j4 V; A, Z3 ^2 {
}
7 q8 N4 _# a1 {% s% Q1 m
3 d! l& k" v1 N) f% X9 T5 y
if (iedom||document.layers){
& ?* O7 ~7 j* ? y; P- h
with (document){
r# z' G" ?" @2 W% O7 |' F
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 W+ l: `% W0 b$ G
if (iedom){
% k! @: T) b" `) h9 D/ h
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
8 {0 k& i$ a: M2 V9 ^1 V" s
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
1 S8 Q) Y- S- ^5 ^) ]" k+ L
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
0 v; C( [2 s4 f# t" A* p' q
write('</div>')
. C. O# E7 f; U0 R
}
& _; T( x2 _7 M7 g8 }
else if (document.layers){
0 c3 C8 F9 U% F c
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
7 k* f3 s3 x7 s
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 `0 w, e4 H5 A2 i# Y9 |/ S; W5 b
write('</ilayer>')
2 C, y# F' O6 |- d) f
}
+ S6 @7 i0 @+ `3 u' n, E" L7 A: h
document.write('</td></table>')
+ Y+ |! R9 q+ g M7 u; _2 X2 f1 h
}
& k' e" A+ F+ h* ^, n0 P" G; N. @, `
}
0 A- R9 E0 P, F- Z# j9 b4 i+ o
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2