标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
# X) w0 f, h6 T& V! S
var marqueewidth=300
, P8 r% H, _9 @0 z
//高度
8 g; b7 V2 r( q% k6 h( {! J: D
var marqueeheight=25
4 W i- L- { Z4 j
//速度(1-10)
0 g5 I9 i( ~: O2 D) V
var marqueespeed=3
: D. v2 t1 a# E) m
//背景颜色
' p% g3 q. @1 @2 k
var marqueebgcolor="#FFFFFF"
v! @3 `6 W2 j0 q2 q
//是否能暂停 (0=no. 1=yes)?
7 H# ?" n6 O1 L7 `) X
var pauseit=1
: G6 t" F( v4 w M @# k
0 v! r. z9 ^* I
//修改显示内容
+ d+ g7 P: \; V/ p
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
" [" K! b+ T. ]
5 _9 y/ p2 G0 H" f
4 z. c2 e$ @4 M1 B- m9 h
////下面不需改变////////////
$ i0 }+ O+ D1 ^' Z9 T
5 I" L7 t) f% Y, }( @9 ?
var copyspeed=marqueespeed
6 n& w' W5 T- a% {
var pausespeed=(pauseit==0)? copyspeed: 0
2 u! _9 X1 o3 N- D3 D5 D; j H# t
var iedom=document.all||document.getElementById
5 B2 U. j) G+ `& C- I* p
if (iedom)
5 _/ F9 {" j G" ~/ E5 b
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
+ E! M p. j8 {( O+ b
var actualwidth=''
% l/ I+ F% k3 K) y) X# d b- L+ ~
var cross_marquee, ns_marquee
7 C& I3 d9 [. Q( r4 h- K
3 o& J5 k, \9 K1 c$ w1 o
function populate(){
. y8 J2 A1 C' J8 O' D4 \8 L
if (iedom){
, o; M! b( N, T3 s
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
m+ K" _4 Q' q m& Z, F9 Z9 \
cross_marquee.style.left=marqueewidth+8
4 M4 ^) [9 s6 h/ z0 A \
cross_marquee.innerHTML=marqueecontent
. E ^6 S$ ~! C2 Q! `
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
: b! S( }% L& H' }8 V
}
: L: A+ u( i. `$ @7 r1 {2 `
else if (document.layers){
: Y, g! m$ d- ?3 r9 E! Q8 Z; z% H
ns_marquee=document.ns_marquee.document.ns_marquee2
7 C+ ?# R! o* w* H
ns_marquee.left=marqueewidth+8
: D8 n! t ~* r3 k' I: y0 g
ns_marquee.document.write(marqueecontent)
! B, K. G4 k# j# C3 V, ^
ns_marquee.document.close()
+ N) w3 ?! ~* S9 T9 w2 W
actualwidth=ns_marquee.document.width
" S: j) |, s" m- m _, o
}
( l/ i( r# v0 y! r
lefttime=setInterval("scrollmarquee()",20)
8 O/ U( b: M K8 A9 E5 e
}
0 N4 f1 F2 u U8 T( V# B& k! A. @
window.onload=populate
5 c3 v" x1 K8 {' N. Q* T/ O
: l' c$ O m1 b% s" U( W1 X6 d
function scrollmarquee(){
2 V0 y4 ?& N. r. _
if (iedom){
" H9 g5 I( F* g3 K. ~. c( ?
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& F0 N- m1 G+ Y. @6 M' H3 n
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% X( o7 @* ^3 c. |- J7 D
else
2 R2 H. w# U; ~9 u
cross_marquee.style.left=marqueewidth+8
# Z: O! ~5 c8 i# Y: Q* ~
! W( ]) p) H; z) H4 Q
}
: u" Q4 S/ b$ W ~
else if (document.layers){
) A: X5 \- o& p, G
if (ns_marquee.left>(actualwidth*(-1)+8))
/ n( h F7 V S! ~9 j# y9 l: o* i
ns_marquee.left-=copyspeed
$ X# F4 Z/ t: h v% s8 B6 E# u
else
T% T, X( f7 F& X
ns_marquee.left=marqueewidth+8
* Y! V2 \6 Z$ \( ?) H, G/ e4 h
}
8 J! |3 p& v2 M$ w
}
D: A0 H( E$ }& x/ T# h; z
2 `% V, Q' F6 Q7 `8 f" I$ C
if (iedom||document.layers){
/ Q7 l( A H5 T! t5 @
with (document){
$ X; f8 I6 U% b v
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
/ A: [2 U8 s+ m @; e! W" n
if (iedom){
- e+ _. V/ d* R% U6 j e# ?9 A( t, K
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! L/ F- G( H: ~5 M" e. K- I3 G+ x" h
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
7 w" ]% S7 I5 D' w+ [/ @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# `. Y5 m5 d0 z t1 `( b
write('</div>')
7 y+ L: k8 O: a, X: _% s! c ~
}
. f) @) n- ]" O/ C- H& \" c$ V+ p+ a
else if (document.layers){
6 z4 Z+ e8 P( e
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
J7 W/ F) I2 o2 s' b
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
0 n4 x) Z7 S/ E; b
write('</ilayer>')
0 _( x" D! z8 G1 W% T
}
, W& Y7 m9 H& |, C; m* x
document.write('</td></table>')
5 F, m2 a/ w, l1 E1 m( u
}
' p0 A, m, Q: q8 E' [
}
: p* f# g" c* x
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2