Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度
' i  q' [- S" A: k9 W9 kvar marqueewidth=300' ?* Y8 L$ F' B0 f- Y9 \3 P
//高度
( I9 h4 y: `& U. x! Gvar marqueeheight=25
2 L$ `) @' k, C- @5 z: B  F2 n- M//速度(1-10)
/ V- R3 i/ g: w# @var marqueespeed=3
5 |- Y3 Q2 k& J) ?  W3 @7 V. g//背景颜色
, o' J) a7 E/ i: Zvar marqueebgcolor="#FFFFFF"% z7 ]6 h. G9 V# U- C) \
//是否能暂停 (0=no. 1=yes)?
& |* f) x: x2 M5 c2 p' Y, wvar pauseit=1
% k( C2 s- P. O
$ i, n& H4 a+ v//修改显示内容
" N( W" t7 G% Xvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'% I1 a7 ]( o2 ~- h* U2 `8 |# x/ @
/ @4 m% o7 p' k

: e0 M# K; x3 h) V0 U4 ?, u////下面不需改变////////////
# O% e% w$ L2 u( b7 e
( W1 \6 b: f; {" m) vvar copyspeed=marqueespeed
! U5 J% f9 ?' G0 P4 y+ j7 bvar pausespeed=(pauseit==0)? copyspeed: 0
# ^$ N6 U5 T' S6 d) wvar iedom=document.all||document.getElementById
2 W) {7 I! h$ Y' d6 k# J" d. mif (iedom)( }/ c- C, q0 Q. k  ?6 X" c
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
4 h% @" R2 p1 w& C6 xvar actualwidth=''
' n1 ?- N, c# P; T4 F" b; q) D0 ^var cross_marquee, ns_marquee  H, ]# ]4 c& C& G
, f; Z+ g% S( I  E/ |
function populate(){
# }  {" L: w0 o! m$ r8 Sif (iedom){* [; {0 x! a9 j
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee% W" K) m7 l- N( y) L7 R% n
cross_marquee.style.left=marqueewidth+8
2 k9 `% k* T, L5 Pcross_marquee.innerHTML=marqueecontent
7 c  T( h. ^$ i3 O0 eactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth9 D4 q& h' z. C2 i; Z. b
}5 k! k6 t& `% B3 P
else if (document.layers){
6 j" U9 V) Q$ Xns_marquee=document.ns_marquee.document.ns_marquee2( r. ?, g. E2 l# X  S2 A
ns_marquee.left=marqueewidth+8; T& i$ o) m& W% h4 K8 x
ns_marquee.document.write(marqueecontent)( e1 O) B! H# Q8 o; k. i/ \. ^7 a
ns_marquee.document.close()
+ W0 Y- L' v. V' pactualwidth=ns_marquee.document.width" N6 {7 h0 ?6 P- n9 _! F. G
}
' T( k- T- P7 s  Q( R* }lefttime=setInterval("scrollmarquee()",20)
' f  R, k- i6 _2 d2 H/ f}
+ i! u  X+ @3 |- F" `window.onload=populate
$ h7 x* q5 L7 @; w$ J! r: n, ]  X+ }& N# r( M* Z. S
function scrollmarquee(){* z/ t+ k9 S, h) ]  t# y
if (iedom){# u$ a: M( ]: j% O3 a
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
. E% {: C& s( rcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed: P+ h! n  C% f+ b: e: e$ [! B
else: ]; q' M% n* i
cross_marquee.style.left=marqueewidth+86 q6 G1 {$ E* _  F) H+ h# X* f$ c/ O
3 A/ i, P5 l! [: q$ d7 a
}" D  u: {4 Z3 Z' [) L3 k" s7 n: C8 l
else if (document.layers){
% ?9 l1 F% T2 W- O: Z" hif (ns_marquee.left>(actualwidth*(-1)+8))
4 ~" i6 d& a+ k& b) Sns_marquee.left-=copyspeed
9 n, \+ f9 Q8 ~9 N$ Y1 ?7 c# zelse" T+ s4 X* ^( Y! J: n
ns_marquee.left=marqueewidth+86 A1 Q. t4 N+ V8 Z; |
}
6 w+ d$ K+ i7 t# c# d6 X. f8 X}! Y. |+ R$ n5 Q4 O+ v2 |0 k0 j

+ ~# K: s& O5 O% Z. h, Jif (iedom||document.layers){
6 g8 N7 ^8 r- v) Cwith (document){5 Z6 l0 A0 C9 S9 Y2 n
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
4 c5 }4 a( w% P  N# A: Iif (iedom){' D; t1 N; S7 t! ~$ K) B9 n
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')4 R7 r* w8 R; R+ d
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ [" I0 _- W9 c6 r1 Jwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
/ Q2 e) J8 y2 w2 w# o$ ?' J. c9 c: \write('</div>')9 f  n0 v# Z& t4 x! J# f! j4 v
}
8 V' K5 m" ~4 L/ qelse if (document.layers){$ {: N& H# ~) ?% u% Q2 K
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
: s1 {1 T* _" {8 cwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')- F- h8 {- }3 T6 H; y# [! j- E
write('</ilayer>')
- |# C! a; h: W* }! [( P}
3 O% B4 f/ {+ ?document.write('</td></table>')
, U5 ~% W. y* y* G, Q4 J: p}
0 A' T+ }, r- e}
$ K1 g; s" x# N7 _' |/ B6 z8 O# p</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2