返回列表 发帖

网页之跑马灯文字特效

//修改宽度1 H) v2 l9 Z& A, [$ i  q6 L! N( j
var marqueewidth=3006 j2 ^3 R' }7 n& }% G7 ~
//高度
8 m7 N8 x! |- b. C; l% f4 xvar marqueeheight=25' Y6 z& T) P  o) a. ?( R
//速度(1-10)
* i; ?: Z& A' o/ n' D' kvar marqueespeed=3
7 A% X7 I$ t- K0 ^- m$ V" o* F//背景颜色; d% w( B$ C- F8 S9 q1 g
var marqueebgcolor="#FFFFFF"
- F# U) ^, g/ E9 E' l0 Q//是否能暂停 (0=no. 1=yes)?
2 C/ [; p3 f4 N9 b; l& U: C: j8 fvar pauseit=1' h, E" [, S, a9 k

3 b- h5 p5 g, V//修改显示内容
0 p5 T: N+ Q5 Ivar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'5 e# l0 K% I: ?0 v7 h$ g+ v3 G
5 P7 e( y7 z! Z1 s& D+ i! O) h3 p

/ q; C1 x' f0 @. I: v////下面不需改变////////////  @) C) h6 ]: ^. m
7 v: X9 z7 X7 c" W, c$ z7 A
var copyspeed=marqueespeed" C( v1 j8 }2 {8 Y
var pausespeed=(pauseit==0)? copyspeed: 0+ W( H. G/ j; U2 B
var iedom=document.all||document.getElementById  Q! v0 B  y- l& s  ~
if (iedom)
9 A& j. f! @5 v0 u8 A0 ^! Udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
0 f: N  i# a# p1 @) n# d, vvar actualwidth=''
( o) x4 \4 |8 v4 r, wvar cross_marquee, ns_marquee
  W0 \- W( @# C
! y' S9 p$ X( u% M8 ]6 gfunction populate(){
0 e+ b5 e+ w. kif (iedom){
) m, s6 z7 \" L1 E! _cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
% Q  `, ?. R. _! ~cross_marquee.style.left=marqueewidth+8
6 z: W7 H) @5 f  qcross_marquee.innerHTML=marqueecontent
  w+ }. c2 f# f) d2 ^1 S0 U! Dactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( i- v" r* X  `: E0 d}5 C* C3 C% f5 b3 S
else if (document.layers){7 E- F* C& g1 Q& n8 B
ns_marquee=document.ns_marquee.document.ns_marquee2
5 f* {* B  D9 i4 d* cns_marquee.left=marqueewidth+8
2 V$ [" k+ `7 I0 X) S" ^ns_marquee.document.write(marqueecontent)! ^- e2 _3 D8 \# @
ns_marquee.document.close()& a) v5 k1 n1 Z5 N" Q9 x7 ?
actualwidth=ns_marquee.document.width' i7 p- Q# R+ p; w- F% y& L+ i/ Z
}5 i4 A1 U' b  H
lefttime=setInterval("scrollmarquee()",20)+ Z) I4 d6 |" n5 l  x2 Y
}0 f8 b" }& w4 Y" I) ^% d5 ^
window.onload=populate$ L, E" H- f5 G% x) K
) D% y1 l, b( r6 d6 f9 N$ N! l
function scrollmarquee(){' L! N, a) o) r& e* V/ I
if (iedom){, @" S, {( W! a. ~2 \/ i; K
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))8 V) ^2 T$ W' [4 G. Q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed# x: H" ]0 [: d6 i6 V$ B
else
# l7 x9 ^* Y7 I9 s$ Kcross_marquee.style.left=marqueewidth+8
/ V; Z! }+ B# M) g! ^3 N% z3 N, ^
}
, Y$ Q* {4 S1 e0 |9 Aelse if (document.layers){1 n3 X! u5 k0 s# {  Z8 i( t; `
if (ns_marquee.left>(actualwidth*(-1)+8))0 q  u; g. `& z  |! p
ns_marquee.left-=copyspeed: d  h( h; S6 Y( j
else9 F3 V' f! E/ A7 V0 _
ns_marquee.left=marqueewidth+8$ a3 O, r6 W% T1 l) j
}
' R/ e7 S% x1 f- M) ?. U}
( @6 {! x; G5 L+ P! o# @5 y* N2 V; ^- G5 b) f3 B
if (iedom||document.layers){
) N8 z' ^5 ^0 D/ M  Dwith (document){
. n/ t% M* ]0 m' m5 `1 Z: idocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ m0 E/ M0 G+ m7 M7 \; J9 qif (iedom){& w" r6 W5 [' o; ?1 J# ?3 c
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')9 S# ?0 {8 I; o& w1 z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')+ I" c+ I0 f$ L& a# [& d
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
5 z) u0 ?" V1 D6 pwrite('</div>')+ g( L" v0 h, f$ }  P2 q
}
1 F- [9 Q0 z+ P( R0 h+ S" a4 Yelse if (document.layers){* T0 g( z8 r! O, e2 {1 v
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
) T* E  x# ]+ ?2 d+ F# awrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 _# f* ?$ w6 |: c0 J. j& bwrite('</ilayer>')
+ B  d! a7 _* `. f/ h4 u- ~}. Z7 p% [4 M1 N
document.write('</td></table>')
. `. D4 o; N' W) X: z  z, r}
- B  f$ m* G1 q: q  u9 I}; n: u0 Z' h7 q% |% u! I
</script>

返回列表
【捌玖网络】已经运行: