标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
) A5 P5 s) T+ ]/ }% \$ z
var marqueewidth=300
; M# v- M- ^2 `9 L: g
//高度
1 k/ j8 O0 o1 ^4 h) M2 ]
var marqueeheight=25
/ a- X; T/ d v! i$ v
//速度(1-10)
: q# `9 W3 a8 P4 L1 o1 v3 p: o
var marqueespeed=3
6 P: A$ C' R# q# n1 C6 n+ u
//背景颜色
! ]# ^4 p: J1 _$ S5 X# N0 ]+ i
var marqueebgcolor="#FFFFFF"
3 v( q. ~$ @% V
//是否能暂停 (0=no. 1=yes)?
j3 o& Z; H. S4 F
var pauseit=1
( c" Z7 f" e9 d$ ~. o
& \! S+ S& O0 y% g H* Q
//修改显示内容
6 S; \8 q1 m/ M7 N5 I. K' [7 w
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
' Y: H& U- i) p$ `5 A; O
! Z/ n; a5 b# Y
* h: f6 J# u9 O( G3 S' t
////下面不需改变////////////
. o$ _8 r) Y6 G
1 O8 L) z$ N! v. i0 [
var copyspeed=marqueespeed
8 R3 W/ H ^9 r+ P* E2 |9 S! F! T2 @
var pausespeed=(pauseit==0)? copyspeed: 0
# f7 B) ~; D% O8 D, o$ H6 }0 z2 p2 A
var iedom=document.all||document.getElementById
% B8 d8 ^3 d! Y
if (iedom)
# Q; X: X0 b- m a2 F! _- W8 f+ U
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
3 \' ?7 t. t0 @ l
var actualwidth=''
- A5 O- L' e3 J
var cross_marquee, ns_marquee
, q" G* G# }, H7 A3 p! ?) S
5 Z8 e) I; T' _/ Q4 N
function populate(){
% S- O8 D# [" q! f& }
if (iedom){
! `% W' b/ V9 y. ^$ p
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 I) k+ N B' D# q6 V X5 {/ ]
cross_marquee.style.left=marqueewidth+8
% @. h/ f: I8 O% g, j/ B- @ e8 J
cross_marquee.innerHTML=marqueecontent
- o+ |4 [. l0 w$ y" T9 p
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 u" R# V3 o# l& @. b4 K3 l/ o
}
* I, \4 w. q# H. L& x6 M4 R
else if (document.layers){
i) O: b1 o' D( Y# u- R- d
ns_marquee=document.ns_marquee.document.ns_marquee2
+ I' c ^; D( t
ns_marquee.left=marqueewidth+8
/ T& P* ]) \ Y8 n4 y _% G+ e A4 y5 v
ns_marquee.document.write(marqueecontent)
# k9 }5 p- y- H# _9 ?; x) a! Y* M" d
ns_marquee.document.close()
- x/ ?; ^" \! q8 }3 m; \
actualwidth=ns_marquee.document.width
$ q0 T* v' A k. i
}
- D/ f, e8 Z/ J" p) }) w
lefttime=setInterval("scrollmarquee()",20)
; Z8 u& L7 \7 p5 s3 v
}
j& Z1 P, |# v/ H
window.onload=populate
& M3 \9 }: k8 x' d8 h, s
! r+ `8 M& r, K5 I! M, a2 f
function scrollmarquee(){
( t! m/ v5 l" Y0 |' e
if (iedom){
: S% V- Q) i: b" T
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 c8 V. q" v$ a+ K
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
* v) x8 i8 a2 `& K! G
else
: {& Y" H, y& F) J
cross_marquee.style.left=marqueewidth+8
% |6 w% i Q0 w. T
1 a. a! [3 I5 I& N8 Z
}
" z/ G& ^; j2 c7 x! c6 c
else if (document.layers){
* A. n) e' H: v) }
if (ns_marquee.left>(actualwidth*(-1)+8))
5 O6 Y+ B1 s5 B: R
ns_marquee.left-=copyspeed
% L" u9 L6 J9 F; b" x0 T
else
( |. h( ` c7 z% J9 Y* o0 G5 [+ n
ns_marquee.left=marqueewidth+8
( ~8 |; }9 F8 E) i. |( Y; Y( J
}
% U8 H% {2 e: y3 M
}
& z% W9 s; b0 K8 P
$ U4 O8 O+ m# D; f1 Q
if (iedom||document.layers){
, r4 {' U: b6 _1 V- r6 O' H
with (document){
v8 L: i4 i8 M2 U6 }
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 K: L6 \9 ^. A8 m& x
if (iedom){
4 o- F/ T# I3 _4 R; p$ @
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
8 f$ r! ^6 P5 h5 B8 f4 O
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
: U/ f% ~/ u; `, t/ \9 {5 n0 t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 d; G2 f# m! M
write('</div>')
; U6 O- R* l% P/ b0 C( v
}
8 y5 }: z f. C P8 }9 v
else if (document.layers){
( U. F6 X+ e4 i* b( N8 r
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
) s/ O; O" M4 a J/ d+ M: ^
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% Z b" f: S& ^6 p
write('</ilayer>')
2 `) Q' h3 B4 Q" Q% I) q
}
, [6 f) B) y3 T9 Q" b1 H
document.write('</td></table>')
9 K; J+ ?- E9 [1 r! j3 w2 H
}
( P8 j$ t0 ?- }# \+ L
}
* e7 k$ H- z9 G7 G" h, n* q- |
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2