标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
- m+ A! c8 o) j" p, _" d
var marqueewidth=300
. z8 ^, Z7 E k- `
//高度
! E6 P( g8 m& W- |5 k/ K$ d
var marqueeheight=25
' N+ D" ]2 S" x3 F/ `$ m& i k
//速度(1-10)
* z E) }4 t2 Z4 a! Y' g
var marqueespeed=3
0 r$ L" s0 W8 d# ~
//背景颜色
, K0 a/ M+ z$ @/ U+ z+ L z
var marqueebgcolor="#FFFFFF"
9 Y" {( F( k, i) K
//是否能暂停 (0=no. 1=yes)?
. [! M! y; D: M' j9 r; i A; j
var pauseit=1
0 L) n- m7 e |, l9 e
7 U& b0 B# V/ e, p9 R7 t
//修改显示内容
; ^$ ^+ M) e' N# }; G
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 M- |1 W! f C( R/ g
3 c; m. g) q* \. x* c+ n6 e2 \* J
& R" A% Y0 q& S9 b
////下面不需改变////////////
; a* h& e+ F3 J* n. @8 c. o
8 l5 |) f! w+ P
var copyspeed=marqueespeed
6 j( {1 m# N3 Z+ e" [, C( s, x. M
var pausespeed=(pauseit==0)? copyspeed: 0
' w Q2 j& ?& `1 F s8 P7 a- m3 _
var iedom=document.all||document.getElementById
& t* F+ w/ B0 `# l: D
if (iedom)
' J4 b7 y0 v( G9 V3 d
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) o' x/ G+ T& }7 @* A, ^7 ~
var actualwidth=''
" o' G) h1 @- p5 M8 ?+ h* h6 T) K
var cross_marquee, ns_marquee
( s. x* G, v% m5 x/ ~) t$ S! `
' l3 c6 y- N2 _! {
function populate(){
2 N7 @* a5 @* G& i! f5 p, h
if (iedom){
8 d T4 J5 h u* X6 x
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
( `! s9 C7 t ?. a% \
cross_marquee.style.left=marqueewidth+8
( b5 D# t) o0 j8 Z
cross_marquee.innerHTML=marqueecontent
: J Z9 v9 E2 r; J }
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
?7 c n4 ?/ S7 q8 r: Y
}
" Y& ` J4 D" W7 ]
else if (document.layers){
" g; T& x' X% s1 D+ u6 q5 Y
ns_marquee=document.ns_marquee.document.ns_marquee2
6 F: r( z% j7 m; Y+ O
ns_marquee.left=marqueewidth+8
) \( z) z/ b3 x7 N d* y
ns_marquee.document.write(marqueecontent)
2 U B, x+ @7 F# e3 w
ns_marquee.document.close()
1 x! M: M9 H* S2 N+ ^ \, Y
actualwidth=ns_marquee.document.width
% Z9 ~4 ?! k* k6 K
}
: I/ E, [. ?" {' c
lefttime=setInterval("scrollmarquee()",20)
' q e4 e3 Z: M& G! l# H& _0 D# P+ h
}
+ l0 H% f6 y. \- u' i8 r# ^; t
window.onload=populate
; T1 o3 c( t. }0 j* z+ w
1 W5 x" K/ {' ?6 Y
function scrollmarquee(){
# i% d0 k- \# r; Q
if (iedom){
0 N9 d' `- q2 F7 h* z! R1 i
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& l" v" R$ `* W/ @! Q8 s/ E, h4 Y
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
$ E& h' W8 D+ `2 p$ j
else
2 g {! G% G% [( g* x
cross_marquee.style.left=marqueewidth+8
0 Y1 n9 L( X3 x' [1 A1 S9 C! G8 U
) s5 q5 ], m9 A8 H$ z: j7 I
}
' _3 e- l# W# A$ D: z, C: G
else if (document.layers){
: o, U; Z3 e* k: s2 u
if (ns_marquee.left>(actualwidth*(-1)+8))
: d8 Q- q) K* `! ?. P7 |
ns_marquee.left-=copyspeed
; t; ^" P8 f6 V( C+ \. {5 W
else
7 H6 l2 V3 N' x9 j) n. G! D0 c
ns_marquee.left=marqueewidth+8
5 w5 G% l7 l; V3 q" ^/ c& H1 F( F
}
# H7 L! w4 I2 `1 h: w8 f3 x
}
$ Q, L) `# H }! ^4 ?/ _5 w" c
1 T( A7 G2 R4 M. V5 X; q2 l
if (iedom||document.layers){
3 f6 ? H: X" z( ~' _
with (document){
( w7 |9 H ]0 M; e& T/ \
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ K7 k& K( C& G4 n M+ A, c
if (iedom){
) d4 @. n6 M5 P8 F* z$ q* N
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; ]1 L, @" v# r& g) h; i/ T
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
9 | Q4 c U! a O5 a% @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 s( k; l" h; @5 z
write('</div>')
' R+ C$ h# n1 l/ f
}
. C, t) J9 N- e0 p
else if (document.layers){
% g0 u& z( \" ?+ x
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
& R& ~4 m! T. V0 B1 E- U7 o F
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 T1 y4 ?. ]3 P9 P0 t: g0 O9 g
write('</ilayer>')
. @; ^( M) V% m) ^
}
3 U5 }' z6 w) n
document.write('</td></table>')
& _4 A4 |7 M* W
}
0 V9 }, d/ t$ l. m0 n
}
B1 P4 v8 i, D) ~
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2