返回列表 发帖

网页之跑马灯文字特效

//修改宽度
$ u0 [. U- }5 k) u3 g8 w- e3 mvar marqueewidth=300: f* Y0 w) T  }- g+ G
//高度8 D3 f1 ~. }3 I, i* P
var marqueeheight=25+ y) c3 p5 s/ F$ F9 G
//速度(1-10)
' @; O5 D4 c* m5 l  gvar marqueespeed=3
: I- [; j, [; {2 `. J; q//背景颜色9 l9 Q7 _/ u* |
var marqueebgcolor="#FFFFFF"
; k8 T& K2 M( i( [4 G8 c4 X//是否能暂停 (0=no. 1=yes)?
5 j% ~5 [& {. k; d/ b6 X" Ovar pauseit=1% U7 G! W* l  y1 x. m( l

2 n2 P% D* H+ x$ I4 y9 ?//修改显示内容
: s! }& _1 |' s" W4 g5 Mvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
# m$ X" k5 A' G7 G
5 u- E% L5 T$ ?% Q7 T
) [. [2 L3 O3 c, e7 B& @6 s  \////下面不需改变////////////& i8 y2 z! H0 s
  t6 W6 ^( e3 g  ~6 U1 T0 z  @8 L/ X/ t
var copyspeed=marqueespeed' I* _  k: t# e4 g) }$ l; S
var pausespeed=(pauseit==0)? copyspeed: 0/ n4 _8 N! x  ~4 O: ]  Z2 f
var iedom=document.all||document.getElementById
4 \, Q: y# E; rif (iedom)
1 _  \% c7 `. `3 f0 j5 Idocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')! V6 J& b( H8 Z* ]. T6 f8 d9 I
var actualwidth=''* }! A- \( \4 s
var cross_marquee, ns_marquee
" G1 g0 r. D4 q. Y0 V3 W7 K$ [4 ^' x
function populate(){1 v9 Q" f0 T$ C9 O( J1 H
if (iedom){  I5 y7 z% ]7 o! f0 {
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
6 u+ Q' [2 o) P% A3 a1 Pcross_marquee.style.left=marqueewidth+8
& Q3 O+ h# ^, S# U4 Rcross_marquee.innerHTML=marqueecontent
2 L3 G9 m8 S2 r; U1 X1 wactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! `6 A! P) Z) C+ n: p7 x- |}
4 k% f" D" g( p1 uelse if (document.layers){
. B* N, Z# b% B1 M: X  x7 z$ Cns_marquee=document.ns_marquee.document.ns_marquee2, n& @+ F( J8 u# h" ~! A7 a' |
ns_marquee.left=marqueewidth+8  g5 e) w0 i8 Y" _
ns_marquee.document.write(marqueecontent)7 Q# T3 C9 m6 r1 v4 L$ f: F
ns_marquee.document.close()
8 k5 D% j& K; z5 M" \2 Tactualwidth=ns_marquee.document.width
0 v+ {' Q, B9 |; |; b0 j}( K! C3 t* T9 F2 X
lefttime=setInterval("scrollmarquee()",20)5 a; o' b1 C. j1 J9 J# E
}
! E/ \2 Y- p$ M0 H. X( d- `window.onload=populate
/ Q/ `" b; \6 Q& ^& @: M' o
4 [# |6 r# d  l3 }2 S" Nfunction scrollmarquee(){2 ?) [: Z: z2 t
if (iedom){1 o  @2 b4 h& S- |
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
( {5 |9 w6 W" C! l9 pcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
  G) X1 h0 G' M; F6 Welse
& P1 H2 s" K6 A" X* n! \6 ccross_marquee.style.left=marqueewidth+88 N2 x6 D8 a* L" ^5 \& h

- I1 a6 a1 p% a. d+ g}
2 M  h$ I& I& i8 Z/ gelse if (document.layers){9 k$ p/ l0 K9 U5 r
if (ns_marquee.left>(actualwidth*(-1)+8))6 ?8 c7 Y2 u! w9 f* s& k: {8 K, n: V
ns_marquee.left-=copyspeed
7 Z2 |# G0 z0 uelse5 n; G/ x  I/ h+ E: Y2 K
ns_marquee.left=marqueewidth+8: i( x% z4 n3 \0 K2 s) Q, E
}
' [, O0 l6 H3 Z( k- w}
$ h3 e3 F1 K+ V7 L8 I
2 X3 X. ~2 e/ i. V/ U# Q: r7 aif (iedom||document.layers){
, m# l4 ]3 N' z6 D) bwith (document){
5 ^8 d4 Y) ?' ^1 ]: K3 @8 @document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
& o- u1 f8 ^* k" Y0 @if (iedom){
5 F* I0 L3 L- d7 i* `6 `9 K  j) Gwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')6 p, v* b9 h, E1 o1 I- W  o; u
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
8 T! X. e' v: L1 Q$ L0 B0 F7 C8 Ewrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')' b, _8 g; q- b
write('</div>')% E( w( ^/ b+ k% L- s5 s
}
' Q, t0 ?  p" M- f( }0 melse if (document.layers){
" u+ s5 R6 g9 s7 |- ^3 A, L  O( F+ @write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')/ S/ D6 u/ T* a" _4 A5 u
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')1 u5 @! Y9 }! K' b2 O
write('</ilayer>'), Q; ?$ W$ b: H+ `8 y
}0 N8 C+ X5 D- L5 d. ~% d- s
document.write('</td></table>')
+ I' C! c' @8 i}
+ Z4 _9 G0 L) p}
8 J  I! z0 _/ d% Z0 Y5 W9 t: S</script>

返回列表
【捌玖网络】已经运行: