标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
6 d( M# `) t P- Q$ j
var marqueewidth=300
$ F5 v6 i; U) u' U# p% s C5 O
//高度
* b# l/ V* V' E! w* G
var marqueeheight=25
4 H* b- c8 P0 N" X$ T5 T3 M8 A, A! J
//速度(1-10)
! N5 n3 o h; e& ]; c1 c
var marqueespeed=3
3 o; p, D$ @" |2 Y
//背景颜色
5 F" W9 u t" p g1 D# P
var marqueebgcolor="#FFFFFF"
2 a# l: n% T/ ]; N- T' p: o% T
//是否能暂停 (0=no. 1=yes)?
d+ u5 t5 ~$ z' ]7 i
var pauseit=1
. R! W+ p$ B) c& W h0 }2 A5 o7 N/ @
3 Z& E, u8 H/ R! o. K# A+ J) k
//修改显示内容
$ b! C: Q* Y( T4 d; V- w0 u
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 A9 v* h0 g0 R& y& J% S
5 Q& ]" A- {1 M& F; r6 t
; W( H6 }9 @8 i S
////下面不需改变////////////
3 W( C7 {! Q! a3 M1 G$ G
1 n, m4 w" f. { D7 I
var copyspeed=marqueespeed
% r* B) T7 N% R2 j
var pausespeed=(pauseit==0)? copyspeed: 0
! j0 s. a5 v8 g) G @8 b, L
var iedom=document.all||document.getElementById
% p0 ]& g9 |3 Q. ^+ {$ K& W
if (iedom)
9 l( t; g- _4 R; M( ]/ e3 r
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
- g: r( @- F& b+ k5 {
var actualwidth=''
( H. _, n! Q6 ]6 u+ G% S; e! Z
var cross_marquee, ns_marquee
; h' n6 X3 W4 }; p$ ~2 [) o( B, l
) k | v' e% D: r @1 x( e9 ?+ a
function populate(){
# L" V# l8 h* q S. s+ i: ]8 q7 ^
if (iedom){
" H5 \9 D1 D1 [' J, N
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
: u, T1 F! b$ [7 Y% {2 H1 `5 |
cross_marquee.style.left=marqueewidth+8
2 i g1 q/ O) s6 h1 r! Q
cross_marquee.innerHTML=marqueecontent
* d, n# j, G# \4 T: F6 E
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
) m8 c" y4 `4 H/ ]$ Q5 T
}
2 `4 @& T) F) L8 y' |
else if (document.layers){
3 \; h. g4 `" F4 q) o- H/ q* S5 w
ns_marquee=document.ns_marquee.document.ns_marquee2
7 N5 H7 _4 K M) H
ns_marquee.left=marqueewidth+8
( g- U6 ^8 X( l' M
ns_marquee.document.write(marqueecontent)
& T0 M; w8 J& I( @, W5 d5 u
ns_marquee.document.close()
/ f4 U6 I7 }+ G- G2 O* @, ]
actualwidth=ns_marquee.document.width
1 Z! ]2 _$ P- n( |9 G, ?, z
}
- A6 a( A2 ~- I% q+ N& E
lefttime=setInterval("scrollmarquee()",20)
$ ?6 E2 |1 u3 ^- T3 E8 h5 i
}
' T6 o& _7 O4 Y+ P# f5 x% r
window.onload=populate
1 w! [" b% |/ I
: t, ]: J% Y6 j; N& i
function scrollmarquee(){
- _. }0 k9 |1 F0 V o
if (iedom){
; ^9 G4 M! n$ {2 Z* h
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
! C3 g3 T: i5 s/ J! N+ j
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
" h! _; Z9 x0 M
else
+ V) K" e& r) v9 K, S0 t8 x
cross_marquee.style.left=marqueewidth+8
/ O3 Q/ @, C( y$ r1 k3 s* Y2 t
" i( k, y0 n. @# K5 O
}
5 C4 _8 E% [2 @* N8 K2 ?
else if (document.layers){
$ y/ u$ s/ D; f
if (ns_marquee.left>(actualwidth*(-1)+8))
7 V/ a& P8 Z1 j7 G
ns_marquee.left-=copyspeed
7 R- i' z1 j. Y) J/ d# m
else
5 s# {+ @! n3 a6 s. S
ns_marquee.left=marqueewidth+8
; |! B2 b: J8 a+ ^9 U7 y. ^
}
% Y4 L0 a( |3 r( a: s( E' S% k
}
* |! C3 O! X/ j, j( K( N
% b& R8 J, [! V* f" [
if (iedom||document.layers){
3 D. ?/ q1 g) p0 U. Q4 D
with (document){
+ x. z. U8 c, _4 ~6 A
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
) W& v* N' p7 j% y, [* X/ |
if (iedom){
4 ~& \( u' b) F* L+ h8 m. M8 o4 L' N
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! d) n+ v' o' m7 I8 I5 L& h
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ I' y2 B; |# o1 Q
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 q' U4 f4 }9 ?6 K) l' ]
write('</div>')
, X8 Q% J" k: [6 G) L. g
}
: N4 |- \/ R( ?- J l
else if (document.layers){
, T6 E1 u! \4 O; v1 z, I
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
. t: B* x( [+ q2 H4 m7 a
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
0 @- l' s- S7 V- X: x, w$ ^0 X
write('</ilayer>')
) X4 e% j- ^* T* l
}
7 ~/ r1 ~$ I9 a. O' x& N+ R
document.write('</td></table>')
1 L& q# @* O9 o% A6 }
}
r0 d) Q: K+ w; A" L: k# u
}
" e$ ^. y9 }, N1 A$ Y: H
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2