标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
) ~6 P* \4 S5 `1 |' ~% I
var marqueewidth=300
( I, u2 C; b1 K* T2 J" F
//高度
& T/ s* U2 B/ y
var marqueeheight=25
; @0 [8 n E" c b/ B7 y! p
//速度(1-10)
! w& [: N8 t3 } f5 o7 j5 p- e
var marqueespeed=3
9 R* r s. B9 K, i: L: X
//背景颜色
+ E' l" B) n k! O; G% }( v' v2 y
var marqueebgcolor="#FFFFFF"
- |) q( @0 c. |; E
//是否能暂停 (0=no. 1=yes)?
/ p( w% ~0 J: V( F+ l9 P
var pauseit=1
: v6 t# J# ~6 q) Z ^ m! y* z% h$ {
" L5 ?, A y3 ]2 ^
//修改显示内容
( M4 d2 P2 ?7 E% @; }
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
: M: }8 ], s. k6 P( D7 \
" l: N. \# {; [+ d; J2 C
. f2 K/ T% y% H3 n
////下面不需改变////////////
8 n! B% Z" c) j
: o9 {$ {6 j6 G, _3 e) f# q4 e
var copyspeed=marqueespeed
( i1 b6 g4 Z: \& r
var pausespeed=(pauseit==0)? copyspeed: 0
4 T' C: [$ H% b% C$ l; N
var iedom=document.all||document.getElementById
# g) `3 b4 Q( R9 Z6 w) k
if (iedom)
6 v4 Q( n2 X( x
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
6 O0 o8 M+ L3 u( g8 Y+ o9 Y, _. j
var actualwidth=''
3 x4 L+ W( I( A) i5 L2 w6 }& o
var cross_marquee, ns_marquee
* h6 B% a2 B. E4 N) N
' W! V2 U2 R+ I0 |3 v% K
function populate(){
. R$ N7 K4 F. @' I3 u5 q k
if (iedom){
6 j6 h1 \3 C! C! o9 v' {
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& J- g$ b0 ^/ c K
cross_marquee.style.left=marqueewidth+8
@( D3 p) h6 j2 c/ M
cross_marquee.innerHTML=marqueecontent
, l* X9 Z4 {7 }
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 ]0 ?- K9 G# a' G$ w
}
! U) F, z# h& u" c/ p4 G
else if (document.layers){
& f8 y1 ~6 ]1 i! {) ^5 A5 A- l
ns_marquee=document.ns_marquee.document.ns_marquee2
* ]9 }5 ]: z/ {$ g1 u! u
ns_marquee.left=marqueewidth+8
- b. w/ w2 _* S1 F& j
ns_marquee.document.write(marqueecontent)
) Z/ d$ T, D9 p( ?. s
ns_marquee.document.close()
* Y2 o( I" f0 d
actualwidth=ns_marquee.document.width
+ P; E/ H6 R& m( F1 H! L( r! M! ?5 P6 E
}
3 R/ J$ Z- m' R
lefttime=setInterval("scrollmarquee()",20)
7 a. @3 X! f) n1 g) j; g
}
# H. h+ j2 M% D. G' M0 d
window.onload=populate
$ w% |; A. X! d) D2 V
0 N! v3 S. D) f# I* c7 q
function scrollmarquee(){
( `7 r$ a/ [! m: `
if (iedom){
# s8 f. `' z4 t" T5 q" `
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
% a$ T ]9 K5 R0 c1 {* w' `. c
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
4 E, W0 m/ ?5 h/ Q" `5 V! L
else
$ \1 w6 @7 }/ ]) f/ Q% o
cross_marquee.style.left=marqueewidth+8
- p; S3 v6 o" z5 I& M$ z
! K! s, l' e3 N+ z* }& E8 B- Q6 I
}
+ ^3 I( e a6 [( @5 Z. g* P* J
else if (document.layers){
3 Z$ {( o: x4 {: X* \ |' A/ s
if (ns_marquee.left>(actualwidth*(-1)+8))
* U" N" U8 b5 x
ns_marquee.left-=copyspeed
6 Z7 @5 }1 F+ P: @) v) k& Q" X
else
1 _# h! T n V% t4 S2 r1 t
ns_marquee.left=marqueewidth+8
% ?" j2 R- [6 U3 h( J
}
1 y) Z G5 [8 `( J' ^& ~
}
1 d6 m$ N; ?7 P
8 h; O9 u* r/ @8 o! D
if (iedom||document.layers){
! w. ]1 }' Q P5 M, ?# }
with (document){
8 Z4 n- j/ Y7 w h1 F% u4 {
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
! G% A7 T* z9 j3 E4 l, I2 p
if (iedom){
! e; F) O! L* K7 h3 m4 r1 d# a
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
' ~) p: H- q% `, }# E/ x: T% M
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
7 e: w% [" ]2 L, L7 E0 X$ r# I$ Q" g
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
! `1 a# Q# W& x5 X! o. b
write('</div>')
$ W, o2 @3 j0 `! `
}
7 u6 H% T. p/ S M% b9 c
else if (document.layers){
% q2 @6 @" L( D
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; j' F5 K0 B; `( N
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 I* q; k0 D4 e# q2 u
write('</ilayer>')
# f: H" f3 t: [4 \ u: b( y
}
! r7 j( P& }- Y* [' ]2 |1 C
document.write('</td></table>')
, C7 A) d3 l9 o$ @- |
}
5 ~% y+ {) A5 \# D/ e1 z' v
}
n* i v2 [! j- a( z( p3 l$ x& R
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2