标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
- A; A2 z6 R# N0 N: r$ a' e
var marqueewidth=300
( L& f9 }7 c$ ]4 ?
//高度
# u/ X. c9 |2 F0 o* Q
var marqueeheight=25
5 Y3 [9 m3 O& b$ x
//速度(1-10)
% ]) }& m, m; X/ O$ [
var marqueespeed=3
. Q0 l) N, t: _& p! q8 f0 B
//背景颜色
_1 v0 L2 _2 o- I( p2 v4 a8 f
var marqueebgcolor="#FFFFFF"
6 E5 w6 }1 i. x7 l
//是否能暂停 (0=no. 1=yes)?
o/ h& r4 _1 J. Z- K4 e B8 x4 o
var pauseit=1
) l R+ W2 P+ L# u' t g7 m
$ n8 q* ]0 i. h" U* x* J3 X
//修改显示内容
6 C( M9 c h( F( x$ t
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ U4 [ t! w' G. _/ L0 V% h
5 c: F9 C! |$ N
" r+ Q l+ O: c7 ~+ L
////下面不需改变////////////
5 K; y5 f; f7 z5 P+ @
7 A' G I1 `+ Y7 {& N- ]5 Q1 `- {3 f
var copyspeed=marqueespeed
/ Z9 p; z ]' C9 S4 i: b( |: [7 v
var pausespeed=(pauseit==0)? copyspeed: 0
: e/ T7 Q& I7 C0 O v6 T+ d
var iedom=document.all||document.getElementById
8 @# f( n0 x! I2 v
if (iedom)
% L9 t2 c# z; m- t# Y: k
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
* u* S) s6 C( Q+ e, Y( j8 d& ~
var actualwidth=''
. b7 J4 a' j2 s4 [- b2 j4 r
var cross_marquee, ns_marquee
% H0 H0 T0 H" x2 k7 v$ I2 v7 U
) |. y2 d5 F) b% r8 f, Y0 k6 Q
function populate(){
" R5 h. h+ B7 d+ ^1 d/ @
if (iedom){
1 w3 J) Z# \+ Z" f" Z/ ]) Y9 t' Q7 n1 `
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
. n B+ H" e/ x( ?, E' H$ m
cross_marquee.style.left=marqueewidth+8
/ E! h$ m5 k, e5 a' a8 Y
cross_marquee.innerHTML=marqueecontent
! [; Y( ^1 d- @5 s V# Y
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
7 Q6 l3 q0 }( p% a+ ~
}
1 s- p) i! c, G; i$ b
else if (document.layers){
8 T: w* a! d! @% R6 ~- j" }
ns_marquee=document.ns_marquee.document.ns_marquee2
% B" ^6 T+ e2 J8 ?7 W7 f1 @6 @
ns_marquee.left=marqueewidth+8
- a5 t& y$ y6 Y. x
ns_marquee.document.write(marqueecontent)
% n4 y: K1 l0 c% }) x
ns_marquee.document.close()
9 A9 I1 q* \! B
actualwidth=ns_marquee.document.width
$ K0 s9 e+ K( Y% d* b: j4 k' D
}
6 E' Y9 C9 D( x
lefttime=setInterval("scrollmarquee()",20)
1 Y8 p/ k0 B% t
}
) \4 J9 Y5 h! w4 c
window.onload=populate
. Z, o6 z& D0 |/ L* g( y
/ T3 l6 t: U' E5 j C6 L* @& m
function scrollmarquee(){
? u/ \3 F; }2 {+ V h
if (iedom){
3 V* ^! ^ a$ a2 o' M
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
" O. b+ x4 L8 l5 m( r u
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
8 J& C! a% E1 [) w% l
else
3 b7 A+ S1 f' n* t. }
cross_marquee.style.left=marqueewidth+8
4 g8 v6 t$ ~' A# s( @ s2 ^
4 g) s" y8 @2 M- S* _; P; {
}
4 t Y7 B" A2 ]* Z& r. T {
else if (document.layers){
( I [- n" Y/ U* u
if (ns_marquee.left>(actualwidth*(-1)+8))
+ \6 s! N2 v: ^6 l
ns_marquee.left-=copyspeed
$ |+ \/ z' q) @% {$ h" c
else
- i8 P* `( k; v$ A
ns_marquee.left=marqueewidth+8
: }8 S, l. l2 [! ~+ r6 k, q5 Q
}
! j3 s1 K+ {: m0 A& |; G# I$ t+ j
}
7 |1 t7 G- J1 @8 o
; l/ J$ P" E7 x
if (iedom||document.layers){
) ^& O5 c; }& p
with (document){
; `2 }7 _/ Y1 q. q* s _
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
3 H6 u3 l+ m- F, v v. R
if (iedom){
4 e9 y# ?3 c. Z+ R! M! s
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
8 u, g/ r D+ d. a- v! ]% k% @1 q( \
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
7 d3 R9 Y1 h2 ^5 [) {9 W/ m
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
6 n' C# w% M$ `3 ^4 k9 J6 C0 ]
write('</div>')
' K) f+ s, n8 l* Z- ]+ s4 H
}
/ u/ L' Z) w1 o, Q
else if (document.layers){
- a/ q E2 I' b0 C$ ~% ]+ z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
) k( s! L* r' h" G
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 X5 x8 s) M; e$ b, W9 R
write('</ilayer>')
$ U; O. n) r! ~% f0 p
}
' @* K1 D2 o) Y5 B
document.write('</td></table>')
! c8 h) T) _# T8 C2 w
}
' b: j! W0 }2 w, T( r: A
}
6 y8 P' h. H; [8 ]
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2