Board logo

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

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

//修改宽度
( B1 o) {" T: P  L  z  L; Fvar marqueewidth=3000 y; C0 M" S( n
//高度
0 k( H; D- A1 }& _4 Wvar marqueeheight=25: Q0 n/ x8 E3 @: F0 w
//速度(1-10)6 w: B) p9 D( ~
var marqueespeed=3
" b" Z% i) O/ C( f2 X1 J//背景颜色9 G; i& V! L; T9 ^
var marqueebgcolor="#FFFFFF"3 ]( P% m3 y) r) Q0 z& O
//是否能暂停 (0=no. 1=yes)?) x) |4 p+ w% W' k4 Z, i( ^) \
var pauseit=1
$ N$ C( o4 G, }$ g+ |. e& }0 S. m8 T8 ]" l) H
//修改显示内容
& e8 v. @2 |# ]2 L8 b; h) kvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ C0 O- o6 q3 d# K* G
2 i- I8 p) Y5 ~9 W7 r- T/ W! C. Y! n
////下面不需改变////////////$ {+ t* t! X9 Z- I  N

4 b* |* [* A$ i& m' q0 }var copyspeed=marqueespeed& c; g  a: k- u: y0 I
var pausespeed=(pauseit==0)? copyspeed: 0
5 K2 s4 s2 L! Hvar iedom=document.all||document.getElementById! y% }9 A8 l: S8 k+ o* G
if (iedom)  q- L( ]4 ~; x9 m* w5 V
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& W: Y" C0 r$ b( q! L2 n! uvar actualwidth=''
7 `/ l; q/ n7 Z) j: Wvar cross_marquee, ns_marquee, W0 F. g8 H2 G$ i/ J
7 h" p0 y0 ?2 V5 }9 ^2 @5 @* u
function populate(){6 a! U) g: W9 N& A# s% |1 K. B
if (iedom){
; Z- w! i: I. `; a  L( Vcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 n7 _7 Y* [' b( K7 across_marquee.style.left=marqueewidth+8
, x; ^% f5 Q6 Z6 o4 ^. Bcross_marquee.innerHTML=marqueecontent
  S' |4 I" f; v8 O1 P1 hactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth3 E1 T$ G( H# l4 e. U
}
. s; x( V% b; Y, t: e% l% selse if (document.layers){' I+ n) f* R* M- z( ~
ns_marquee=document.ns_marquee.document.ns_marquee2) T1 n* }) {! a: r( u# L
ns_marquee.left=marqueewidth+8) [% A$ s- `( s( E+ I& o
ns_marquee.document.write(marqueecontent)
' b7 V0 ~& F5 G2 h9 Bns_marquee.document.close()2 y# Z# j/ K/ g
actualwidth=ns_marquee.document.width. ]2 }2 v, D* c( w( v8 q/ {
}4 }# I* t" d; @+ _0 U" }2 {3 P
lefttime=setInterval("scrollmarquee()",20)# z5 s1 u$ g' y6 x7 z
}
( C& M# U( }& Y; v. J; D: xwindow.onload=populate6 U, H* ~5 m3 w6 W6 K
/ \0 L) A+ Z9 i' X/ ]- ^
function scrollmarquee(){
6 c4 A8 }# x0 Q* _+ R! ^8 Pif (iedom){
& }- j' ~7 U% U3 X4 ^% Eif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& N# P  c" f$ ^6 Y# |cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed! I4 q& Z% N0 Y
else* \( s# y. P& ?& t3 w* d2 L
cross_marquee.style.left=marqueewidth+8; c6 O  C) |  |% N* W9 G0 e2 G

4 e5 k: E  b# K! m}
+ D- w+ z) L# F, @else if (document.layers){) `5 ?9 Q5 ?5 s% S& z
if (ns_marquee.left>(actualwidth*(-1)+8))3 h1 }+ V3 R3 o' G! {; M5 q( k
ns_marquee.left-=copyspeed* U0 t4 k9 i: A6 ?% A; n% {5 M  g
else7 Y# L% M, x" P6 a" [
ns_marquee.left=marqueewidth+8
" O- d( @# y# c% j8 a6 B! K+ j& r}
5 k  Z2 f8 \4 z/ U/ W9 Q# O}; V7 b/ f. e* D- m" y

+ A  [0 m3 r# J- Q# F) Y* W2 Uif (iedom||document.layers){
' L% s% X- E  \$ {6 e1 \with (document){" W' W9 Z3 V1 Z% z. H
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
! k: F9 ~. s% j7 O" K3 v7 _if (iedom){* K: p5 Q2 K, i& \
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')9 N$ Y- X# ~& A* p% b0 U" Z) v
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
9 T4 i0 a# _" l& r0 ewrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' Z: Z/ o, w5 E8 H1 k; y# m9 y4 Twrite('</div>')( ^) ^, f: B4 p- V& Y) i) a- Z
}
0 G, F+ x5 p% d8 g5 Velse if (document.layers){
& z" A) t! Y) d3 _0 q+ Kwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
6 d* i- C; X- Twrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
2 N  q( }; Y  i3 a" D" Kwrite('</ilayer>')
3 `9 x. f4 m; l; Q' l! _$ h}; V8 ?+ U. v* s! t8 b2 Q; ~
document.write('</td></table>')
, I8 Y/ M. N6 T5 J- N$ O}
1 h% i! p* ]5 p; R0 F7 W. f}7 d2 n9 O5 p$ v/ u* c6 l
</script>




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