Board logo

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

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

//修改宽度
6 E5 k3 Y3 Z' N2 Ovar marqueewidth=3006 I: @0 n0 ~6 q9 }& ?
//高度
: `1 I8 }6 ]2 r8 u0 `var marqueeheight=25; d/ B0 t) I$ L  n8 q
//速度(1-10)
9 a" W" F1 C1 i& ~) Yvar marqueespeed=3% i3 v- r# C- l; ~- M
//背景颜色
4 d( ^1 S. @) I) Uvar marqueebgcolor="#FFFFFF"4 F0 ^: Y4 j0 r& C* x
//是否能暂停 (0=no. 1=yes)?
+ R( i/ H6 g2 O' _) y# h5 K. ]var pauseit=1& {: c9 z, C  |+ V

) R9 z" f# B! N6 {1 q3 E6 J/ p//修改显示内容+ ]0 x/ P" U8 _% m/ h5 z
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
  e. |9 x# x8 G. w0 ]) {) e5 i6 y9 S- p* S% v' L: j2 r( K% r1 d

" D2 |) d! O! \  E+ j' K////下面不需改变////////////: e) K  z$ ]$ b6 ^

+ y8 S! [# f4 E9 ^" A+ N! e" ivar copyspeed=marqueespeed  }( f: a- o& X1 x0 z- a+ y
var pausespeed=(pauseit==0)? copyspeed: 0
) j8 r# \$ a; Y1 Z4 a, {, }var iedom=document.all||document.getElementById
2 I1 e, A* `0 mif (iedom)' P) J& [' ]7 V" o  D
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' [8 N9 R4 j2 B7 |* [9 L: wvar actualwidth=''
8 K6 Y8 b4 u, x3 \% l# zvar cross_marquee, ns_marquee$ @5 F3 I) ^7 r" u! @, u
  @. [0 V3 v1 I) x+ ?" z0 n
function populate(){
6 M8 B) v8 @. j6 M: dif (iedom){
- I" L' J5 S! r- hcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee  l, c  r" ]! M3 s+ s% H: x$ m# z
cross_marquee.style.left=marqueewidth+8" B* [1 h2 M% t! \- |5 q8 N
cross_marquee.innerHTML=marqueecontent+ x" a5 Q! Z  Y. Q. N
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" Y9 ^6 k+ P4 ]1 k# D+ O}. x7 c5 L+ a, j( ?9 ~5 y5 U
else if (document.layers){
; ^$ x+ i0 v0 Q7 [/ F! m" y$ ^ns_marquee=document.ns_marquee.document.ns_marquee2* B: u0 J& U4 H- |/ F, V
ns_marquee.left=marqueewidth+8
& Q/ i* G( ?9 M% B1 f9 Wns_marquee.document.write(marqueecontent); L) B( L% k* X8 L/ A0 I
ns_marquee.document.close()
" _: m! J) u9 Xactualwidth=ns_marquee.document.width1 p" R2 J& I" w  W
}( m# d8 Y) y9 Y
lefttime=setInterval("scrollmarquee()",20)3 T& w/ K' Z7 e, A# l9 T+ z1 o
}# [( E0 k* E9 o5 j
window.onload=populate
0 O1 I) D8 i: X% {- y5 Z0 G. X
) @- u9 k1 H( D# y8 w+ s  _function scrollmarquee(){
/ K# z5 T* u6 t8 Dif (iedom){5 b6 s7 S- c- t' d. i( m* \
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
7 i7 w0 E- p0 v2 P, A7 Pcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
1 m1 J$ A- r% f7 J4 i: C) Ielse
+ ?1 O& \8 Q* b, Dcross_marquee.style.left=marqueewidth+86 j) Z5 P5 h  [9 N0 J0 d- c

, P( k0 P0 q; {: m}' E6 @9 L( V7 A$ }5 S. z3 s; z) I
else if (document.layers){
4 w! w2 G9 t1 O7 L; }4 vif (ns_marquee.left>(actualwidth*(-1)+8))
2 E" Q3 c- n: _& Z2 ]( @1 ]6 xns_marquee.left-=copyspeed) M" r( j5 \: y9 H5 t+ O1 q" |2 Y
else
& w- p. S: b( k3 ans_marquee.left=marqueewidth+8
; p& T$ E7 h' X) A- B1 v" |}
2 s! C$ D2 @' a2 `" G}; T, k0 i, }& w$ Q- ?9 M
. p0 u! i  y: E* {+ f" N
if (iedom||document.layers){! A0 t. c: S3 \0 H  |1 X4 W
with (document){
$ w9 D3 G9 k% m+ l  Z3 [/ h) \document.write('<table border="0" cellspacing="0" cellpadding="0"><td>'): J* H9 R: r5 [+ M  E6 y7 m8 A
if (iedom){
7 b0 K( j* j& Ywrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">'); I0 P- g+ u; i8 p6 E- K, V
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')( I" k. c% j4 t& [
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')3 i: q- ~, ?( ^6 |' e7 @2 O
write('</div>')7 J% L$ e8 Y3 n5 R: V) s8 ?' N( @
}% c, n+ p5 o: s' i3 H6 b
else if (document.layers){& ]: m- u0 _& r1 n. f+ u
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
$ T2 b% b5 t6 v/ P3 p) owrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
- p" I' Z5 F4 }- mwrite('</ilayer>')
* j9 ]" Y4 n+ P}5 ~) S2 {, F- `/ L( a6 }" E  d
document.write('</td></table>'): ]& Y) C6 b" r( L" W2 B/ P
}
; P# ]3 q8 _9 u; U4 q) L}
3 [* \1 t. ]! W& r9 q9 ^</script>




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