标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
. Y+ G# l# X% ]1 x
var marqueewidth=300
0 ?6 C% s* b8 u3 n1 b2 \3 S( C. j9 Z+ ?, @
//高度
[' F9 X N9 k9 Q" q' i$ @
var marqueeheight=25
5 N- T$ R, }" R f; I9 @
//速度(1-10)
; ], o& P0 w6 t) M
var marqueespeed=3
$ H: C0 x' Q# U" o2 c4 y) \) d
//背景颜色
( F: |7 q1 g! Y0 q# E
var marqueebgcolor="#FFFFFF"
- ^- e8 y# H9 ?2 M# g6 z
//是否能暂停 (0=no. 1=yes)?
& ]0 B E2 E( B2 W
var pauseit=1
: V' K8 G" N& X7 C; W# R9 V, A$ i
) U$ a% n* D6 \/ B! N8 ?
//修改显示内容
& L0 O# U- e+ w# a* T" Z6 n n+ Z4 z9 j
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 K5 I" A/ w q$ @7 H/ J
( a. ~+ X- Y9 ?
9 k- D- K8 Z5 }2 g" h7 c/ }
////下面不需改变////////////
6 {' H! k$ z4 S5 n% N& D# |+ w; t
8 w& O1 \! L) ~' A; G
var copyspeed=marqueespeed
0 `" P) N8 i' U; e' ^3 A/ }
var pausespeed=(pauseit==0)? copyspeed: 0
D! U, j' F3 z8 N) r/ Q/ N
var iedom=document.all||document.getElementById
) \$ M, a0 ?$ w, {1 Z
if (iedom)
* L8 S$ H2 l0 Y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
Q8 E# X3 |3 t
var actualwidth=''
5 q9 \. Z- d/ C2 C3 ^: b0 W: G f
var cross_marquee, ns_marquee
& A: l8 i* x3 c- h; _
+ q6 x% X2 t3 X7 t0 [5 G
function populate(){
0 |- e4 E' I* Y
if (iedom){
9 t, p1 o6 d3 N" K/ x1 r s4 K" z
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ A2 I' P; n. x; J4 }
cross_marquee.style.left=marqueewidth+8
& a) e2 w+ J# ^9 y( z( e# i
cross_marquee.innerHTML=marqueecontent
- l( r* G. @) u7 n4 n
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
4 S' G6 M* y, P7 H
}
( W% C" B% P+ G4 ~5 R2 F" I& d J5 W
else if (document.layers){
0 t$ r$ `( M+ Z# g
ns_marquee=document.ns_marquee.document.ns_marquee2
' M* U& U/ N3 v1 {# y6 |) I
ns_marquee.left=marqueewidth+8
, w; o; q8 `3 n n' d
ns_marquee.document.write(marqueecontent)
) s1 V7 [2 c7 [/ X
ns_marquee.document.close()
0 A4 M3 v0 a; H/ } a
actualwidth=ns_marquee.document.width
3 \. i1 `) [- y2 N4 j* G+ Q
}
: G% B. ^: d `
lefttime=setInterval("scrollmarquee()",20)
; b4 p. F+ Z/ n" ^' \+ G+ _& \
}
5 F$ ?) ?3 ?9 C" |# B4 C6 w) ^6 K/ T
window.onload=populate
2 U% c# H- _# X/ G
( O7 s, K( h$ l! ?# Z6 n% S
function scrollmarquee(){
* F# q* Q5 I; y3 v6 n9 v' q* M
if (iedom){
! J7 D9 {; Y) Z2 Z& W
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
# J1 Y! H6 d$ D8 X& U# W! u
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ j5 {9 `) n& T9 P
else
2 ?, ~& N8 I( n; {2 v- N3 |' K/ b
cross_marquee.style.left=marqueewidth+8
) {, v" g5 [1 A* b b+ ]
% S9 a* ~& O' @) H, B5 x9 n, t
}
6 j1 i$ m, w) R. a m }8 {7 P
else if (document.layers){
5 ]2 x" I- e E B; _
if (ns_marquee.left>(actualwidth*(-1)+8))
/ ?, f6 a* N* t( u# F3 a
ns_marquee.left-=copyspeed
/ y8 P# M6 B/ s$ W. \+ a4 B; g
else
9 Z. \/ t7 a9 ?# r7 \( @" l
ns_marquee.left=marqueewidth+8
1 ~2 M g- s, ^8 b
}
. e4 `3 o# ?1 T" j* |+ `& |
}
' X2 F: G, p; N
' ^' O, g+ j4 `+ e& b; F9 s
if (iedom||document.layers){
3 A" a7 \% Q0 @' t
with (document){
. G; L/ q% z$ d
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
9 {+ F( n+ Z( W$ R; A. }
if (iedom){
s3 n: n; q5 `) Z
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
, r7 S! L9 P$ D; X( F2 a
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 s; `- w1 n/ e) c- q+ \0 T5 y
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" J. _; _+ ~/ r: I: V
write('</div>')
: Q0 i2 b4 _$ ]' M7 }( \% p
}
* W8 g' M. {. `( H
else if (document.layers){
' c8 B; A1 a8 u' ?
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; a4 q+ i4 c3 _& a4 `6 e8 J) n% r$ q
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
/ ?' C+ B( Z! t! i- G3 K p& Q
write('</ilayer>')
6 e4 E6 `% p8 V8 M( n8 [1 j
}
5 l0 S. o' m! d
document.write('</td></table>')
# X" T# }/ n; ~8 _: ]5 g
}
# X6 t. ?3 I) _" x% b E
}
1 ^: M1 k/ C0 o, S5 n u+ n; t
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2