返回列表 发帖

网页之跑马灯文字特效

//修改宽度
; D( G5 n) w4 W% ]* Uvar marqueewidth=300
5 V5 a  _8 e. S' R( g. X//高度
7 r8 n: D. M" L; P1 _* h- P' Uvar marqueeheight=25
6 ~2 p: a2 M6 `. ^+ ~//速度(1-10)0 C& N: R3 T- k% |# }/ R6 I
var marqueespeed=3
5 L/ e# {$ x" z9 w//背景颜色% U. j* h' W' q" v( B) D
var marqueebgcolor="#FFFFFF"% G: {$ _; ~, F- q* y7 U/ u- m! ]
//是否能暂停 (0=no. 1=yes)?
3 B- o( H! ?, [+ K! @& rvar pauseit=1
8 h" C: V3 ?" ?) q
, t! \: w5 j  j6 @//修改显示内容
8 h2 x, u8 K1 g& Nvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'5 |8 y9 O4 f/ P# `

( P0 U$ K. [6 o: Q
/ W' P9 r& q7 A6 n$ u  O$ u1 r/ _////下面不需改变////////////; w0 V, n/ m  X) P
; o/ c5 w! t6 P
var copyspeed=marqueespeed
; ^3 e) b8 o- C& v; Hvar pausespeed=(pauseit==0)? copyspeed: 0& Z) I" ~7 P: c: E. K5 X1 O8 }
var iedom=document.all||document.getElementById; g  W0 |9 F3 i7 |, t3 J
if (iedom)
3 N4 c/ O9 {* {+ L, y; C3 ldocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>'). k5 i0 H6 `2 L6 [2 c
var actualwidth=''* k- _! @, @# d$ R8 P
var cross_marquee, ns_marquee! N3 r; U$ Z! O, }) ?$ V

0 H1 Z( a' H  Y: r6 Wfunction populate(){
2 `6 ?! u) t6 A  z7 m9 j+ ]if (iedom){
' X, H4 ^" @, g" L9 t- Ucross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! B+ a5 t" y' A) t8 o9 |cross_marquee.style.left=marqueewidth+8
1 Q; h9 Z6 P& `" Y8 ^  {cross_marquee.innerHTML=marqueecontent/ A* f% G' q+ g
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth, p5 K& Z$ I2 g
}
) J6 f! T* n! u# D0 ~4 jelse if (document.layers){
# v1 V- r" E: ~ns_marquee=document.ns_marquee.document.ns_marquee2
& H- t/ Q2 f$ t. W0 v* dns_marquee.left=marqueewidth+8
5 a. t0 ]8 r8 _) I& m! V/ p# Xns_marquee.document.write(marqueecontent)
2 {( N  c9 e! x3 Bns_marquee.document.close()( ~* m, t* W; W% [9 h6 m3 N
actualwidth=ns_marquee.document.width* H: U0 _! A! A7 ]  g: X
}  F# B8 M9 Q+ e
lefttime=setInterval("scrollmarquee()",20)  P; M* a9 z# j3 o$ [7 ]
}0 w: X4 h: l' X, b% |& K- b
window.onload=populate; f% \0 V9 M* V8 n6 p6 `

6 j% b& l7 W# m/ [4 @function scrollmarquee(){
* a- S8 J) a2 r- mif (iedom){
# t4 Y, r6 s% B% Bif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
+ Z$ ~" U2 O* z2 }cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed5 q% N; I2 B; P! e  m/ k
else9 ~# z2 P- p1 V) |1 p% \7 s5 k
cross_marquee.style.left=marqueewidth+89 J, g6 G4 b1 G

0 w) V% @8 R9 X6 F}
3 x4 w6 y9 h0 Pelse if (document.layers){
+ j* Z! {7 C4 k# j! R" u  T% f- _if (ns_marquee.left>(actualwidth*(-1)+8))& J3 U/ k2 E( L# K
ns_marquee.left-=copyspeed
9 z2 X+ ?, e& m1 ?else
. `5 Z2 N$ b3 S* [+ a0 W. hns_marquee.left=marqueewidth+8
1 Q1 W6 @+ ]1 ]3 K! J6 V: X: u}
; t4 h- {( Q* y}# h! m0 V0 ]& h7 Z) D) q
- Y0 i- w. I8 P7 z4 _( A: z9 r3 u
if (iedom||document.layers){
/ C7 K+ G  x* J9 Dwith (document){/ f0 Y) m9 h9 Z* g* P
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
, G4 n! [7 |4 Kif (iedom){4 U' @% v* t/ U* d# ?& a
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')5 ~. Q+ T3 Q$ x! b
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ d/ |6 |+ M" V4 Twrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* \% |& S* D! T# ^* wwrite('</div>')) v; ^1 |/ b' b7 i
}7 ~: X' f. x) j# e  \
else if (document.layers){4 L$ S4 ]% {7 K# Z- r7 J* e- K* ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')0 z8 }4 d5 j( {" g; k
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')- a6 x* j2 @; W! ^7 t2 Q! v( [' G
write('</ilayer>')8 h, b0 J/ J, M  r( g9 R# f, k
}& ]3 D2 m& f! j+ p) @
document.write('</td></table>')
$ `1 X, g# G. z* b5 c}0 A1 X; h5 z5 _
}, l+ B; _( J- I6 ]! L. v
</script>

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