返回列表 发帖

网页之跑马灯文字特效

//修改宽度
1 X  h& b" G* J, s# `var marqueewidth=300, m/ A  [5 e. k* F7 g
//高度
! L7 c/ P0 }+ z7 a  x6 tvar marqueeheight=25
7 D7 {+ w; Y8 \//速度(1-10)
3 L* b) {# ]) o! ]5 Y+ Jvar marqueespeed=3; a/ j; y7 T4 H- a. R- ^
//背景颜色0 f2 e3 y0 ~7 c) r- V9 d
var marqueebgcolor="#FFFFFF"5 [( @0 t; J% I" G" |
//是否能暂停 (0=no. 1=yes)?; N7 j: k  U8 [9 Q; {
var pauseit=1
5 t! K% w6 ]! Q0 F* r3 a
" C/ A) Z6 C. ?. Y, E$ K% ^5 ?//修改显示内容
6 L3 M0 w- _( ivar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'% C8 ~( W9 f6 |  [  p5 b

0 d2 T. w6 ?) _6 ]
% |3 @! d$ E( b: J% J0 D& H& R////下面不需改变////////////& Q. F# F8 w5 n( \

6 Y- d& X  b1 H0 xvar copyspeed=marqueespeed. z- m9 `  `- V$ ]  F' Z/ v
var pausespeed=(pauseit==0)? copyspeed: 0+ L6 c) R( }/ y2 e& E5 _) G
var iedom=document.all||document.getElementById( k# D7 x6 `/ v, r& Q$ ]- ^
if (iedom)
* h: }3 K' V4 D  G0 R& udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& O) a9 G6 _& y0 m' `5 ~var actualwidth=''
# U8 Y7 L& N- D1 \( o2 d7 o5 d" |var cross_marquee, ns_marquee% U# I% f+ X  [& I, v

2 u$ X  P; x8 H' Y1 Q- @function populate(){
$ G1 L& I1 s8 Y8 X2 Z! [) j1 Iif (iedom){& q. U' d# d/ C9 \2 i
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
# I& T- ?5 ]9 B, M, [- f+ Xcross_marquee.style.left=marqueewidth+8- R& U* G4 p2 k8 `
cross_marquee.innerHTML=marqueecontent
6 |: V% W' \, y9 Nactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
& w  s- z8 N' q* Z# l& l}1 `! u  L6 o+ B% f& o
else if (document.layers){* L* N$ r" f0 B4 m
ns_marquee=document.ns_marquee.document.ns_marquee2
6 M* y9 l* l: p. ?ns_marquee.left=marqueewidth+8* ^- ^$ r! ?( K( s
ns_marquee.document.write(marqueecontent)
: d: f! R- G9 |ns_marquee.document.close()! ^7 ?# q0 [( a* U. f  N
actualwidth=ns_marquee.document.width
$ l- \, R9 n9 U; i* y, X9 [}  G7 J' p8 w8 A# P& ?
lefttime=setInterval("scrollmarquee()",20), E1 a7 R# N9 G4 T+ h
}' v: E( Q3 ~" v
window.onload=populate
4 `8 Q( n6 U3 M. Y; N. b3 o
  z0 l# |1 S; z- A5 m" G6 [/ rfunction scrollmarquee(){% q, g" P" z% q- r( p* j, g$ m8 `
if (iedom){
- |6 i5 @1 G( `if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))" Q  v. ^0 E7 E( d- i, n6 t
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed# h" F! ~7 `" j+ v
else, K- F' ^( S8 N+ i5 W( k1 G
cross_marquee.style.left=marqueewidth+85 p' D' b* q2 N) P! p1 F- V

& u4 N6 r- U/ [7 ?0 C6 }6 ^+ q}
& T' l/ k+ X( q/ Nelse if (document.layers){* ^, k/ I5 U& N+ ^- _2 S+ R
if (ns_marquee.left>(actualwidth*(-1)+8)): T  _& j3 c& ^6 x( C
ns_marquee.left-=copyspeed
. i: a- e- ?* u# E' Relse3 o9 O+ i$ N- ]# b  A
ns_marquee.left=marqueewidth+8% m! K: r1 W* Y" `
}
7 }! a# y9 ]2 B& z3 Y4 i}# z( z* X6 r+ W4 d4 i3 c5 H; O0 p

/ o  ^" q8 G% D' dif (iedom||document.layers){
# ~" m* \/ C- U1 E4 k" f) `% s* Ewith (document){
4 I0 Q1 F, I( O) y( Udocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')' o" |+ s( B# c! S6 _' f
if (iedom){5 a  M# V) ?7 [3 j' p% ], o) ~0 Q/ u+ f. `
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')' R) r# Z& f, a9 x% N1 [
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
, @1 n* x+ g& ^3 Vwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
, g5 b; x5 ]2 U7 O1 P: }0 fwrite('</div>')- I. W0 q) n. i
}
6 K+ ^) ?- Z1 v( n6 s  J# kelse if (document.layers){2 e% l- m9 }3 z# k8 I$ t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')& [6 S% |' c- W, T0 E  q
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>'); ~, Z; z' z) c& b3 }: w$ @- i0 x8 `
write('</ilayer>')% h. @4 J1 x/ z( L
}+ r7 f: J2 J# I  n% B& p" y! D
document.write('</td></table>')3 G( g$ z% N% M' U5 X& w/ ?
}
1 e* a# m0 J$ j0 G}1 K7 ^2 L2 z; b
</script>

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