Board logo

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

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

//修改宽度% Z, p, D% k, @: p8 ^& X  ]6 M3 V, J
var marqueewidth=300$ N- ^' u* e$ J$ q& G/ |4 k, C7 t
//高度
% U* a% j7 E- F) n, J' g+ E" ivar marqueeheight=25
1 n$ \0 [- B0 j, J  w: `) ?! g//速度(1-10); Z9 `3 d' y& Z( ~) C
var marqueespeed=3
- {) B7 E: c' F6 W//背景颜色& h; Q& I8 a6 j: w) C
var marqueebgcolor="#FFFFFF"# f+ D! E. l9 K  a8 s
//是否能暂停 (0=no. 1=yes)?' s+ x, a& c& p7 a- V: \0 `
var pauseit=1
5 y2 u' B- d6 Z9 [: ^. L) C  a  R: `& V. w, N* g- Q; n+ W1 }
//修改显示内容9 y* P$ T( {7 M: }
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'/ I5 u5 b/ U7 ~5 M/ U5 {
" t+ ~  ~1 s1 F( p/ t  o4 m

2 w* d' e2 S# z" b////下面不需改变////////////  p. p0 ?" A7 X) I

. t7 `$ p, t8 pvar copyspeed=marqueespeed. J7 j' L8 `7 I; q2 n9 k
var pausespeed=(pauseit==0)? copyspeed: 0% _. M: T  ~+ I' k1 [6 m% |$ U8 Q% A
var iedom=document.all||document.getElementById  g* n" O4 K/ T
if (iedom)
* `+ L& U4 @2 }% z: Udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')( ?) o$ d6 b% @/ ^+ d* E9 r
var actualwidth=''* W/ {% }) _! V* L& Z
var cross_marquee, ns_marquee3 [: }0 d! k" Y
  o& W: k2 O3 T
function populate(){
8 Z2 T1 V& f; w, Oif (iedom){
; [  w5 ?& n7 Dcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
5 o7 d  i& o1 R, c% zcross_marquee.style.left=marqueewidth+8
5 @2 d3 B5 C2 E9 across_marquee.innerHTML=marqueecontent
7 Q  u9 J8 B. Uactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. k3 z$ L  E7 n}9 s( `9 L9 l8 D
else if (document.layers){1 O+ F  Y6 y# f/ Z" y6 J
ns_marquee=document.ns_marquee.document.ns_marquee2
9 o( V$ i) A1 j1 t- T& W! nns_marquee.left=marqueewidth+8  G3 }0 Z2 }: j! [' \
ns_marquee.document.write(marqueecontent)
+ l! V( ~% k8 ~4 I3 W6 d; Xns_marquee.document.close()& K) z2 e$ B/ T4 ^  o4 l1 U" b3 ]
actualwidth=ns_marquee.document.width
, v6 j' f8 y  h- m5 h. v$ [+ r}
3 B0 m8 f: b" n& V" J. A* Slefttime=setInterval("scrollmarquee()",20)
( O& G+ |2 Z2 j  v}
1 f$ b" T/ Y1 ]' l- Ywindow.onload=populate
/ c; [' A( \4 n# M. U  N0 V$ h" Q, k" C7 S/ U4 V8 z
function scrollmarquee(){8 ^- w3 [2 ~8 @  m' s! y2 ^; s+ W1 l
if (iedom){+ R! P/ M. ~# N) P4 Y
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
+ U, I2 U* D8 V+ Kcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed/ h2 t) b6 e" O& ?4 `6 T
else+ N6 }1 X  o  k' ]  h* R
cross_marquee.style.left=marqueewidth+8! H: i' x2 C, \. p  X6 y& t, [
- Q  ^9 L  D' Z/ F/ n6 \
}* c" D: R. R  t1 D
else if (document.layers){( Y; G5 f- A  {8 j2 A6 m
if (ns_marquee.left>(actualwidth*(-1)+8))2 f5 z, \% f2 j7 x% z
ns_marquee.left-=copyspeed8 w! v% z$ D9 V; V3 o0 }0 b. _
else
; T6 A) t; h0 B/ jns_marquee.left=marqueewidth+8
# I7 ?. ?% P( _  j+ b) k7 r}, E4 G* ~5 ]3 r- O
}. F4 R/ ~( h- e2 \. k
4 z3 r0 G) S. Q9 t( ^1 \) _
if (iedom||document.layers){: o1 }* ^+ \) ?: \; \+ _; v2 \: o
with (document){8 A* n% m# X- H- a, e! m
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
& t) P: X5 r6 Q7 ~/ Y- z- K5 j/ oif (iedom){0 \5 ~$ y* l& |; _' ^
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')( T% E+ {& _3 ~+ y4 C# i) }
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; W* L5 F' A! G; H7 vwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')# @. T1 D1 l  O9 {+ }. b
write('</div>')
' q0 H: w/ e) _, H}9 \4 B6 d' u; M# D$ a# T
else if (document.layers){
5 v4 k( G/ R, Zwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')0 \. X: D- L1 H8 |+ O
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')% n% P1 }+ W( A4 {( u  P, M/ J! \
write('</ilayer>')
/ T) M# Y5 p, c6 K2 _8 T8 a' Z: T}
1 I% x5 y' N4 P1 H. U5 idocument.write('</td></table>')
% x. U5 d+ ~% A7 }}7 e2 Z, _6 Y4 s& o) {3 Q3 v
}
9 {! t. }  [8 d7 g( w</script>




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