Board logo

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

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

//修改宽度
! V3 d$ F8 R" d& v  E* Xvar marqueewidth=300
# D9 B! H+ w3 j& V  C1 z//高度# U6 q# ^1 c0 M+ k3 I, Q, r  E
var marqueeheight=25
. @: E* @9 V5 E) H- n" i( w//速度(1-10)
) j- N, D) }" Z/ Uvar marqueespeed=36 n1 [0 ]  W: E1 D7 M. L6 C+ k
//背景颜色
0 T2 g5 |2 O. E( e9 F& w; c3 P: hvar marqueebgcolor="#FFFFFF"8 z$ X( J" ?: ~& n" a  c+ t* O. R
//是否能暂停 (0=no. 1=yes)?4 _7 A! m! |7 B+ _8 ^% N: k! W: ?& N
var pauseit=1" |. m5 Z8 h' i
& U, V7 ^4 [1 Z  }
//修改显示内容. Q) Z; w( V5 o! F( `" v
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
: r9 p; P; r4 X7 s" y; \( [( I0 ~9 S% f5 P/ r
! b# S' W8 L( ]) {
////下面不需改变////////////1 N+ B$ H4 T, a! E# d" F* S  |
* B6 c* r7 ~! r% h5 t; U
var copyspeed=marqueespeed
  x& x# L2 n0 u/ s  lvar pausespeed=(pauseit==0)? copyspeed: 0
' J# k; j4 N. o& x! P, Evar iedom=document.all||document.getElementById/ V7 w; I0 v3 ^9 i  b
if (iedom)5 Z+ T2 M) |! j, }0 J5 B0 C; r
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
, j; @2 z& @4 l( z; w7 C5 ovar actualwidth=''
( j' @1 R+ H2 |, R7 }) L# G9 S. kvar cross_marquee, ns_marquee
* I1 `6 r$ Y& o$ w' C0 `
' ~! S* @% \) Y/ v0 ]6 l+ [function populate(){+ Y9 E7 d9 G1 Z( u. A9 Y/ _. ?
if (iedom){1 W1 }2 z. Z+ f
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee& Q2 ^) o+ y; @8 Q$ @
cross_marquee.style.left=marqueewidth+8% q; f1 C7 z+ Z8 E) @
cross_marquee.innerHTML=marqueecontent% b' S8 I! J  F, j  G
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth6 W$ |4 ^5 N, w) H
}
2 S, P: P- K) i8 q7 F& }else if (document.layers){
, W0 `4 Q2 e$ x1 L4 I1 t9 |6 @ns_marquee=document.ns_marquee.document.ns_marquee2
8 A1 B7 F. t- U% q7 x  u" nns_marquee.left=marqueewidth+8) T# K( `! u% ~& H% ?: I
ns_marquee.document.write(marqueecontent)
1 _$ P0 I( x; r+ z# Xns_marquee.document.close()
4 H+ N4 K% z5 B1 ~/ bactualwidth=ns_marquee.document.width
2 s2 A# ~; ^$ x' N}
. r5 K; X1 l; _5 G5 C& g" elefttime=setInterval("scrollmarquee()",20)
) J. Q4 P. p  J$ g2 z! C: ~  R( k}' u8 {  A# h! b- W
window.onload=populate
3 j- s  ]8 z! r( G# e' g  S3 E/ x8 _( |* v; A0 p6 V
function scrollmarquee(){
5 P$ m* \, x, T- w" cif (iedom){
, q6 u' T0 ^2 f' Xif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
+ I5 B5 N, Z" S7 U3 J1 o# ycross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed( z3 c9 w+ K' w
else  h7 m7 Q' h! m/ s3 w
cross_marquee.style.left=marqueewidth+8
2 `; j1 j7 _- Y  t8 N5 \( E" x8 E% c" j! `  W7 ~' P3 a
}) ~- d/ S9 p! q! i# r: M% F
else if (document.layers){) P7 F! m! c, Z5 {9 s  \: `( V
if (ns_marquee.left>(actualwidth*(-1)+8))
. N* C* ]; ]2 I* n  r# ons_marquee.left-=copyspeed
3 k6 P9 X( O8 P/ xelse
' U1 N0 Q) J  a) M2 M  ?: D/ N/ E! Wns_marquee.left=marqueewidth+8
5 U4 _) }2 {) c/ s$ S}+ p  D( i2 a& f( c4 g! t
}
" n& k: t) c! f1 x. ]( F
7 z; c& p4 U, d+ ~if (iedom||document.layers){
) h+ T2 ~, l. ]with (document){
. @! F4 y! e8 t) j8 edocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>'): j, E  K. k* k8 ^& T
if (iedom){
$ n# o2 E) u/ V: z8 c/ `4 R8 \write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')- I0 V& v' |0 I; I
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
& `+ V. ^5 }* p) dwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 l, g: ~" r* D% |5 a, ]write('</div>')! @# [- h1 R  m" [- F" `' d+ U
}+ Y% r4 _+ G1 ?- F' i9 ~
else if (document.layers){
# M0 |* V5 |# K3 ?write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; i4 v- o, x9 Wwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')! ~: A$ c1 [& k; u0 Q: H$ D
write('</ilayer>')$ [" m7 c8 M; i8 L, q
}
0 m3 k. L$ v7 _! m" h" jdocument.write('</td></table>')9 d9 I3 ]7 i5 Y! x5 k
}
0 L( Q6 s2 x" I. m0 I; N4 e4 ~& ]. k}6 s/ }( k* I; G  Z5 j/ _
</script>




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