标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
8 T+ \: J" }- \2 @, C6 ~6 @
var marqueewidth=300
$ b( W- ~7 N: y% E2 R
//高度
% S/ \( {% g: B2 A$ K2 l, f
var marqueeheight=25
: ?* A% T( e' Z3 Y( Z. U
//速度(1-10)
4 w- G) G7 F- y% r7 x
var marqueespeed=3
' Z& A! Z: M/ m/ T8 \) Q& f
//背景颜色
0 K J0 a5 o8 r( G7 Z( B
var marqueebgcolor="#FFFFFF"
7 w5 M0 a4 t1 @5 a
//是否能暂停 (0=no. 1=yes)?
e3 X9 I3 L e0 V, J* y4 ^
var pauseit=1
; W1 N7 [( F% ]/ h
1 ^- R5 R9 J" ]
//修改显示内容
/ t1 @5 G, f" f" @. X( a
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
7 Z. C! }* Y" \5 P
, m' Y U) x" @3 b# l$ w1 ]7 f* ^
8 U5 B9 p- w$ Q, l) }& k
////下面不需改变////////////
: R O4 D* c' e7 t$ {# ]
% x+ G/ v1 o7 b- O
var copyspeed=marqueespeed
" x% T6 }" j2 B! I/ w
var pausespeed=(pauseit==0)? copyspeed: 0
" V3 r! v1 |9 o+ p7 h
var iedom=document.all||document.getElementById
( A& P, p6 F( ~( d7 I
if (iedom)
# N7 p5 C& _- t1 r+ f8 W" y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
% E) P+ S2 U1 R
var actualwidth=''
# U; T V3 ]5 X: e# }
var cross_marquee, ns_marquee
' f8 Z$ K! G8 Q
9 H, ^0 N7 w% p
function populate(){
# L+ `+ E3 k0 E
if (iedom){
1 G7 ] ~+ @; V8 [2 f5 m2 \
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 ?0 M; y& O. O3 Y B, T2 U9 }. B8 X
cross_marquee.style.left=marqueewidth+8
& S7 I+ R, M9 V1 m" q7 c
cross_marquee.innerHTML=marqueecontent
/ D" a. g/ `, M8 R! j1 r. W
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
, v" H8 e! C6 `
}
( l4 n8 `: c7 m4 K9 a2 o. p
else if (document.layers){
8 }5 L( ?5 k" p* B& w# ~
ns_marquee=document.ns_marquee.document.ns_marquee2
' J8 t2 C5 I. y) U
ns_marquee.left=marqueewidth+8
5 j' m0 O# d0 ^: u& Z
ns_marquee.document.write(marqueecontent)
5 e5 @! l4 T: j
ns_marquee.document.close()
o* q2 @2 i9 k0 a
actualwidth=ns_marquee.document.width
8 {* O. D4 J0 D6 I
}
- Q3 A% [5 n/ Z+ J0 C
lefttime=setInterval("scrollmarquee()",20)
5 D' E1 O6 d7 k( A5 R
}
; }* O" s0 Z! r
window.onload=populate
% D- h$ A: d" ?2 L: b: B/ C! Q& }
1 r. }; _+ p; m, n
function scrollmarquee(){
$ r7 }& ^- a3 W# o
if (iedom){
9 k: u# ?3 c% h$ ?
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 d+ w) ~5 r* a$ J* K
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
! m b% J& x6 ~* ?
else
- o5 D# o/ T" W, j b# s4 x
cross_marquee.style.left=marqueewidth+8
) z& y2 w; b0 S0 D- A
# g) i/ j) [" s8 ^" G
}
/ z8 E ~; w2 l" o/ X: Q" W
else if (document.layers){
9 N2 [# f# d- H9 Z6 O7 U4 z
if (ns_marquee.left>(actualwidth*(-1)+8))
! \5 @$ j d& e
ns_marquee.left-=copyspeed
- E# [/ S5 @& G
else
k H# N; E2 t; P: F7 W$ Q6 Y
ns_marquee.left=marqueewidth+8
# d1 a x0 g: Q& L6 \4 i/ B
}
5 Q0 ]' Y3 _- G0 s2 c m
}
3 B7 O Q" |" {9 k
/ }; P) `# h5 Y& o% i
if (iedom||document.layers){
8 t: Z" b5 Z' o! _3 o
with (document){
) R+ M3 K, G: ^, {, G- e4 @
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' F0 y7 E1 T. R5 U; H5 N
if (iedom){
' S1 |2 [( U1 J- h
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 \7 k4 S& p2 n
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
( J1 x4 ~3 H6 b. w, H7 B
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
) c7 N# x# @9 a3 t1 I8 r
write('</div>')
1 f( o$ m3 D3 Q: \- h6 P+ r
}
1 S% l0 F$ c; n$ R9 t* ~
else if (document.layers){
/ W! j- J8 ^( P: H2 q$ u o
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
( N1 z# Y& U8 D( K! ~4 M! x- X
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 Z9 @) M4 m/ n1 s2 u
write('</ilayer>')
; n% D3 s! U: f) ?8 ?
}
. \0 q* m( x& P5 ~5 ?, s) s
document.write('</td></table>')
. G( @% p! Z1 v4 c) n3 B6 h
}
2 W$ G5 l2 C* p/ \4 H$ H
}
4 L$ `9 u- c: X T$ V$ U
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2