标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
3 }% E6 y0 y% T+ N0 z' ?) ]
var marqueewidth=300
) W. R( X' ?' k2 u& a( F* y
//高度
/ l5 {4 o7 |) T: K
var marqueeheight=25
( J7 {- o4 _2 B& Y0 W6 y$ i
//速度(1-10)
' H1 o8 N- b- B. k0 T6 T8 i
var marqueespeed=3
5 I5 e; a! w' }& u" E& T$ g
//背景颜色
% r8 K [7 t/ K; m" S
var marqueebgcolor="#FFFFFF"
. t3 j2 w& h3 o7 z, L5 S5 F
//是否能暂停 (0=no. 1=yes)?
2 _! f: ^$ I; [" g: P
var pauseit=1
8 ^. m4 j' A5 I$ S( w
) \# c1 I# x; i: ?8 y$ i0 N: ?
//修改显示内容
: |" Q7 E, e5 Z3 J
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 C2 a, J# @: S
" |' X) A# N1 M9 ~8 L
- P7 F8 F5 n4 b+ u. \9 n }! g6 {2 O, D
////下面不需改变////////////
5 a1 t7 b! n4 h$ u2 N
: N, G2 O7 Z9 g3 B2 e0 o8 D8 z8 l+ d
var copyspeed=marqueespeed
5 V8 U$ s5 I: ^4 z" I+ Z
var pausespeed=(pauseit==0)? copyspeed: 0
; l" k" v2 B$ L. \
var iedom=document.all||document.getElementById
( A8 H, N* f+ Y, X( v
if (iedom)
6 J" B4 q0 p5 L9 L9 J% J8 @
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ }! V) q0 n" g# D+ e
var actualwidth=''
# q. h2 H6 {3 n0 v
var cross_marquee, ns_marquee
3 K5 o- b3 ?- {& p& M& z( P; D2 D/ `
% L- u0 [# S6 D2 z) z7 ~+ a
function populate(){
+ j2 Z# |+ F" U. f- V
if (iedom){
* _9 m& N- J3 ?1 s9 X, x: a% N
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 D& w! Z: f% f, o* Y
cross_marquee.style.left=marqueewidth+8
% D# G. Q& p7 Q' T; f/ C
cross_marquee.innerHTML=marqueecontent
# R; O# Q4 M7 _3 O2 @6 W! l2 f1 h) q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
- v# ^2 e, X' I
}
4 S/ L7 R z [5 |2 G1 B+ |" o
else if (document.layers){
- O, U% m& h9 W R9 |+ n
ns_marquee=document.ns_marquee.document.ns_marquee2
, L. A$ ?5 ]& u% a, ?2 ]
ns_marquee.left=marqueewidth+8
% J% ~) |; m; B$ [
ns_marquee.document.write(marqueecontent)
% J5 y) K* x! Y+ v- l/ D
ns_marquee.document.close()
& g. F! L% Y+ _$ @9 o
actualwidth=ns_marquee.document.width
) R U( T$ ?' f/ x
}
6 t, k! B6 B4 ~$ A2 n& A9 T) S8 ^
lefttime=setInterval("scrollmarquee()",20)
: Q4 v& o% f' N
}
& X4 u$ y: K0 Y
window.onload=populate
1 T) j4 x+ L/ G9 p; Y
& E* Q+ ?: m( K" S
function scrollmarquee(){
* o7 h2 m" F9 j3 {6 W' P; }$ @8 L
if (iedom){
4 g2 K- G; u; x/ _$ F' e+ u
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
" I' z9 u' n* H- Y |
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ j* z* G; W! v; l0 {
else
2 J4 T1 ~& `& p" j6 M
cross_marquee.style.left=marqueewidth+8
" S5 ]# u7 a' _ E p) k: c: u
; c: u* Z) D. J5 S; t
}
% U* e3 L- P' o# l- p. U
else if (document.layers){
7 E" ]) A+ [8 @3 u
if (ns_marquee.left>(actualwidth*(-1)+8))
( X9 R6 h. x/ H/ s
ns_marquee.left-=copyspeed
% A8 f1 C: Q& m
else
# A5 z; _5 P9 f0 q6 b$ I, h6 b$ \
ns_marquee.left=marqueewidth+8
' v2 N7 m& J5 n
}
$ t M, u% `. R, ?; d5 ]5 o
}
! {3 v V1 Q' K9 e8 u9 L
S; U: B5 F5 Q" a# {! W
if (iedom||document.layers){
: j2 j5 c. o. Z X
with (document){
# a+ O. S1 u p3 ~ I/ I
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' I9 T# a4 P; P& v
if (iedom){
7 [' h8 `: s3 D# w- M% J
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; n1 v8 n# [& c
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. A3 A4 r# m5 |$ v9 k6 v# w4 f
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
; u4 e( l6 l! y+ B/ E, \+ R
write('</div>')
2 R. S+ o7 s' a3 y4 T. o* |2 ^7 Z+ t
}
" a5 X9 Q0 u4 u$ A8 r
else if (document.layers){
1 y# C+ |4 e) _7 s* [+ g$ ]9 k; a
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
, U8 c" V. ]6 O/ P$ f& |
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
, n# Y& C" k# |. {& ^0 y! ?
write('</ilayer>')
; Y2 n4 d/ H# c E3 `6 Q% n
}
7 v( ~/ b* Y0 I' t8 H) e' I+ ^. ^, b
document.write('</td></table>')
! m" n6 m# }; j1 G$ D
}
% L& [ m8 t- G/ R) K
}
6 [6 c! [0 S3 Q( i* {* d& {4 C2 ?& i
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2