标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
$ D3 v. M/ N, L8 U: z2 W+ c, M
var marqueewidth=300
# p" X+ F/ k9 |
//高度
5 M: P! F7 n* I# b+ I) p% P8 X
var marqueeheight=25
+ D) j+ g& E* S$ p1 j
//速度(1-10)
9 n- |- K6 e! e! c" I" B
var marqueespeed=3
n* `- p$ P% @/ y% ?, R
//背景颜色
+ H1 h, R# J9 S; y W7 ?
var marqueebgcolor="#FFFFFF"
/ H8 E1 h; _7 l3 i: [7 ^3 ^
//是否能暂停 (0=no. 1=yes)?
8 G- k1 U- H# A
var pauseit=1
4 L4 W5 b' {$ `+ t
- J) N1 n1 K+ t% P1 g+ _
//修改显示内容
4 b; k2 ?2 P" F+ K9 D
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ `( q5 n- c! E3 x7 p' s
3 P. M2 s; N. B. h7 m2 F8 |
+ O! @% V' ^) w/ Q7 o8 `
////下面不需改变////////////
+ A' v6 X+ ^5 W( O* J
) U8 Q% _& `7 {. p. i& I3 y
var copyspeed=marqueespeed
5 K5 F: H5 M; C3 ?% s! [
var pausespeed=(pauseit==0)? copyspeed: 0
5 D* Y3 n. k, T7 \" g
var iedom=document.all||document.getElementById
. q4 P; m- \7 G) q' C, o
if (iedom)
- w8 r w9 T6 B4 l2 g9 h4 o2 U6 k
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
( K& ?, L. p8 Z" k/ `
var actualwidth=''
! T& ~& H# c/ W' O! Y4 Q' O
var cross_marquee, ns_marquee
4 @/ w3 v. p @$ W0 W
~- o6 K" Q& R2 x2 x6 A0 ^
function populate(){
& D, D& ^. _" i7 h2 y; c7 a# w5 m
if (iedom){
& ~2 [$ l+ Z- n% _" A
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
2 n6 n3 a$ }8 g+ |. E
cross_marquee.style.left=marqueewidth+8
) m [: ]6 }/ w L, h. T
cross_marquee.innerHTML=marqueecontent
9 K/ a9 w2 K7 L! g. F: P
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
8 s/ O: D8 t7 m- y
}
) S' P; I5 J% e# k H$ F
else if (document.layers){
- d9 v4 ^5 I$ |3 S# L5 f
ns_marquee=document.ns_marquee.document.ns_marquee2
$ x! o. Y8 v% v `
ns_marquee.left=marqueewidth+8
; ~& I3 g! y m# B- f
ns_marquee.document.write(marqueecontent)
$ B0 W4 U8 ]( q U7 d
ns_marquee.document.close()
% g: |# X& `! n; o& C {4 i4 }! ]
actualwidth=ns_marquee.document.width
8 I, r( b( r& M9 w8 t+ W
}
. l& n3 _1 d* P: G
lefttime=setInterval("scrollmarquee()",20)
! F) m4 h2 b$ J2 G9 t- n# ]
}
- g/ N7 ^( X0 t
window.onload=populate
: R7 J) X" j* \- u# R
R9 `9 ~) n; X8 y2 g
function scrollmarquee(){
8 }2 `, u* C8 r# M) n4 i+ i
if (iedom){
( @. P! i/ Q A O5 b5 T3 _) h
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 w# Y$ K( J$ m: s" H( ] K
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
4 j c! q" Y% C6 @; M
else
; V F$ l/ E" J
cross_marquee.style.left=marqueewidth+8
' k# c! b) g9 H! B: b( ^
9 V! \; Q+ t/ j( a5 Z( y
}
2 J* Y( \0 O" ~ f
else if (document.layers){
) q; B" b& S! L# n- p8 {
if (ns_marquee.left>(actualwidth*(-1)+8))
" D6 n/ f8 e) B' S
ns_marquee.left-=copyspeed
- h$ g' h) Z* K( f1 ]) z' b# ^
else
8 O9 k5 b& x+ N4 t" F( l) Z: h
ns_marquee.left=marqueewidth+8
6 W' z) t7 x2 t1 l1 D
}
& h0 ^* b% y+ l! H O \
}
: L: `7 H) i C. K; {
7 X. u( Y8 k1 ]7 i0 O
if (iedom||document.layers){
0 r$ q* Q6 P8 a- S
with (document){
, i3 q2 s# ^# u2 i
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
. r% J6 m" q! l, s: i. [
if (iedom){
8 j; j3 u( w5 p8 J9 S* O
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. k/ \& f6 o4 D; k _
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
3 d$ O2 B l$ [' }$ r: K$ W
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
0 P' [7 ]' C/ E$ n5 @2 d$ L
write('</div>')
! t7 r6 A X. x# _- w
}
- m7 a; U; R, r, d
else if (document.layers){
$ V: S. b+ Q) h
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 X5 h/ t1 R2 q0 m9 y( H
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
7 D2 P3 f# q Q1 n
write('</ilayer>')
1 e4 O$ |7 _% L- I
}
# ~+ b: [) U0 n7 S6 V- }
document.write('</td></table>')
. ~6 \( k# F9 G+ _! v& T
}
" W. [& t5 V0 x
}
) D( G! G& w% X2 M/ w4 ]
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2