标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
& x% N' w) i! o
var marqueewidth=300
8 ~7 i; h8 X3 U( z7 b
//高度
1 i! v( _! J( K7 K( k
var marqueeheight=25
$ Y, F% g( U5 D% h5 o
//速度(1-10)
" b. Q; L3 q# B( t/ n
var marqueespeed=3
9 ~5 _4 O- c& M- a& q j
//背景颜色
( u2 @. n% [" z! s, N) { q( h
var marqueebgcolor="#FFFFFF"
- {9 S; W! d- N* a$ r' m. ~* U
//是否能暂停 (0=no. 1=yes)?
% J, l# t9 A" a$ M8 P2 e: o8 c
var pauseit=1
7 o9 k9 X/ n& I, d4 j5 V. B0 f8 g
, e, X7 ^5 u: o1 T( t* n8 s% u, j1 r
//修改显示内容
% H$ c/ [0 ` C3 w0 q1 c
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
8 C5 v* `# e4 b R7 v
$ K/ J2 R2 [* W. p
4 B. K) f$ @, m5 V% m, b- }, K5 [0 D- K
////下面不需改变////////////
2 k4 H2 s* O7 B/ }! F
, e) E& P# B7 q6 ]; @
var copyspeed=marqueespeed
/ C" |; f" i1 t- X, \
var pausespeed=(pauseit==0)? copyspeed: 0
+ B* m. \0 w# }) i9 _
var iedom=document.all||document.getElementById
5 e0 G) M2 `/ |; D. H* C
if (iedom)
9 V2 }! y: X+ }8 A$ {
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
- n. M7 S+ u# [3 L8 m
var actualwidth=''
z Q6 a; D2 n% ~ W/ r
var cross_marquee, ns_marquee
9 j0 J( f/ c/ |; C
- G. P( b5 U4 k, X( a
function populate(){
8 l, G9 s6 d, i0 m& {
if (iedom){
) D5 ?4 [9 M, i
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 R2 f8 @% J4 b
cross_marquee.style.left=marqueewidth+8
' `0 l6 ]" J# ^1 o( V
cross_marquee.innerHTML=marqueecontent
! ~: f' @; L4 @ ^) B0 o! \
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
* ]* C& E$ e* Z6 R
}
5 U% @8 ?: e3 X$ W7 `
else if (document.layers){
8 ]. P _& u% {. ]
ns_marquee=document.ns_marquee.document.ns_marquee2
9 j' Y: S* o m; U
ns_marquee.left=marqueewidth+8
0 ^, u, e# V$ S, K3 w& `. D
ns_marquee.document.write(marqueecontent)
0 s6 P- F5 n- |( U
ns_marquee.document.close()
5 K6 d$ \9 j) G. D: q" M
actualwidth=ns_marquee.document.width
) G- c" i' s3 G7 k
}
% D( | v; Y6 g" j& g! A
lefttime=setInterval("scrollmarquee()",20)
: T9 S: \! [ Z b! ]/ j
}
+ K+ S4 b0 U" y, b, D4 z: T
window.onload=populate
3 D$ R" L' A! G0 z: w- n
3 D4 K) ?$ Z" M/ f, H3 j
function scrollmarquee(){
' c* X! x9 i. z$ E5 ^' W
if (iedom){
$ t# [, }2 E( Y# G* r
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 A8 Z. d; ~7 }5 e. |
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
: g: U! j, z9 k8 @5 ]
else
5 j/ F+ _# e& H' L: q$ x0 u7 x
cross_marquee.style.left=marqueewidth+8
9 a8 g; {( R) b4 E+ v( ~
- f2 A( E- P' V F* j+ Y6 f6 d
}
* b8 D0 k( a9 [: D
else if (document.layers){
/ i: D( D; _+ X' J0 F4 F6 B' V
if (ns_marquee.left>(actualwidth*(-1)+8))
& l+ o8 A2 g7 N& C* B3 v+ e6 ~# q
ns_marquee.left-=copyspeed
8 l( A+ d7 N* z* q+ v2 l
else
5 q+ r, {4 C, O/ `! C
ns_marquee.left=marqueewidth+8
) h, n* ~9 l% Y, S+ n
}
' {3 f1 ~ ^# d$ c R
}
1 f2 c; o6 c/ x- s P
( t* o6 P% ?* G+ G6 ^! D* t9 }8 K
if (iedom||document.layers){
& ^0 r U; ]' k1 e
with (document){
' c S) t& \( `+ ~. }
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 }# _- c2 R" i. Q3 M
if (iedom){
4 E0 q! V- d: m# j$ g- C
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
) D. o( y8 s7 L9 o3 Z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
: \$ d; ~3 J+ ]! t% r) I
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
7 r9 T, A R0 Z
write('</div>')
* M3 v' V5 g2 J+ B% L/ H
}
. L Q9 X& M$ _/ `, s/ o
else if (document.layers){
( |: l9 K, Z( m5 R4 \% ~9 w1 n( q
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
: n1 P! `8 t7 p3 ?
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 X, X+ } p& Y& `( i6 \& ]
write('</ilayer>')
4 o# P H0 m3 o% D- b
}
) ]3 [/ e- ^6 G" L% b
document.write('</td></table>')
0 c& c/ u8 E/ V) E6 i8 q
}
. D7 q; V7 o$ |8 n2 W+ d9 K7 k6 Y- D
}
) J( n3 W& l2 K! Y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2