Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度
" A" K7 R9 [$ m. [0 ~1 l, @var marqueewidth=300- _8 T, R2 G0 v2 w, G2 x
//高度; j/ y  ^9 z! V0 l$ a7 d; M
var marqueeheight=25- d4 c: O2 @1 ~" K/ i2 x/ g/ X
//速度(1-10)
7 p: @: ^& r: x: _! @( g9 {) Zvar marqueespeed=3* W+ x( ^* N6 a- c' C
//背景颜色
9 U4 H8 ^( P: f2 p# hvar marqueebgcolor="#FFFFFF"' v0 Q, D; i( q4 |
//是否能暂停 (0=no. 1=yes)?1 v, H  G0 g" @+ u. h; K/ ]
var pauseit=1
# R/ q* e& ?  m- T1 x4 f
. s, Q5 l# L% j& H//修改显示内容  ^- s4 x) t. A) G' B) f, h" H! B
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
/ y5 b' h: O4 i' V0 ]& t
6 T( |" S6 q3 b  y2 C# k+ ^+ x# e2 j, ^+ x: a' x
////下面不需改变////////////
7 E2 W! @0 l/ V% k% `* w8 L$ [2 P; p, D, G# D4 d. Z
var copyspeed=marqueespeed# ^+ P  [0 g1 _
var pausespeed=(pauseit==0)? copyspeed: 0' w; o) ]/ X5 T% ~; y, T- M
var iedom=document.all||document.getElementById1 D; @2 l6 S, N2 \1 Z
if (iedom)
9 X8 ]4 i7 m' \  ldocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
; Z, W4 r* D  t; ^5 _5 n! Kvar actualwidth=''
& e  p6 V! d+ X- h2 {var cross_marquee, ns_marquee& h6 |, P) G1 u. f6 N
" c$ q9 p, b4 k! f  g( f0 M
function populate(){& k, D+ [- s( T9 U, Y  @
if (iedom){
1 y, O+ }6 {" G) z- |- v$ pcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& P, M- t: a/ o( x" Qcross_marquee.style.left=marqueewidth+8
& N8 i: Z+ j% ucross_marquee.innerHTML=marqueecontent$ D- R2 A& {) F
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( j7 O. A3 L" [7 R" ^}9 |4 I# u0 V. C2 x$ |
else if (document.layers){4 v& ^! A! b' L# T$ s! i% U
ns_marquee=document.ns_marquee.document.ns_marquee2
  Y0 C9 V$ j- H) O: ons_marquee.left=marqueewidth+83 w! V! N  h7 P' K/ S  W
ns_marquee.document.write(marqueecontent)# b; z+ _  n9 q& ]) _
ns_marquee.document.close()
6 A# k' \8 H% yactualwidth=ns_marquee.document.width$ w" W+ h0 F) J2 M
}
- ?4 N2 q, P" @5 ]$ r& u0 Nlefttime=setInterval("scrollmarquee()",20). \* q8 X, W, q( r3 a8 k3 J
}& q( X( z# @! M6 X/ t& u
window.onload=populate
2 s9 F3 z7 [3 E8 ^3 ]4 f2 ?' }5 {% K
function scrollmarquee(){
, w- ?% i& i- T- ], B2 Dif (iedom){- q5 t! \  ~# l; _+ }' m- }% T4 v
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))' X1 ]  Q# M( ^$ Y$ A! G4 T: X
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed, ]4 R, l7 ~: v
else
1 W) T1 a$ s! p% G8 s, wcross_marquee.style.left=marqueewidth+8: J. Z$ O& {" b& o) i

( T$ C+ f! v0 S7 Z# E+ M- z}, b* L: c  y: B7 c1 t: z9 @
else if (document.layers){
5 T( Q7 Y$ k) d  G( ^( J8 c  Rif (ns_marquee.left>(actualwidth*(-1)+8)): s% z) Q; e% {" [1 P$ k
ns_marquee.left-=copyspeed
+ a& K7 I+ b1 r( e1 z, T  c/ |else; f, ?1 ]$ }: o) x/ `( J
ns_marquee.left=marqueewidth+87 f# |% F( ]5 p+ @! w
}6 W. J8 c9 _2 t- o0 M2 s1 ]
}9 [) j0 `. O- H, N- }& [0 _
$ p0 s" H$ [" G9 R6 w: s' h/ F
if (iedom||document.layers){% N9 |. j/ o) i% [
with (document){- t5 w0 E: e3 L7 P/ A
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ ?( A. N. H+ `if (iedom){
+ E* h2 r4 S! H) y5 Gwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')# \$ ]; o9 H- P1 B! g/ G. r* l, v
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. s6 `" H* Q% \* ?write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')+ E( ?# B7 }, b1 }6 L: e$ l9 X
write('</div>')
+ Z) m" m2 |- M}
, [: c. L2 S3 U3 y9 r# ^+ u" Y8 m5 |else if (document.layers){8 w2 {* E& I5 P
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')2 y# C$ s  A* T% J' w5 B+ @! m
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 P$ t- P! v) H# Y  H3 vwrite('</ilayer>')& J9 l7 V* W& R7 i) E9 M% l
}; |, H" i/ X$ f( ~# y8 I
document.write('</td></table>')4 R8 c9 `! ]* h9 w
}( [9 ^* d. j' U' V; q# g
}; t/ P0 K* v8 E& e; e
</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2