Board logo

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

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

//修改宽度' c" o+ d+ d) n  z
var marqueewidth=300
6 ~$ e9 o- N0 R, P  v: I/ ?//高度6 a" W8 E% ^  x% n& O5 U/ f
var marqueeheight=25; W6 j" \9 ?) W1 q0 B, |
//速度(1-10)8 N9 n4 S+ i+ }, T/ i5 D1 p9 U
var marqueespeed=3
$ d, a- k6 B9 p: e//背景颜色, s  C% ~) g1 R; f1 E( g
var marqueebgcolor="#FFFFFF"+ M6 K! D! A( V  {* r; g
//是否能暂停 (0=no. 1=yes)?, ]( K9 f0 H5 A( j8 ?2 l; u. e
var pauseit=1& ^4 w% g# }. m6 S7 R! t

7 ]  }& K  e( W+ r0 A$ C//修改显示内容
  H9 V2 x! V+ G6 ?& R  |var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'8 D6 a, y* y0 P! H$ Q

: }& J# k1 B2 t" a$ D: j
2 G* S  X. h0 t" v  V+ U8 V3 o////下面不需改变////////////( \+ v. j) P) ?; k& E- h
0 ]$ X3 t5 a  ~7 y5 }
var copyspeed=marqueespeed
$ a% a+ T+ s0 t9 uvar pausespeed=(pauseit==0)? copyspeed: 0
8 u9 ]. m& e: h7 Y- W8 J) F$ t7 H% ]var iedom=document.all||document.getElementById
/ E% y$ \0 |" lif (iedom)& o1 C, e; h" _
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
9 ~& x4 q& g8 d6 i! Nvar actualwidth=''5 G% ]7 a+ }6 o. G( o: ~/ n
var cross_marquee, ns_marquee
' a) [) s/ G3 ]0 ^; d
3 S  k1 P6 n& c" bfunction populate(){
" {) ?, {  K# {5 H" D8 k0 E: `$ w% ~if (iedom){- `2 F: R/ q6 B6 f
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 I3 f" _- n9 Q' ^" d( ~cross_marquee.style.left=marqueewidth+8* N" p) T0 A: O: ~7 J& f$ D
cross_marquee.innerHTML=marqueecontent! u' \& [- a% Z8 R2 Q) u' b
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
1 t9 h! ^* `. f0 t- t: P}
3 M& S5 i" A& z5 D# q( Welse if (document.layers){+ X2 S8 v+ m0 @/ e1 V+ s
ns_marquee=document.ns_marquee.document.ns_marquee2
3 I) g8 {) e; J6 U. Yns_marquee.left=marqueewidth+8% K  s" l; Y; F* Y
ns_marquee.document.write(marqueecontent)$ r4 D6 ~) O2 D6 {! z; A9 h/ @' _
ns_marquee.document.close()7 V; ?9 l1 t6 d: ?9 N. N4 r% m) ]
actualwidth=ns_marquee.document.width
9 h9 |! T- W; Z2 b$ `/ n  }& W}4 h, h/ Z% p+ k* d+ e
lefttime=setInterval("scrollmarquee()",20)* R* @  E  v# m- c: e3 K  v# a
}; L- T/ _$ \" q" d5 G6 M
window.onload=populate
2 W! R& Q( o0 V% y6 ~1 I# j8 a: M  N" r4 Y' U, E
function scrollmarquee(){
9 k; X, t1 J" t2 I# M* ]# Hif (iedom){2 a0 Z8 E8 z7 ^' _! \2 |
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8)). [- z+ K6 f5 u. e7 |
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
2 D9 |4 d* V  l+ Xelse
% X. y  @' w" e8 P$ c$ w+ bcross_marquee.style.left=marqueewidth+87 [! e9 z+ n& b$ p7 ]
- R+ q, C! B4 ], G1 P6 H
}
% Z: S+ d* ], }, I& W8 {- Zelse if (document.layers){: L9 W; Z: \. Z
if (ns_marquee.left>(actualwidth*(-1)+8))
6 R& v( Z1 b+ C$ Y* qns_marquee.left-=copyspeed
, W7 N8 N3 w2 e  |; U) relse
; V3 E! u: f7 o( R! `" }6 V4 c+ Cns_marquee.left=marqueewidth+8; l" N0 M8 i# [1 j9 }
}: u' W4 m7 D# J, k# O
}
4 d1 x" I) v7 ?
6 }9 R$ h  H0 |- R! N: ^) vif (iedom||document.layers){
% p/ u8 o$ I3 V6 \: F5 T. Z3 ?with (document){
" a, w4 X$ a% Z1 a; z* H1 N( Bdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')4 I2 C7 R; g  z& D/ F
if (iedom){
2 D3 G5 ~" Y3 Gwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')$ |- e( ~. `# X1 l: i) T1 J$ l
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')# G7 ^( M! C$ T4 @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
; L! l3 a. y3 twrite('</div>')
( K( S+ X7 p+ J$ s) ~) Y}2 M% _* S0 a, N- d$ o' Q" W" G( j! G
else if (document.layers){$ W% `. n# ~( p; ~* o$ G( _# S
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
6 h1 z0 _( B0 |0 L: i" l: ~* l1 Vwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
& @) r6 b- I5 ywrite('</ilayer>')
* O0 T% N# X6 z  h}/ M2 v0 @  ^7 j7 ?
document.write('</td></table>')! V0 M! G& p( E9 M5 c. C3 u
}
2 I4 B7 \& ]8 U5 W5 e4 t}
: F/ H. ^0 ?$ ?3 L( F# z5 L</script>




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