标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
9 F7 Y- \ ]" n
var marqueewidth=300
4 o2 a$ U% E: K- C1 R/ S' n
//高度
: n. p/ A. F5 w) ~
var marqueeheight=25
6 q2 m* ^( M$ s( j! N
//速度(1-10)
, l) Z/ h: q3 S+ n. ]# X; p& R
var marqueespeed=3
1 h! T# e4 t0 X0 a+ P/ p$ W0 L
//背景颜色
$ H# t! _/ r- I1 B5 i0 Q- y8 Y
var marqueebgcolor="#FFFFFF"
. d3 K9 g# u% q( G
//是否能暂停 (0=no. 1=yes)?
) C+ l* H9 y o+ \/ Y
var pauseit=1
6 h: H% y6 w- N' ? M' {% {% N
5 Y( R, { p f. Z+ c/ o) M
//修改显示内容
. q: M! c, w4 H1 M6 D3 d, A$ r" X
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
# M$ K& `( t& m) G7 ?7 M" X$ _4 }
* l+ D: X) }# a. u
5 l: E$ a4 o2 y6 j, Q
////下面不需改变////////////
$ h/ g+ O- q0 F8 R! @
0 U3 Y+ d& z5 ^- f; Y! s
var copyspeed=marqueespeed
4 D& N6 h0 }( m- ~& o
var pausespeed=(pauseit==0)? copyspeed: 0
7 W2 ^' ?& v6 Q5 f1 }& R( h
var iedom=document.all||document.getElementById
+ Y/ t( s4 v2 R
if (iedom)
3 e; [5 y4 T5 ^* x# B) y: A3 d
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) I; }( s9 U6 K7 T
var actualwidth=''
. R! c& v) O( M4 I
var cross_marquee, ns_marquee
1 S) m' A$ i6 m
& t8 h& g7 ^ M* K6 d
function populate(){
1 Y0 {. R0 r T2 i5 u
if (iedom){
* u4 z. `5 i9 @0 R$ w0 C7 |: m
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
" [- Z6 k) K, F, j$ A) u
cross_marquee.style.left=marqueewidth+8
- F4 @9 U$ @7 K j5 O3 N7 A' M
cross_marquee.innerHTML=marqueecontent
. r9 U2 c3 L; [* O3 C( z9 [
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
T& f( t( o" @* ~: {* \
}
! K! c7 P/ Y# K. q1 u6 G
else if (document.layers){
+ U6 j& d: f# _1 s! X' z
ns_marquee=document.ns_marquee.document.ns_marquee2
: X$ E4 ~/ @! a
ns_marquee.left=marqueewidth+8
' t6 Q1 S1 A; _
ns_marquee.document.write(marqueecontent)
# F3 U/ e! R: y) G
ns_marquee.document.close()
9 D+ ?* [0 I& M) v/ P
actualwidth=ns_marquee.document.width
1 S$ _" t8 C+ K
}
' K" e" n/ T5 I' F
lefttime=setInterval("scrollmarquee()",20)
, C7 U/ |1 w8 u) A" o9 {0 \
}
, L9 x5 w/ c8 J# r* [$ v% T
window.onload=populate
& J/ b, m& f7 H2 }
/ ~- n/ n8 D( a; c1 P
function scrollmarquee(){
+ a9 x/ g- r0 E- M$ N
if (iedom){
# j; r. ]& s0 P6 r
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
# r4 T" M! N m7 E7 R
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% h. Y9 w. T' G
else
$ a% r$ L. y2 A! b- P
cross_marquee.style.left=marqueewidth+8
# N- o8 |, h- l' h
, c) {/ g7 R* q* g
}
9 j1 }' w; b# x: z6 K4 J
else if (document.layers){
2 C) A U# | \! f6 y3 x; c: E! \2 C
if (ns_marquee.left>(actualwidth*(-1)+8))
E! \+ n. M" c3 I1 m; ]! {5 a( ?' R+ S
ns_marquee.left-=copyspeed
+ U+ }' s3 A. }
else
7 t2 |% d1 b; h
ns_marquee.left=marqueewidth+8
- T% o+ c8 T, k) |; q2 d& V
}
~, R6 ~+ Q( ]
}
; _- j2 j& @7 e$ E2 }; s
2 _# T; Z! T( N* l, e
if (iedom||document.layers){
v, E) z8 ]8 t% F# c9 ?
with (document){
; G* T8 P' H, ^& c6 _ @5 |: M; ]
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
4 d9 Q. ]8 {" o* g/ w/ e2 `; Z) b
if (iedom){
, W, C$ n" Q0 [" f: Z3 m; d1 \
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
6 }! E6 X/ G0 `/ M* E
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
' [% B8 x. ^# i+ e
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
7 X4 a8 m& {9 n3 |0 L
write('</div>')
+ t5 i' v3 m' M" U
}
! `( `" `; C+ I) Z, S6 |
else if (document.layers){
% k) D$ m c. \; ]6 B
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 P/ p' h' y9 E4 U& \
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
: B* l1 \; h- p( g. v: L
write('</ilayer>')
. L( K! _- F$ ], Z- H' J/ p+ s
}
$ I" m; E; \- H8 R; t: V
document.write('</td></table>')
5 D/ k9 D' D/ u8 a
}
5 k2 c+ K5 g$ L" m
}
/ p8 Z: F8 `& c: P
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2