Board logo

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

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

//修改宽度, k: V1 x. |0 {5 T) f1 `3 w
var marqueewidth=300
8 K+ v6 q! c& d  e# C% y//高度
4 C# D. N+ L4 A# }, d: m0 Tvar marqueeheight=25- o: A6 j6 o0 \9 s1 O
//速度(1-10)& l+ L+ I  n& G
var marqueespeed=3' g. }$ _* \% d1 ?% ?
//背景颜色& u, Y/ H$ l4 l. K
var marqueebgcolor="#FFFFFF"3 c1 B6 {$ v" a( I: d$ P7 Z2 z
//是否能暂停 (0=no. 1=yes)?
% Y4 R) R+ m& Ivar pauseit=1
4 y7 b( E3 V# Y- k) @0 i8 b* |( C( V: ]- T% L) J
//修改显示内容$ t9 j. s: k  @/ {9 M" S  {
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'6 i& {$ R9 L+ K7 t4 M6 y
; Z' ^' e1 J/ M1 }1 R

: H4 ?0 M: F! j( k////下面不需改变////////////
$ S4 m4 W- V- @
. T1 t" {8 v$ hvar copyspeed=marqueespeed
6 r- y! H9 F" v; r$ a8 \+ r' svar pausespeed=(pauseit==0)? copyspeed: 0
8 ^5 ?) J) n% w! dvar iedom=document.all||document.getElementById
7 f+ c; j7 J" Eif (iedom)
2 S/ u' x" ~6 M; L, w/ |2 cdocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>'), F' b5 W( O/ A8 }0 L
var actualwidth=''7 o0 ]$ e1 O& p9 J# u
var cross_marquee, ns_marquee
% K. |# l; v, x" b
& O# B! P2 A6 O4 }5 xfunction populate(){, a5 f) X4 N) `6 o7 ]1 W+ R  ?! c7 b
if (iedom){0 z2 J3 v# o" ]0 P& B
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee! ~" L( O# J2 C. ?( k  q8 D! [% y
cross_marquee.style.left=marqueewidth+8
( q8 \+ ?  T2 T0 Tcross_marquee.innerHTML=marqueecontent
4 o) J* I; M5 F: V% X; e, Pactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 Z7 W6 R# z* ]. Y- ~8 G}. }+ \) j* p# Q
else if (document.layers){
* ^/ b/ k. Q, x% q6 E! c0 Hns_marquee=document.ns_marquee.document.ns_marquee29 X  m1 `- b% Z2 m$ z! l
ns_marquee.left=marqueewidth+88 G6 T, S. \5 |* S5 e
ns_marquee.document.write(marqueecontent)  q2 z8 y4 s. V* Y. y3 j% o% d) b$ y
ns_marquee.document.close(), `, v2 }+ K; F( Y; H
actualwidth=ns_marquee.document.width
+ R! m9 ~7 L  h' O- F, H6 x( M2 D}0 u$ n- R. z, q
lefttime=setInterval("scrollmarquee()",20)+ w! _2 |- D% k
}$ G1 `, ~& a( m/ L4 m  C* j
window.onload=populate
4 _/ m( V$ a7 n( c3 o# v! E. X. o6 |  S$ k! E
function scrollmarquee(){
3 ?& m5 Z* D; C$ }) Bif (iedom){; ^  `  U7 J' |' J$ ~6 N5 ~
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 S4 \$ o' Q, l  {cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed" n$ ^; D6 P+ N; }$ ~! ^, G2 Q2 s
else
9 R2 X7 B/ K8 Dcross_marquee.style.left=marqueewidth+8: _; Q7 O! @. p1 h% a
, _/ a5 u. P, y1 a2 t3 J
}
6 G. F+ ^5 I# n3 pelse if (document.layers){
$ c9 o* `4 @$ b) N4 h& {4 w0 Kif (ns_marquee.left>(actualwidth*(-1)+8))
, R! Q, Q3 h1 o4 {, _3 Y: A: Bns_marquee.left-=copyspeed$ S5 I- Y5 ^7 N/ t& j  s1 y/ W
else, Q) e: x6 _* K) s; |
ns_marquee.left=marqueewidth+8
( z: l( [& t7 X/ U* j1 i}
3 X4 l' J! s  E5 ~+ }5 g}
6 e! m6 [* A9 }" N7 ^: T/ K4 k3 ~0 r6 t
if (iedom||document.layers){
5 X/ M) c/ {& [' kwith (document){
: P6 V$ L7 d, W" |4 J/ n0 hdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')* ^# o9 i, A2 }" ]3 R
if (iedom){
7 v4 p7 u6 }* y/ l" _9 u( \write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')( F# e1 r/ t4 n& V
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
" k1 B  q/ i  C. M! swrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
& u& U8 Z* d, `/ f- B8 ~; Swrite('</div>')) Z! ^  ~- e& i7 r0 d
}
+ h5 A$ t" J+ e! xelse if (document.layers){8 `; @, z7 L* X1 X: x
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
  q) z8 {' {3 _( [% rwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% g, q7 V( I% i4 Twrite('</ilayer>')
0 `) u  h4 A6 I# L" l2 l}
9 S6 e. b; p% ?' E. B+ r. V3 zdocument.write('</td></table>')
/ ~* h  f3 S2 M' q; Z3 t}! }" A4 S& b3 j( f1 i
}' h' g/ C* P' Z
</script>




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