标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
$ c4 G9 }& y }4 [1 m
var marqueewidth=300
2 C/ Z9 x2 f7 {4 P- i9 @1 \; R; J' W
//高度
[* |0 c. r) a' J4 R
var marqueeheight=25
2 Q/ z9 ]0 @, S' v c3 R+ _ C1 L# \
//速度(1-10)
1 A( F; ~! D J: U( x7 G
var marqueespeed=3
8 Q2 [+ W" @/ ~: A: F7 l8 c
//背景颜色
$ m2 R- Z* |9 }; u
var marqueebgcolor="#FFFFFF"
8 y: o+ {( ^) S. r
//是否能暂停 (0=no. 1=yes)?
9 L7 c) t9 L" j0 c: V: k+ I
var pauseit=1
/ B/ F; p# ?5 S
" w2 i0 c6 }- e% r( p
//修改显示内容
, \- M- I* J* C$ l$ g: C$ m3 _
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
) T2 y0 o1 G P! s" m. F: U
( y- [! n [5 `" \0 I5 y7 k
" p' L# u+ V: p$ m7 e% A
////下面不需改变////////////
; @8 e2 l$ S- x9 a# ^
6 B" |4 V+ E" S& u
var copyspeed=marqueespeed
0 n# b1 A' a) L W7 N4 ]
var pausespeed=(pauseit==0)? copyspeed: 0
" b/ j- B* ~ Z9 o7 }
var iedom=document.all||document.getElementById
6 ]1 }" t/ \$ q' M! m( O ?
if (iedom)
: {* h+ R2 S3 }' w0 `# ^( N7 W
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
; L: ]- H% j% r+ T6 S. F
var actualwidth=''
' m% `: j" S( M' k. ]* a
var cross_marquee, ns_marquee
* ?3 F( s- ]# u
5 g7 Z% F" B% w$ d( g0 \
function populate(){
; }- P* u( Y( h) ~
if (iedom){
2 V, I" X" v( D' @ O
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 h+ W$ m: G# N7 p0 R1 T
cross_marquee.style.left=marqueewidth+8
3 e9 Y) d% K1 `5 U# U& M$ B5 T
cross_marquee.innerHTML=marqueecontent
: }" T; \: {8 y
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
2 @0 n$ T0 K5 V' g9 {
}
" o* D0 n: p6 ?9 F8 b) f
else if (document.layers){
- ] z, x* d4 @$ ` w
ns_marquee=document.ns_marquee.document.ns_marquee2
6 o& F, V1 @5 ~& J* N
ns_marquee.left=marqueewidth+8
- @- I5 O$ g" L# }. Y
ns_marquee.document.write(marqueecontent)
0 x5 E: |& y8 g5 Y1 r& I. d
ns_marquee.document.close()
: {7 p. f6 j& P: U
actualwidth=ns_marquee.document.width
2 s4 p- G1 H. P: h8 C- z4 s
}
* U2 U/ \5 g$ v. [1 J8 _ \5 h! [
lefttime=setInterval("scrollmarquee()",20)
( u) Q& ^- r3 e" C
}
8 B d9 ?8 X0 r* x1 Q6 v+ G' g
window.onload=populate
* N4 y) r- U: t7 h$ m* i8 B0 `& ]/ |
; q, {3 O! H. `, y3 k( D
function scrollmarquee(){
0 Y- C$ n3 O8 {+ R; z7 N
if (iedom){
) w5 W: V( N x7 K
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
7 _1 n( g5 x: Y$ g
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
e3 v. j2 Z& j& i6 |
else
+ G4 O8 f$ r( \, ?
cross_marquee.style.left=marqueewidth+8
+ o, w j- R3 a [# e" { u
1 U7 P% \: w' W# q
}
3 e6 a/ q' q( | }) R
else if (document.layers){
5 h4 |; ?" U- _6 d8 w
if (ns_marquee.left>(actualwidth*(-1)+8))
6 Y( p$ O2 e1 h0 C9 D1 _/ b1 |
ns_marquee.left-=copyspeed
! q+ G! l/ w s* @9 Y$ n1 I5 a
else
+ P7 \" j( I0 X! o' r8 `0 x
ns_marquee.left=marqueewidth+8
, f' l( @: X0 c9 X# d2 J% B
}
4 y8 w# D ]4 S
}
( Y1 D V" w, L _% L, z( O
/ j" i& w$ o' U7 K7 S7 t; P$ {
if (iedom||document.layers){
% ?$ h) Q, S+ V" S/ t
with (document){
$ u+ G; m9 v! B
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 ]' b* O; ~$ m- n; C( Y
if (iedom){
9 z& X* r& e, H3 H% w+ K9 a
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; d+ Z( `7 |0 f
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
( ~& C' \; Q& x3 D
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
& r' B7 q: n8 c+ v' W6 m
write('</div>')
\1 |% L5 o$ N! a
}
! H7 `* B3 \7 `1 e9 W. F5 s
else if (document.layers){
* Q m) @8 d/ _' B8 p8 H; } P
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
! g/ |( K- R3 Q* N7 o$ \& n) I( X% y
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
& Q0 ~ }2 f" J3 k( h7 p8 ?5 V
write('</ilayer>')
( ~# s# E, G2 X
}
. q( i% H5 k$ ~& e2 l. k( _
document.write('</td></table>')
/ S9 k9 \# T( J2 o
}
7 F* c ?& m( ]2 X* m/ F; [* e
}
$ k+ ~9 P& |1 D% k; ~% @
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2