标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
, o _- g, p6 j! } H
var marqueewidth=300
+ _6 O' |; v5 C
//高度
; {+ [2 @# O/ z5 J% _
var marqueeheight=25
$ y. V: x+ g0 C6 K3 d
//速度(1-10)
6 m9 Q, K6 \9 a# j: ?
var marqueespeed=3
" U4 f5 g N: M* F9 L! r# P3 G1 P T
//背景颜色
: y0 `8 k) q3 ~# p
var marqueebgcolor="#FFFFFF"
6 V0 \! z% W9 d- M6 W1 S
//是否能暂停 (0=no. 1=yes)?
$ L7 h* r- _) ? ~/ f+ r
var pauseit=1
& ~. {% z+ G. p4 G# g, y1 x
- z: ^ q. |( J' c( H- w7 k" h3 U
//修改显示内容
* T# L: d; |0 j4 U
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
4 k7 r$ I- \5 Z; a
- E& V4 t) F: u( `
. q/ `6 g: H9 A& _/ H2 }; m. i
////下面不需改变////////////
% D: E/ b! X5 F+ o: }2 I. [
7 A+ o# G7 p2 j: I+ i
var copyspeed=marqueespeed
* V) j) y3 H! ^" N
var pausespeed=(pauseit==0)? copyspeed: 0
3 V l6 }2 Q/ j p4 v- e/ Y. h
var iedom=document.all||document.getElementById
: g J% k& ^" n9 m9 e1 o8 r& t
if (iedom)
& w/ e- O5 i0 B9 t
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
+ b; z u$ X2 o5 j1 h
var actualwidth=''
, K# t! U$ D5 R$ i- X
var cross_marquee, ns_marquee
/ G0 z1 F& G; T+ f
7 t6 `( i# `) @
function populate(){
. K" H7 ^+ w/ f3 g: \( F
if (iedom){
! J9 [3 s! {* P7 k! D
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ w& a/ @: A- I* L5 U
cross_marquee.style.left=marqueewidth+8
2 j7 m. c7 x- n! O
cross_marquee.innerHTML=marqueecontent
$ v, i9 l1 Q1 e& Y4 \4 _. m
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
# j4 W# p& J' w; t+ i! v
}
' n% l3 e7 ?$ r9 A. C' \" }
else if (document.layers){
5 w0 r' Q( l+ x& |6 W
ns_marquee=document.ns_marquee.document.ns_marquee2
m. s8 ^) D8 v
ns_marquee.left=marqueewidth+8
! l% b! z0 b0 Q# ?8 z! d( u
ns_marquee.document.write(marqueecontent)
0 C$ n7 L- ~) g( F
ns_marquee.document.close()
, U3 R1 _+ {( w7 K- c0 p
actualwidth=ns_marquee.document.width
5 ^* i' P4 ^$ F# g/ m
}
0 V4 w5 P6 y2 F' w- O( c
lefttime=setInterval("scrollmarquee()",20)
6 F0 @: G$ h! C1 D( _
}
, F8 q q. V7 a: V2 ~( O8 V" C
window.onload=populate
2 Y! N( f' |& X* V
& Y& x& Z8 t; G" `/ n' o9 u
function scrollmarquee(){
9 s) F( [7 f3 C5 E9 r, z
if (iedom){
G! d1 g3 y4 _ d7 y+ P
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 I4 a' S _: `1 J
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% o' x4 A5 {' e. `# M1 x6 O
else
2 o( `. O; _2 i! a& ]3 p0 U
cross_marquee.style.left=marqueewidth+8
! G$ y9 d$ K, |. M; ?6 n
7 @8 y2 Q9 x, U% }* E8 B
}
. l- s( ^2 r6 E4 X) z; j
else if (document.layers){
0 ]/ b* J% ^8 Q9 B
if (ns_marquee.left>(actualwidth*(-1)+8))
/ i# p$ M5 t* m) k; H+ {
ns_marquee.left-=copyspeed
+ z: n4 P8 z( F6 D2 ]( F: O9 B
else
- @ w3 O, q) }! S
ns_marquee.left=marqueewidth+8
: y9 Y, D. a& T6 d& _
}
: r; c% l" \$ ?! y
}
% e# e1 j% u D' z- \7 |
8 D) z/ f/ x. ?+ e
if (iedom||document.layers){
- X5 p+ y. Y" _8 `1 l+ D
with (document){
/ o+ s+ m- u3 j, J, T' h
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
# O5 e1 P1 n1 j8 k/ r
if (iedom){
* F9 o: w" A0 H1 m' n
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
2 w- Z3 l- l1 R$ |9 l j
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ K1 N- ^# o/ j
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' s9 i2 R5 ^' o7 H
write('</div>')
: U+ }, K. z3 f [1 n: v. c, n1 i" q
}
% g \7 W+ f" S" ?
else if (document.layers){
- x2 g9 q" W9 j; w) L/ ^5 {1 j
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 a/ Y5 i1 ]* V: c1 c! h* y& Z
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
2 B' O; b1 w/ ? ^" N* s: I
write('</ilayer>')
4 n3 f& b$ U* S6 r
}
4 ?: \7 y* P% D% n9 j
document.write('</td></table>')
$ H' {* }2 P6 ]" N9 A8 Q; H3 y6 ~
}
- ]7 ?1 P. [: J7 D2 e
}
. S h8 i. X/ T. B( \/ A" ]7 a
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2