标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
0 x' C6 T( q' x+ T2 R) o
var marqueewidth=300
# p6 y. C7 V5 @& i2 q
//高度
- u h/ Q) g# s* z8 L. x
var marqueeheight=25
# Y( _) _$ ?* R, }$ H5 u
//速度(1-10)
) g/ F' ~* Y0 @8 U/ \ f& f# r* p* J
var marqueespeed=3
6 ?& C: L3 L( o* N
//背景颜色
0 y7 D% H( X2 J9 I; I6 o" N1 H
var marqueebgcolor="#FFFFFF"
n& R! \8 ^) d. A% m H
//是否能暂停 (0=no. 1=yes)?
( x! b, B; O( F
var pauseit=1
V* F4 ^1 l: w; I1 _" {
9 e K5 D2 X/ u5 |5 X* X
//修改显示内容
8 K* N* ]/ W2 [5 r& f
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
, o1 L/ ~, F4 z4 v
! Q5 z0 k( T6 P, c
% u: s1 {2 H! z, J2 k
////下面不需改变////////////
+ i+ ?' c2 v+ A. g
; x% F, Z8 G0 @( {9 s
var copyspeed=marqueespeed
: f V1 r5 \$ E
var pausespeed=(pauseit==0)? copyspeed: 0
9 f6 G ]- G; x- }) U
var iedom=document.all||document.getElementById
3 M; I3 C- R$ j+ }# T2 m/ l& P. ]
if (iedom)
/ P U9 V$ K( G& y' A4 L
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
4 H) m. Q0 _$ Y7 o& [6 I
var actualwidth=''
: r* z) V) ~* S6 j
var cross_marquee, ns_marquee
\6 X" o3 [" Z
5 T, O2 o- ^7 F4 H$ _$ M2 c
function populate(){
; T* c- ~# ?- ]3 A, O2 r9 `* q
if (iedom){
) |2 ~3 f) P; V! _2 u6 Z
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
$ r, ?8 ^, D6 E- f0 e6 w& e
cross_marquee.style.left=marqueewidth+8
% j. P$ N# F6 B+ F. R9 N/ f
cross_marquee.innerHTML=marqueecontent
+ x4 T/ l* ~% B' L- P
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
7 O; w) N; n+ I3 Y( ^, |
}
: F- U, d" v6 d5 u8 k* `. L; r
else if (document.layers){
+ Q& B4 n) `* F3 e4 U
ns_marquee=document.ns_marquee.document.ns_marquee2
2 O& N: c+ T" z% @2 G! Y" B% y
ns_marquee.left=marqueewidth+8
" x. k2 I; ^1 N+ ?# E; x
ns_marquee.document.write(marqueecontent)
# \! Z2 Y% J# I& R" S: u( T/ t
ns_marquee.document.close()
$ F8 d& L8 E+ _( {* C/ h9 H
actualwidth=ns_marquee.document.width
, V3 ]/ }" @' x w* u% F9 V
}
0 x7 Y$ p% y4 _5 l/ w
lefttime=setInterval("scrollmarquee()",20)
9 A8 s/ x- O9 i: z
}
$ }' X4 y% v1 h/ T; f. `
window.onload=populate
9 C+ y8 q' l5 r- P
& p- U# B$ e3 v9 |* W- O( p7 O3 Q
function scrollmarquee(){
% ?5 ^! q- G) h3 H4 Z( i! E
if (iedom){
F- T9 E* `4 a, c# L! E) I9 s; C
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
5 R5 K# r. [( o
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
; [0 j2 q6 T8 c( P
else
|, w6 O& D% ? M, V5 R( Q/ Y C
cross_marquee.style.left=marqueewidth+8
5 x" { \* y3 `2 d
, l% U) d6 c, i
}
2 Z; o7 [) d4 {0 ^ |
else if (document.layers){
8 D$ h* T% G2 f$ k/ S
if (ns_marquee.left>(actualwidth*(-1)+8))
8 q# ^+ f7 o0 r+ U7 g
ns_marquee.left-=copyspeed
& y! a6 _1 i, Y3 E: q- m) Q
else
8 u4 B2 `* O( b; T( F; R6 j2 b
ns_marquee.left=marqueewidth+8
2 M, v, |! k8 B
}
3 V2 `9 L% m9 S5 F2 e( T; G6 _
}
2 R" ]6 Z, [9 C+ D8 ]
! A9 u( [! D. g7 N
if (iedom||document.layers){
z4 f2 I6 Z, H/ E+ W
with (document){
) X& y7 J; L: y+ Y6 x- W
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' Y0 Z& i+ j! f7 E% I
if (iedom){
: y$ D- F5 c: p! i; v+ x
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ F6 e& i; p1 S
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ ]- \4 ?6 S5 E; |
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 ^$ i! i+ v% X% p* t2 X; S
write('</div>')
+ _5 v* n s$ M6 {
}
' v( Z3 n0 P! C k3 \/ H% J8 D1 g
else if (document.layers){
7 T+ b8 S' }: t% }
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
3 B3 J0 v, T9 U* d, [
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
+ N+ l" P, V. A. r# n6 B. e4 [$ `5 H
write('</ilayer>')
5 {5 ~& b# P0 T8 e4 a
}
! h, A0 j% h3 c5 f2 P
document.write('</td></table>')
1 [2 K% a# M2 L, M+ p. r6 A( F
}
/ }/ L9 }( s) V9 V: k$ x) i. F, U
}
& P% c$ N8 B2 H% w; {/ ?! D" A; V
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2