Board logo

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

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

//修改宽度
/ v4 R  {* ?0 H0 @% Lvar marqueewidth=300& C4 t6 g# o' o1 B
//高度
2 o% {! ~0 y5 O# y, ]1 Y6 }% T  ]var marqueeheight=25
* t- B- f5 S/ L//速度(1-10)( @4 o" {# n! ]5 X! L
var marqueespeed=3
0 d) v5 ]1 N$ ?5 ?, ?//背景颜色
0 h/ ]% B9 a& N- j" S) X2 m+ kvar marqueebgcolor="#FFFFFF"2 G# m8 Y* `' J( m
//是否能暂停 (0=no. 1=yes)?$ J/ n8 I( M* p' J; v: `
var pauseit=1
7 h6 F4 d8 u# e0 Z3 o* ?5 C# ?
( z- v/ x4 P1 d/ _$ G2 Z//修改显示内容1 a: ^% d* N# F) s( G0 e
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'! W7 X6 s( q) o" B4 N& e1 W

) d7 V, H" K3 R7 j6 l$ C, _
2 x) A* n  V; h8 T" g, q! P  l////下面不需改变////////////$ n+ @- j, I, |2 D
( S+ B( X; D/ k1 g9 o7 o
var copyspeed=marqueespeed  z2 V2 F; h2 K! X
var pausespeed=(pauseit==0)? copyspeed: 0  b% H5 X" p! m8 a0 N
var iedom=document.all||document.getElementById
& y  t' B' V  Dif (iedom)$ P2 q) h6 y* M: p! V  ~
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')8 A3 v8 ?* G7 M7 i& Q: K: R
var actualwidth=''1 r, j. S0 z& Y
var cross_marquee, ns_marquee
0 i( W" a7 l+ c; v" c& ^
5 |  }8 p4 W5 ?5 f/ P' T6 hfunction populate(){* c0 w" C- C% ?9 H' d" F+ n* K4 O
if (iedom){
+ t- \4 N6 k/ l1 K0 W9 o' Xcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ j: w7 n$ O' X* ?cross_marquee.style.left=marqueewidth+8
7 u& G1 o7 C+ }! X" N/ |$ o+ Jcross_marquee.innerHTML=marqueecontent2 D  w# H2 C! B8 x) W; O3 w/ Q9 D
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth8 x" T& F9 R9 g$ i' F; B( P
}% f3 h) {* }/ t/ c. a
else if (document.layers){( i* t) a8 Z. I8 N( c6 _* I
ns_marquee=document.ns_marquee.document.ns_marquee2
1 s* L) g0 V3 O$ e' `6 |ns_marquee.left=marqueewidth+8
. W! ]8 Y  O3 h" jns_marquee.document.write(marqueecontent)
3 b6 ^6 g$ \$ h" N. D- g! z2 J" xns_marquee.document.close()
  n, L0 }4 ]; t5 ~$ _% S# qactualwidth=ns_marquee.document.width) Q5 i. u6 L- {/ P% q
}& ^8 D  A0 A( z5 }8 W8 I: c
lefttime=setInterval("scrollmarquee()",20)
# ?* A; l- B4 H" e% w, C: Y  g}' l1 D6 e: E) L% }9 Z1 T
window.onload=populate
" O: h3 d4 s$ _/ M
* J5 M& Y+ O7 B5 W  t' tfunction scrollmarquee(){3 L5 m% j3 P0 `) @( r$ ?% \
if (iedom){
9 G5 _$ R# {2 }9 Q0 |if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
$ X) ~' r0 |( a$ M& Q# Rcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed/ `7 ^- }$ u* o3 h1 i' ~9 O( v
else
  I/ S6 u! U, g' w& Z; r$ E) Q8 gcross_marquee.style.left=marqueewidth+8
* Z, K! A* c9 c1 T( p3 J: e$ |0 Z: [
}
+ B( N7 e2 l- A+ e/ v( _else if (document.layers){
8 a: k0 ]' m! _if (ns_marquee.left>(actualwidth*(-1)+8))- k8 |8 l+ K  X" \$ c# ^
ns_marquee.left-=copyspeed9 Z# m9 B' ^) j* C! o: _& w' G
else" H2 @# _- \& _1 v: C7 ^2 J
ns_marquee.left=marqueewidth+8) c' @, P) |& h
}8 B/ p- ~! I' y$ x  P2 Q" Z4 ^
}
7 r0 `. M. _: x3 P4 U/ T6 R1 o5 l! ]5 c+ z
if (iedom||document.layers){
+ N' h7 Z5 s2 _1 P% N9 owith (document){
* j: ^* n4 L! J" R5 G- rdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
( W5 o4 u3 S# Xif (iedom){" S3 J2 a6 \" [, [2 U- @
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* Y4 c  F  w. H, h. O1 kwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')+ X. E/ o5 d; j; E- l# w1 v( M7 r, {6 o
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
. Z* L2 i& s" x9 u" f' S( F+ v: ~7 dwrite('</div>')
9 j1 G' b9 z* n# Z3 L: y7 V}% n8 [" D. ?% {+ y
else if (document.layers){8 m1 m2 k% y5 Y; X! l7 _
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
& `& m% `  V7 n2 vwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')" X. Y1 P+ X$ C& A, w9 v4 E
write('</ilayer>')
) \+ v# r; @2 Z  F}
4 Y1 v1 ^+ Y/ s" r# E5 c/ i+ b* i; n8 mdocument.write('</td></table>'); F8 G! q5 m# g2 O9 X9 D
}% [# I; V3 `( y0 U) X  `0 S, Z
}
0 d; g- D# }" K7 X9 q$ L</script>




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