Board logo

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

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

//修改宽度  N/ o, g+ e2 @4 k9 [+ W3 g
var marqueewidth=300
/ Z3 `2 f2 {  H  i3 A//高度
) {" O- x& \" L. s# avar marqueeheight=25; g- G3 G! O# p: y3 E- L, X7 }
//速度(1-10)  J: W! }. J# d3 |
var marqueespeed=3. Z/ K+ K5 c% \
//背景颜色, k) J% _$ Q- T- |
var marqueebgcolor="#FFFFFF"4 r2 C' Y# c3 X& W
//是否能暂停 (0=no. 1=yes)?1 t- ?: q5 v0 i! d# K& e$ M
var pauseit=11 l) l4 h( r/ _) r
( \& q$ J. B. a
//修改显示内容
  h/ w; z! v" o/ yvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 T9 O% P$ a* q' x
3 M4 g8 B( r1 r( P) Y7 U# J+ K0 v  q( X$ x
////下面不需改变////////////2 p7 {. p! s+ f% _, i; H. a

1 S' F9 l5 [0 k) m* G3 vvar copyspeed=marqueespeed9 r$ X* b& a" i/ m4 G: T8 l
var pausespeed=(pauseit==0)? copyspeed: 0( a) d) f! |) K7 |2 I* x& k9 R
var iedom=document.all||document.getElementById0 [. L" c) a# B9 w, r7 O5 l
if (iedom)
% S' {3 Y" E5 t9 h: @. rdocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
: |: r% j2 E0 L0 zvar actualwidth=''
! X8 e; ?6 ]0 y  G, pvar cross_marquee, ns_marquee
' ]8 Y. ?+ V+ n4 W8 ]
. T/ \% m& J! A% R8 ]function populate(){
6 |: }9 |" \( J& a1 g# sif (iedom){
8 X& p- ^7 Q- [  V& wcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee. o) T9 k* J6 k$ c1 g, I
cross_marquee.style.left=marqueewidth+8
; G. w- S$ v& j4 _6 J2 W1 X: |cross_marquee.innerHTML=marqueecontent7 i$ t& x$ X2 g  x- r& U; N9 _9 t. ]  V0 m
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth3 t9 E% U9 O% [$ K! u
}" f0 R, n: W3 n
else if (document.layers){
' F3 k- O5 V, k( c# e" T. \/ K; jns_marquee=document.ns_marquee.document.ns_marquee21 A+ F0 c" e  n+ e* H# r
ns_marquee.left=marqueewidth+83 G  E& r" J: e8 w5 B
ns_marquee.document.write(marqueecontent)
) c3 _* L) M! L% g+ jns_marquee.document.close()
- T0 h9 K: r1 Yactualwidth=ns_marquee.document.width4 {5 R* _' ~9 d# ?; ]
}
* d9 z4 t, J1 n* Alefttime=setInterval("scrollmarquee()",20): q+ i" E. D& _; t5 Q2 t* {
}2 o+ }3 {1 J6 [- z  u& q
window.onload=populate
4 L# v! H2 I( Y5 L
: ~2 V- z* Q+ I3 Lfunction scrollmarquee(){
" H* d0 c; i% X2 b, \- w0 H; uif (iedom){
; S8 [) r* ~, Z4 V8 }3 }if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))$ q; y6 r, z" L
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed/ y( R4 w% G  N* S: i+ p
else5 {8 H, A0 G' Q- }% |1 D) p
cross_marquee.style.left=marqueewidth+8* ?) C) D0 v+ E5 s
/ r3 X9 F2 I" W0 O" n
}
2 N- W# n" u4 z; \8 C6 Gelse if (document.layers){
. x, U- ]4 h; e" G; Y- K9 b7 ~if (ns_marquee.left>(actualwidth*(-1)+8))) Y* J; Z  Y' D! P, ]
ns_marquee.left-=copyspeed8 |1 I% A! r" |9 q" F
else
  r' e2 c5 ?8 j2 Z. \4 dns_marquee.left=marqueewidth+8
2 H( S1 B% Q6 M# D, b}
+ r; n6 X3 Z8 V' Y' z}* i6 o/ v( j7 B. g9 \( l  d/ I& l

1 ?4 ~' b/ O0 }8 Mif (iedom||document.layers){" b# _- i" X% r" X7 X# _
with (document){4 c( \3 f% f: V4 ]; `. f( {9 ~
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
3 n. T$ `$ [% q) n, }  Sif (iedom){
5 |" G! E* j) J0 pwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 c7 i  V7 q$ X, v: R/ Fwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
$ c' y. _" q* S% E% C, awrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')! N7 H6 y9 ]3 A5 G- \6 T
write('</div>')$ S9 {1 g5 v  E% _$ M0 t5 o) G7 {
}
0 ^0 _/ E5 h4 |% Q' pelse if (document.layers){9 g& g. L0 |( H; ?3 |5 v
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')7 M( o8 M1 C/ W4 Q6 L5 H5 ^, p
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 M, w4 _+ u: H  f% M, }7 Fwrite('</ilayer>')3 Q: D8 R7 i1 V4 N( C
}7 e& s) a  h! q$ o" u7 f
document.write('</td></table>'); r) ^- N* s* i% [# _. C
}$ t$ n& p+ a8 Q5 z5 T  C9 ]% ?
}8 x9 k6 ~7 ~3 V, d1 Y% N
</script>




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