Board logo

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

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

//修改宽度
3 P" H( g: O1 O' D1 u7 uvar marqueewidth=300
5 ^3 J. P3 M& S( B9 R6 g# A" ]//高度
9 h+ t- k. R8 S* ovar marqueeheight=25& B* `7 y8 o0 A- {; J
//速度(1-10)% b4 L( B( J, {* `* U
var marqueespeed=3/ U* ]2 d& P) K) \( p. _
//背景颜色
$ s' \; f2 v) avar marqueebgcolor="#FFFFFF"& [) V2 _9 D4 m& o) @
//是否能暂停 (0=no. 1=yes)?
5 h$ L9 h7 {1 T  f# avar pauseit=1% B* w# F0 n4 r& J2 K0 F. F  H

+ K3 a/ g; H7 Q* L//修改显示内容
& G3 ^$ T$ E. w2 L6 Y9 T3 `9 Cvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
* Q1 L; O! T! w" u3 G7 I% p* F$ S# I- P- i( X4 y# `5 t

0 c2 b2 [0 {* r////下面不需改变////////////. m3 Q% I* s* d3 E9 o9 i1 C

. Z* x% X+ T9 Q3 e, \. Jvar copyspeed=marqueespeed
  N" L% i. R3 b$ C, u3 ~' W/ Ivar pausespeed=(pauseit==0)? copyspeed: 0
: T' \) x, ~  q; M2 Evar iedom=document.all||document.getElementById! c# L3 T7 n" V* Z- z
if (iedom)
# Y" ^# q9 }1 x6 k" Hdocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')5 t  n+ |6 g2 N  i& _' B, q$ ~& O
var actualwidth=''0 d8 ~0 [* O* R/ Y% u3 b5 c" ]
var cross_marquee, ns_marquee& \" g2 F8 q/ A, }2 b: k; X

; Z5 _. d' [/ w* g: Lfunction populate(){5 _- K8 X/ `3 n
if (iedom){$ h! z  u# A- @/ Z/ R; u% @
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
7 I0 W) I. m6 p1 I# D( b/ Q+ ~cross_marquee.style.left=marqueewidth+8
" W& G. v' b% Z0 @6 ?  f8 I" Dcross_marquee.innerHTML=marqueecontent
! a2 ~5 W& n: h3 Z! S% w0 ractualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" z9 ~$ Y8 q/ Q* F' |3 ?- g& d}
( t# E4 S. L% telse if (document.layers){
* ]; B7 Y7 Y" n% k/ ^1 x! Q. Dns_marquee=document.ns_marquee.document.ns_marquee2+ z% U# D- i% I" a
ns_marquee.left=marqueewidth+8
# W) x% e" g1 A- w/ n. G) vns_marquee.document.write(marqueecontent)
0 ~& o, d- U3 W# y4 h, ins_marquee.document.close()
% v7 G; j4 d  P1 O" `( Kactualwidth=ns_marquee.document.width
$ Y9 {; c8 C( o}3 ]0 G- m$ K7 g4 q' e
lefttime=setInterval("scrollmarquee()",20), g! l$ }  m! Q, J3 F5 r+ v
}
) N' m( a% [7 l4 {# hwindow.onload=populate
/ j* O% z' g* ]
( b  q1 |. I0 ]+ U3 }" Q5 U5 hfunction scrollmarquee(){
0 H6 y& b, g9 I1 ^if (iedom){
( q7 V  G8 A1 j- A9 C4 b5 \+ [if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 a2 U( `0 B! Ocross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ n1 \* `4 ~( P6 {& yelse
7 P, [. l5 ]' m' c% p  a: E0 bcross_marquee.style.left=marqueewidth+8) i" Z( Q( E* X2 J
# q1 \. c" ?" B
}% [- K. d' O7 T# s0 C+ f/ x
else if (document.layers){
2 v( `5 v. J5 ]- q3 f) eif (ns_marquee.left>(actualwidth*(-1)+8))0 X" y9 G- ~* t+ \. @3 \. P& R+ }
ns_marquee.left-=copyspeed
0 T( [$ z3 j4 U( Ielse
) P4 P1 D& d2 H- m& g/ R5 xns_marquee.left=marqueewidth+8/ x% h' D+ G' [: R3 o+ r: n
}8 Z7 Z+ `, C  A% h; Z1 c
}
5 ~% \1 A* o6 i2 u% s4 G6 s( {$ e' N) u: y
if (iedom||document.layers){
4 O. h3 w" d4 u- U" w6 Ywith (document){
& s' ^; ]: E4 s  Ydocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')# K; k" a5 F* Q9 Z# z( N# Z4 q- _
if (iedom){' W. C* Y( q, a4 p. h
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')7 O7 t/ \& ]: k. v% a7 H0 B
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
( s3 }% E! I5 rwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
: ~: S' ~- z6 A  v! ?7 E5 Rwrite('</div>')3 Q" T" t: p+ w7 E
}8 X+ L- \0 m) i& `
else if (document.layers){
% p% P/ X! G# B0 Z0 G9 `3 ?write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 ?$ J' k% \( [write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
) _& T# g& p! W. H# Wwrite('</ilayer>')- ]0 l/ u3 ]$ m  q" M% M; ^+ W2 g
}0 t2 e" L; @: u1 ?, h6 M
document.write('</td></table>')5 }- c) ]5 o  N5 k% L
}' N. `7 D+ E+ M) x3 v7 }
}* k- A, w! P' ^9 L) u; ?3 G9 ?5 W
</script>




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