Board logo

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

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

//修改宽度6 G4 Z6 E7 @  h: G. S3 z, F
var marqueewidth=300
2 M5 w- d9 F$ k- `2 R' p. \  _//高度8 r. @: ]4 L; O1 t% i! d
var marqueeheight=25; c  F. s7 E: Q5 i
//速度(1-10)5 w$ J2 D7 H1 X. Y) y) |
var marqueespeed=36 [7 M( K, b- a2 f6 ?
//背景颜色: `& T2 c/ w- F# H( u1 C8 t3 h% W1 t
var marqueebgcolor="#FFFFFF"; _4 I& y' U1 a' }" P! c
//是否能暂停 (0=no. 1=yes)?
* A, p8 b# n7 @var pauseit=1
. a0 j2 U# p; J  t- @
" n3 u' k0 O4 Q+ t//修改显示内容
# D; w6 `/ R$ dvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'; z4 u. z9 j- X! M) T4 T
7 h, O* m7 M6 ~% ?; e

# P; T# `9 m! `3 ^; s////下面不需改变////////////7 N+ P- m8 y0 Q7 o+ k
* L/ b' P/ [3 ^
var copyspeed=marqueespeed
" J! ]$ S$ G# d  }' V, b: d6 h4 nvar pausespeed=(pauseit==0)? copyspeed: 0
3 @% h5 H% u4 v; uvar iedom=document.all||document.getElementById
5 X# W+ A4 t7 |3 x" k& C1 u: Vif (iedom)
. T1 y9 m7 K* i! M4 I  {5 k" M6 vdocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>'). q% ~! N5 [: W0 N$ @
var actualwidth=''
. b. k: @% [6 X& i' rvar cross_marquee, ns_marquee7 I1 t" O: ]) _) x

/ ~# M. u. ~& G1 k- r4 V6 W# ^$ s& {function populate(){
; o3 Y* ^: b& Z  x% aif (iedom){
, M- Y+ p6 e4 A& m6 d$ l) qcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
  E& n  y  P/ A4 t% U# across_marquee.style.left=marqueewidth+88 T( w$ ]& d1 s2 W# O* N: L
cross_marquee.innerHTML=marqueecontent' ]$ s( Z9 g1 f; _+ ]% a! r5 _
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
+ t7 W+ R1 H0 k5 ^' a; [}
: m% k3 S' P  s. S4 Uelse if (document.layers){% I* a1 a0 U- w% w, f: ~/ I( }/ K3 W
ns_marquee=document.ns_marquee.document.ns_marquee2
4 N$ _  J/ Z" c! F  ans_marquee.left=marqueewidth+8
$ I$ ^( C# W$ |1 Vns_marquee.document.write(marqueecontent)6 _: m# _9 V8 }4 x( c; \$ y  L* N3 I7 N
ns_marquee.document.close(); p% V! {$ R; q* u) X, Z
actualwidth=ns_marquee.document.width
% j, @$ V7 O# c' Y) t}
" z* d& X/ M# |lefttime=setInterval("scrollmarquee()",20)
1 [) {' R; E- I8 h}5 K3 f( V8 b. S
window.onload=populate
6 q; q: H, G8 B. o' f6 r5 I& P/ Z! ?7 M6 \: _
function scrollmarquee(){1 O4 ?0 {* V1 L0 h7 f* w
if (iedom){& }6 c4 r1 |- N  K7 p! \0 r
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
  V+ x' W( \' p# C9 scross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
1 r3 {0 f; F% b+ z8 S- Belse6 O" Q4 Y. X( z. v
cross_marquee.style.left=marqueewidth+8
" n5 [8 |, B) V  L4 l$ j8 P, `& p" R2 ]2 T. O% \
}
$ v2 _5 @; [) }& F  y& qelse if (document.layers){/ g9 s/ r" B- ~) P7 n4 z
if (ns_marquee.left>(actualwidth*(-1)+8))
& m: R9 z" R7 I; T3 W  cns_marquee.left-=copyspeed
; d) ?0 w( X& N) Y0 jelse. a) o! F" A5 G% l7 T+ U
ns_marquee.left=marqueewidth+8/ K3 y7 `6 C* l8 p" h3 r0 j: h
}& l' d( R: ~, s
}
4 H) i8 k4 f7 O
! b# O( |5 M  l* I' }/ Y% u. K+ yif (iedom||document.layers){8 V# D# [! m4 a1 c
with (document){1 e+ R5 c4 P# Y8 E0 O
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
9 ^) R/ n$ E" Z+ l1 }  rif (iedom){
- [9 ^9 H8 ]  J! Y) kwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
# J  i# K8 t+ R5 {; C/ ?+ Gwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ e( F9 o. g+ {! V- W* d% X# @  |; m/ zwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')% ~3 z  ^1 p+ @; X3 i+ R; @. o
write('</div>')9 M/ r3 p0 {$ O7 m8 `+ G" o
}
* ]9 \; V; L7 a, c  Velse if (document.layers){5 `/ X. U4 [3 Y* J& ?
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')+ }; z, w! W6 c; m
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
2 g( P- y5 l; y9 \1 h% G9 r$ _* {write('</ilayer>')
9 B5 k: v6 D% f  C; S}* X" b3 R2 x7 y
document.write('</td></table>')1 V% ?  B: i: z/ C* C- f% y
}
1 Y2 \. G! i) r, o# }}# b4 V; T% K! C8 ?7 H. Z6 [7 s# T
</script>




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