Board logo

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

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

//修改宽度
% v. j+ {% G4 [" z4 Kvar marqueewidth=300
+ z- `! T- i3 X( m! D8 }- n//高度; `+ l" l0 D4 S. K$ b8 s4 R% V
var marqueeheight=25
; H& d' V9 i% n+ @2 L* [  u//速度(1-10)
9 y2 n& g/ e" lvar marqueespeed=3/ P! |& {4 ~$ }; I+ I# ^
//背景颜色# K, K0 o! O% Y8 ~- v) ?: n5 C8 `
var marqueebgcolor="#FFFFFF": w4 D, A$ N+ B+ f* }
//是否能暂停 (0=no. 1=yes)?" c; K" R9 a2 g% b1 F. [6 C/ v
var pauseit=1
- S! a* C0 I* P! L+ M2 w! V% `* D$ H( m5 T! I, b+ t  N
//修改显示内容
1 C, i* [1 V( w; m$ ]var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
0 {# y: v. v6 |% X. H/ t: x% L1 S, B7 _; V( @% I! I: C0 T1 K

) |2 X4 F/ Z- l& I/ `" C# R////下面不需改变////////////7 ]( a- l% k6 ^7 f4 Z9 G" t. P* F; H* _

! m: n; Y6 b. l+ ?+ E- i% C- Wvar copyspeed=marqueespeed0 w3 H% m1 P7 d8 e
var pausespeed=(pauseit==0)? copyspeed: 0+ X2 A1 J* o+ P1 i' C
var iedom=document.all||document.getElementById
6 m( y% d3 X/ A4 ~: V8 qif (iedom)5 K5 t- a! P& r- \$ f. Q. y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')' T/ e# a  j: x" L  W
var actualwidth=''  E& v$ @+ d, v, `/ M8 Z/ ?$ d7 i
var cross_marquee, ns_marquee" b2 j, B  k& x, {5 l

" ]( R5 |3 s/ X( z2 }function populate(){
7 H! P5 Z4 {  F- F& H! J# T6 Lif (iedom){! P  |* a9 |4 `5 M- v% b  K
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee( H. `* V5 V7 F  S
cross_marquee.style.left=marqueewidth+86 t' H, V4 M6 P
cross_marquee.innerHTML=marqueecontent
3 y9 @& U( g& n3 G$ A" U+ Gactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
9 y9 r# p5 \  e/ o}
3 M5 @- x; j- \8 relse if (document.layers){! i& c, a* G: w# ]$ |' h3 [
ns_marquee=document.ns_marquee.document.ns_marquee2
5 ]+ T- Y5 @8 ?/ `5 Fns_marquee.left=marqueewidth+8
. ]. w1 B! B4 ^0 F, x) C6 v& ]ns_marquee.document.write(marqueecontent)
/ T5 r  k" H2 F" G# w6 Ons_marquee.document.close()
' n$ W0 z0 ^( a4 q1 gactualwidth=ns_marquee.document.width8 Q) y. V1 [, U, g8 P2 i+ Q  z) o! z
}
/ `2 ]. Y6 V7 y; x# ~( {" Klefttime=setInterval("scrollmarquee()",20)
0 F" z' |! R1 Q3 c$ ^( A7 h}
9 P7 o" x  n2 O# \; h) Zwindow.onload=populate
6 N+ @( O5 }' }% e' X; `
7 q/ i* Z" d$ R6 V  {function scrollmarquee(){! G% s3 U& J8 ]+ N, R
if (iedom){
# B$ }* M0 E" n& k! L4 A) A3 L$ E! Pif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))3 B5 W1 O5 c( Z0 {
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed8 c1 [+ v) y# ~$ P. t8 |
else" T" j/ T" Z' w5 ?( c* \4 i
cross_marquee.style.left=marqueewidth+8
8 ?0 z( Q' k, h4 x1 F! }; o' {& y% S! C" c! t
}
' p" a4 T+ f: C& uelse if (document.layers){
: `3 Y% I0 K' g8 ]if (ns_marquee.left>(actualwidth*(-1)+8))
7 G( |; j* l  r. |" X$ x" |ns_marquee.left-=copyspeed7 i: y% S" S2 V- U
else  n6 X' o5 L7 V- ~
ns_marquee.left=marqueewidth+8
6 m0 W( p& v5 J  r}& l/ F0 ]. |5 @+ y
}8 C$ ^; l7 r9 C- g- O' E+ B
7 T9 D+ B4 @. v( f" `
if (iedom||document.layers){5 f9 |7 B5 A9 S( R& {8 T+ _6 D
with (document){
8 H% c  A4 P8 l; j! g) a8 Udocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')' @" D5 M8 }" ]1 J" ?2 F5 L
if (iedom){
0 d% M+ x, z. i0 I! Twrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')/ w2 @( ?% }$ E7 l3 \
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
2 R1 m! i) V" D, Z- twrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
/ ]) i/ v7 |$ c, D2 q, C7 k2 owrite('</div>')5 @: |! z! b( \( h" R. U) ^& o
}
2 u0 w: n/ q& i5 {# x4 @else if (document.layers){: y7 x% Z' X+ J- e1 l/ ?* ^1 n
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 M3 G8 Q' E& r+ G+ @' |" Lwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
  s! t: i+ ^) M  }write('</ilayer>')9 c% R. s6 D7 I" k& r; H
}7 X1 K  b- J+ m6 D, ]7 ?
document.write('</td></table>')" \3 v/ w$ k* K
}
8 ~% \! G0 i5 a+ F3 J. j}
; h- ~8 e7 F2 ~# f5 s5 M4 l$ Y5 W</script>




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