标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
# K# D/ ]: O: W- B& W; `# V
var marqueewidth=300
" l" ?. D/ K% z8 z: P+ d1 o
//高度
" i& A% S6 A: C( G+ W' j; A( k3 ]
var marqueeheight=25
0 _: @3 { W( n" U2 U1 t
//速度(1-10)
1 z! k. e+ \5 ~0 P* p
var marqueespeed=3
^; ]/ H& v4 m9 O
//背景颜色
+ d0 c2 I" u% }! P6 [% H' o$ w
var marqueebgcolor="#FFFFFF"
+ C" Y7 ]7 s2 w' H% b! v+ H
//是否能暂停 (0=no. 1=yes)?
6 I0 J: y4 X2 [; I
var pauseit=1
0 A2 \! I v" N _! |. r& G
9 r: E! k3 @8 V W
//修改显示内容
! J' l" L5 B9 p+ I' R4 m
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
' e& l4 }6 |* n* U8 [4 f$ W; u& X5 \% x
2 |8 O G! `& u' Y @: j
, l7 f% Y3 _+ G- G' p* U
////下面不需改变////////////
! I {/ J K# x; f
% F) H1 ~5 d. F* e
var copyspeed=marqueespeed
& C: L6 r6 {, ?# ?; e
var pausespeed=(pauseit==0)? copyspeed: 0
; O( O7 e+ T' J8 G/ L& t: Z7 ?, `: u
var iedom=document.all||document.getElementById
' r2 c3 O5 N0 H- \
if (iedom)
" ?9 K% q5 N- r/ }' h7 Y( l
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) ]0 U0 L" J* _
var actualwidth=''
2 U5 v3 x: U* t/ m% J
var cross_marquee, ns_marquee
' {0 G, i% n- B2 M6 z7 P# G
2 g) d! \+ `1 W% M+ ~0 z; X
function populate(){
* ?9 [% u3 c" u* t7 [9 A( V, e
if (iedom){
8 c2 [$ z4 q, Y8 `' l2 M
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
3 m7 I5 l- [* X6 `# i2 I
cross_marquee.style.left=marqueewidth+8
+ Y' M8 K9 O/ c/ u) V
cross_marquee.innerHTML=marqueecontent
1 A, s8 H1 L, |6 p: s
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! L; h& t, Y& @/ p( o
}
0 C/ V0 z y% j4 [: ] z7 t
else if (document.layers){
# e9 p# t# g+ \, f- z
ns_marquee=document.ns_marquee.document.ns_marquee2
) r1 X+ N; |' Z- d" `$ y
ns_marquee.left=marqueewidth+8
7 Z7 {* L0 f6 W4 j
ns_marquee.document.write(marqueecontent)
: y; [: A5 S% t' q" Z; x5 L- N, T( y
ns_marquee.document.close()
0 d* x( J2 a* y6 P
actualwidth=ns_marquee.document.width
5 c# f. j& g3 o* ?
}
3 N( u( S' ]' a* m+ A
lefttime=setInterval("scrollmarquee()",20)
4 E$ I& Z' B! n- ^2 \2 W% J
}
Y& E! v! F' x& u7 L$ n! J! L3 s
window.onload=populate
- T; ?) \& f$ w
4 K5 ]& o: Q. \8 ?
function scrollmarquee(){
: i* o: j5 b+ U& S6 B$ n( t
if (iedom){
6 a) v+ C7 A; T; \+ {* O
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 T$ T3 ~+ W! f! a+ Z: X6 S
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% y- ~: o6 }, U! o/ ]0 z
else
7 O6 t: k& a6 v# z2 p/ w) ^' Y6 Z
cross_marquee.style.left=marqueewidth+8
9 b) _, [1 s% t9 p( v% J7 E9 B3 I
; t- r# W# _# n' C% G
}
7 {$ m, w# c. |+ i
else if (document.layers){
& L9 s* X1 o/ P
if (ns_marquee.left>(actualwidth*(-1)+8))
9 z$ L/ j# ^8 `# I4 M( H: y
ns_marquee.left-=copyspeed
3 P3 q$ k9 o i' c9 G0 Q$ @
else
6 y; a Q8 H4 P _8 P. O- L
ns_marquee.left=marqueewidth+8
2 X5 U# ^' D% M& R' i
}
! b3 Z( z* b D( C/ u% c; G. N) o) d6 Y1 r
}
! y! u! P( F+ K7 u6 A% X
8 L& w" Y7 O* k
if (iedom||document.layers){
& m& A" k- C* Q) s* o; L1 w
with (document){
9 v1 X: R o0 Q6 O
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- h" H4 R3 p- d& o& i6 E
if (iedom){
1 r6 s) N8 g+ e1 V4 l
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; u' W; W# O1 p9 Z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
w- o) E! G: e3 |
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# H" M( H7 b5 X7 H( k, r
write('</div>')
/ M/ x0 @& |6 Q. E& Y
}
. c4 q2 x y+ T+ Q k% }, m
else if (document.layers){
5 q/ Y( M! E! H4 v9 r0 E% Z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 ]. p3 a& A2 M; }& f
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
) B, ~! a! [0 w+ K8 J$ U+ S
write('</ilayer>')
9 Q1 @- J' Q! O- f- _. c, L- q+ N
}
/ r* N8 e( t+ k! o& B0 f
document.write('</td></table>')
; V- j2 M( [# o/ |! F- U. c
}
$ ~0 [0 K1 g2 R* G& u
}
, o1 |8 O0 d3 N/ S/ \8 G
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2