Board logo

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

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

//修改宽度
: S, T0 m" s$ H  l8 p! kvar marqueewidth=300
. c% X0 |2 o3 S& g6 b//高度
% u& P, v# `+ Y( t% _2 w: s/ [var marqueeheight=25- Q- ~" E/ |! ]1 a7 [) Q5 ~0 F2 c6 ?
//速度(1-10): s% l1 L0 i% t) T0 i$ d7 u6 n- w
var marqueespeed=3
& ]# _$ S% z0 g1 s: ]" p: \( @//背景颜色
1 K1 R3 d# K, u7 u, S# N8 z, N; X2 Bvar marqueebgcolor="#FFFFFF": J/ C2 d5 {( s& s
//是否能暂停 (0=no. 1=yes)?8 C% ~; O; V0 ]% O% A
var pauseit=1$ a2 O8 r8 ~9 v0 ~% E. J
1 [' }: v  }( t+ o
//修改显示内容
$ s, P+ e/ N; mvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'( C2 W! I* r* Y- w# O) R

9 ^/ r8 ]% V$ o& x1 ^$ ]5 o1 ^$ ?
////下面不需改变////////////( p$ c7 }0 k+ h0 q1 Q
: X! V6 O4 W4 m9 @, q1 A$ m# L4 S5 |
var copyspeed=marqueespeed% C3 I/ h4 F2 x& n7 G( T8 f
var pausespeed=(pauseit==0)? copyspeed: 0; r# v' K. y: a. l% w! D
var iedom=document.all||document.getElementById
) K  |9 w4 s2 M  Hif (iedom)5 ~: E* _/ f6 H( U' k% S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')- v- f; g3 b  @( A; L- r! G5 b4 M
var actualwidth=''- ~( W) l$ S7 o- r
var cross_marquee, ns_marquee
, q& A" s+ O3 z& b, m  Z8 @; V1 t$ B) L# j, G
function populate(){
# X6 |# Y! C! Z2 Eif (iedom){
2 D9 C& x0 Z3 k! jcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
7 C: ]- a. I+ o( W& _cross_marquee.style.left=marqueewidth+8* G  L  ^1 J$ u( F9 G
cross_marquee.innerHTML=marqueecontent9 g& y8 b. x& o: F
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
3 ~$ e( ~5 J" x# ^5 B2 ?}
7 N+ @8 c& |8 I2 N. }( belse if (document.layers){
8 h9 O) l1 Q" D; f5 Z' i( Sns_marquee=document.ns_marquee.document.ns_marquee26 s! k2 g* N! d. ^" a+ a& K5 d+ w
ns_marquee.left=marqueewidth+8
0 G$ k. ]3 d8 H, i% h& R$ o+ wns_marquee.document.write(marqueecontent)$ E' B7 S/ ?) _& j& a  G2 s: Q
ns_marquee.document.close()- d7 i) m, f! v# J, K" h- V* z
actualwidth=ns_marquee.document.width
: c) G/ k6 w/ ]; C}( \% L( t8 U! a) k2 s9 a% b& \1 f
lefttime=setInterval("scrollmarquee()",20)- D& a" x: X: E7 {. y0 \- R% {
}
; D9 D7 `  G! b& D/ iwindow.onload=populate
/ _6 G( H, \7 B: m9 e; }; @7 F$ h
) j  z0 D0 y& u" A9 jfunction scrollmarquee(){; M+ j" W! \5 O$ w: x" W! v
if (iedom){1 m! L/ w/ E8 A
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
. L& w7 Q# }5 q# q$ p* N+ c  kcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed3 T( m5 z  q6 Z+ |
else. X5 J( \5 }" |  M- l2 \
cross_marquee.style.left=marqueewidth+87 c' J% L  _2 ~: T6 V9 S7 ^, m

6 y$ `  r0 f- K}
  a* X1 q4 e; r. e, ]else if (document.layers){7 _  I3 |6 n( J! O7 D, d
if (ns_marquee.left>(actualwidth*(-1)+8))
, K6 q% Y& ]/ mns_marquee.left-=copyspeed
5 ^% `0 I, D3 }: W# G" M  delse, p- C6 R' V; }7 F, z0 ^
ns_marquee.left=marqueewidth+81 B5 d3 U4 @/ R) j" W
}% o  m( k% p" H2 |
}! \3 K2 k0 M1 U* s
* b3 e2 b& ?9 y. p- N- |3 y
if (iedom||document.layers){
' |/ `) e: u& @- Fwith (document){
# h! C" V- n* A& X, u% f  Q7 cdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')" J7 A, |: K; e9 r9 N
if (iedom){5 S5 U+ d# ?, D& `
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')  b. A  n; u5 X5 J  V7 Z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')8 Y) [) W! D5 y9 |1 d# t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')! X2 g. N7 G" m) Z; v- h9 W. D
write('</div>')
  L7 z* u; L* G. s( Z}2 F7 F6 i4 i- I/ d
else if (document.layers){
0 J2 C% B8 L$ e% x2 t8 S+ hwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 ~+ u! n; E5 B) U2 bwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')& ^* Q$ P6 W8 Z, U4 @' f4 l
write('</ilayer>'), J& a7 {) p/ n9 i& M
}
! o: f( R  B1 ~* g6 s& u0 s$ A+ l. udocument.write('</td></table>')$ E! u  d  E& K0 y+ }$ F6 X% w
}
, ~. f6 |6 V. q' {+ y6 j. g: J0 }* j5 T4 @}' |4 u5 @- `, J# x! b; I
</script>




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