返回列表 发帖

网页之跑马灯文字特效

//修改宽度
9 e9 B  M; N  ^4 E' w' c9 m: cvar marqueewidth=300
. }; Y$ W! t) j( O//高度- C3 c. n; v* D& U; \3 t
var marqueeheight=25. ~+ c% |* g% ?3 k( ]+ `
//速度(1-10)
' J) c* I  H4 f4 [+ _var marqueespeed=3
3 A$ u4 ~9 n& O# F6 a& m//背景颜色
# A: [/ N6 E1 D( i( `# hvar marqueebgcolor="#FFFFFF"* }1 y1 b/ L7 q9 s  C* D3 y8 Q& Y
//是否能暂停 (0=no. 1=yes)?0 h) X- P' S1 u, Y1 L
var pauseit=1
7 M: F* [' u8 ~3 |# v; j' Z. A9 f- b3 C! z
//修改显示内容
* M* @, p0 ]1 V  `  jvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>') G+ D0 u0 C5 Q9 T8 t& t

+ H8 w5 Y! f8 n9 @
9 S7 _' }5 r, G////下面不需改变////////////
1 ]; V* e. m9 V9 v2 \% z. a' B1 _% o) |; o
var copyspeed=marqueespeed" @" @; L0 l# V- v& v5 D! N1 s7 A# S
var pausespeed=(pauseit==0)? copyspeed: 0
! O5 s- Q: i1 g& tvar iedom=document.all||document.getElementById
& s8 L& x* W5 }5 \" ^3 Fif (iedom)
8 H9 y4 k3 ?5 V4 N' Adocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')5 i9 A) M1 \& r1 j. @- M
var actualwidth=''8 e3 M7 H' _: j& f8 p6 d
var cross_marquee, ns_marquee
8 @& S, Q  ~/ A4 F( W* S8 T) c1 C) W7 B% |: [4 I! T' \; r; ^' a
function populate(){
( L" s. W8 ~/ k9 mif (iedom){5 y& l' V0 ]$ {5 g8 G% s
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee/ f) L- M* O4 ]2 y# Z
cross_marquee.style.left=marqueewidth+83 }$ a, o: K9 V% u
cross_marquee.innerHTML=marqueecontent
, l( _1 v6 j* K' {2 Factualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth9 U/ z/ A; H+ l2 Z1 Q. i1 W
}
9 Z* r! o  [* Relse if (document.layers){
3 s$ `- L1 M$ X7 E( h* Z  zns_marquee=document.ns_marquee.document.ns_marquee2
7 e  u& ^6 P+ t! t- Q4 k  Dns_marquee.left=marqueewidth+82 S3 c* f% ?, H( k
ns_marquee.document.write(marqueecontent)
4 A$ o. p; S% q& `" bns_marquee.document.close()! o* i/ n/ }8 J+ Q. t) a/ c
actualwidth=ns_marquee.document.width0 w, b" p) ]& ]; v" ?( a3 l
}
3 V/ c: Q" {( c6 l! flefttime=setInterval("scrollmarquee()",20)+ b$ E% W; ~- E) _" M! f
}
: k  T( D' l. ]6 J6 B$ v5 i7 ^window.onload=populate
% S- _% Y9 o; B# Z3 x" \, E/ v" j' p0 t6 m6 R
function scrollmarquee(){
0 Z# A2 X' |* H5 R+ M/ ]if (iedom){/ D3 Z- A+ G# d. O1 X! ?# N) L
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8)). ]/ {: z) {5 W, F  I( {
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed% J2 Q% p! P8 j3 }3 A! K0 c
else1 H# N, {3 H6 R. C+ g
cross_marquee.style.left=marqueewidth+87 `* ^! E! [/ K( `4 |: s% f+ j
( r2 e' U( |5 L( B8 z! \4 n
}- G& w8 Y' X' r
else if (document.layers){
7 J8 i( C2 `) u3 \# Q0 J" {3 p" Oif (ns_marquee.left>(actualwidth*(-1)+8))9 m. T4 J' m: G& b2 R- \
ns_marquee.left-=copyspeed
3 r1 Z% t1 ]& i7 X) oelse
$ F9 L* D" }! v, ?ns_marquee.left=marqueewidth+85 Y5 o0 u$ J, Z5 g6 m( B9 T
}
7 p! n7 q7 a% G}
. Q  \* Q; Q/ H7 {/ U1 p1 ~2 n4 `, `: E- X3 u% x, x0 G5 E, ^- P
if (iedom||document.layers){; o6 ^/ Y& ], n' r5 ]* m5 K
with (document){
: _+ F1 Z, y6 c/ g. I3 Fdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
, X! Q4 ?$ C  s) zif (iedom){
. X7 z$ P/ Z8 S7 d5 p) F$ zwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* R* a* M+ y& K5 b& x7 F( l6 Xwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')  t, }! A# U; W6 C
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 y$ v( i8 }2 \& a8 Iwrite('</div>')) h  v* d. E; n9 z6 `$ g
}
4 I. c% J1 y) l2 h4 ~else if (document.layers){2 H: j3 ~7 f1 X  e1 R5 V2 V
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')7 i) k) H4 H6 J: E* Y
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. u2 |- z. u  R6 k- B( R0 W+ j4 Bwrite('</ilayer>')( [0 p& J, D' V# v/ T# v. V
}+ Q7 a( \; t, B5 J$ m8 Q3 n; Q
document.write('</td></table>')
* A% x/ m! k/ g. v0 g0 \}
0 A- \$ v" D; i; a  x6 K- A}) _7 s) Q: J/ J* @
</script>

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