返回列表 发帖

网页之跑马灯文字特效

//修改宽度
7 o. ^7 M# Y5 t+ _1 |var marqueewidth=300
! |5 f1 `" K3 k% _; P//高度
1 J3 H6 r, K4 a& i8 Wvar marqueeheight=259 s$ s9 z0 Z8 z  p2 g( a
//速度(1-10)
+ s, C+ Z0 N8 C& p0 m, J7 jvar marqueespeed=3
( n; S" \, Q% `//背景颜色5 a% Z4 q& G4 t2 s: B3 A
var marqueebgcolor="#FFFFFF"  I5 n' \0 ?6 D7 c9 J
//是否能暂停 (0=no. 1=yes)?
0 t2 M- E, u+ l9 v+ uvar pauseit=1
9 l7 p, w, o/ F5 D- B& `! @, k& s1 q  |  f/ t
//修改显示内容
! b2 X# N8 A/ M; k% Ivar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'7 r% P1 b* B$ v2 l& p2 ~
! a& o) a0 z5 f: J

- C% ?& Q1 e6 M1 e  c& Y. t( ]  L////下面不需改变////////////' ?2 ]! P/ z/ s9 V7 g! o5 d6 `
; N3 ]* o4 A; p( I8 }4 `+ J: E( X
var copyspeed=marqueespeed
5 ~( t. T& }- V) B# p. b, S  X1 Ovar pausespeed=(pauseit==0)? copyspeed: 0
5 K# V' {7 _4 k0 x1 ovar iedom=document.all||document.getElementById
: M0 n8 {) E. O* E2 I3 Dif (iedom)# S. x6 [' U9 h. R* C
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& I! k3 j1 G% e  ?! ?var actualwidth=''
3 n  a# ]6 j& e& ], }; ovar cross_marquee, ns_marquee5 P3 l% p! x2 Z3 W7 ?8 e$ F
8 s5 J4 e* w! T2 t" R% |+ O
function populate(){
; D  o0 m1 m" e- t8 E; m& Zif (iedom){9 J/ d- T8 g0 f( b
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee; ~9 l$ S& a3 j3 b
cross_marquee.style.left=marqueewidth+8) ^- K6 S8 j/ U, N) [9 ^( a4 v
cross_marquee.innerHTML=marqueecontent
( |7 B' v7 _3 o1 k7 Gactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth- m: Y/ O/ H) W
}
# h* B1 j0 J* }( Oelse if (document.layers){! k! F, i5 I) y9 q
ns_marquee=document.ns_marquee.document.ns_marquee2# ]" _. P* z' Q! l  |+ M) J
ns_marquee.left=marqueewidth+8
7 S. C5 H3 Q9 j7 ^ns_marquee.document.write(marqueecontent). x/ z: v" x; ]9 H5 U' y3 \9 i6 q
ns_marquee.document.close()
* _4 y% a6 V( v3 R3 Eactualwidth=ns_marquee.document.width
2 d9 ^8 E% J$ k( q& w" c3 A5 ^6 L}) A9 f( h0 h% I0 e8 u2 i2 A
lefttime=setInterval("scrollmarquee()",20)  m1 _. u9 u; f1 W* v) R0 D% J3 W
}
5 T* h5 m6 y; ^window.onload=populate
( E# u, {# @  r: ?+ i# |; k
* O4 Y! D/ L+ f7 Nfunction scrollmarquee(){7 v0 o. q9 `( w% n
if (iedom){
: J+ a* r8 g6 @" G" M2 o/ c! {if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
) o$ m) L, A( d: X( Zcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed1 g2 M- m. z9 ~' [! L
else
' ?8 R! b. P" t2 S* @( g4 jcross_marquee.style.left=marqueewidth+87 X/ f* Q* A, G' o
- u, d1 R( [, Z% H/ T: [' J
}0 O4 j; ^( h" E
else if (document.layers){) z: ~9 n) z9 M8 p3 n  R( z
if (ns_marquee.left>(actualwidth*(-1)+8))4 {/ p* Y4 A& W
ns_marquee.left-=copyspeed# y. G% n0 y% k! U
else
5 [/ y: c. k* h- I5 N1 C& E- `ns_marquee.left=marqueewidth+8! ?# V" D- X" ?; W/ ^7 P7 m7 s
}; N" v1 k* `1 `8 Z  N2 E, h3 Z
}
0 f, i, o% s  r
% x& S- l# e# G% S* xif (iedom||document.layers){
" j: k: K( r' y, jwith (document){
3 r  l* l. V1 adocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
/ \3 b% \/ L+ w- n( Lif (iedom){
$ v6 f0 u5 Z! }write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')4 n- _2 m6 u* g: V7 o" d
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
) l6 A/ e# f$ k) `- o8 _3 vwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')7 f& s& J# t5 W- Z* g( Q0 f0 v5 z
write('</div>')) g; S2 _& w+ |# C+ z" T6 v, {
}
$ e3 }4 Q% {- Oelse if (document.layers){
: c; O4 O6 z# j$ {1 e& k+ }% q9 qwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')0 i* L* F8 Z& O1 ?, a- @* c$ m
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')6 n$ |% V& S2 y
write('</ilayer>')# H5 r2 T# J! d% ~( u
}- Y$ i; Z8 s$ L9 Q0 n
document.write('</td></table>')
/ ^: V+ B% b* X- W- K}
  \* L. I  s* o+ P* L}) b/ b% j# t. `7 y
</script>

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