Board logo

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

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

//修改宽度) f# v& F, W  {! X# g/ L6 C/ j
var marqueewidth=300" o( w! n* t$ z$ r  G$ h+ G; u
//高度+ h' {) R# }8 s! h7 A2 |$ U& ]( B
var marqueeheight=25  P8 ~2 |6 }$ ~# z5 u
//速度(1-10)2 U0 h  N0 _4 e1 e$ o0 n* N3 i9 {) \
var marqueespeed=38 @6 h- S7 G8 l/ I2 `5 m1 Q% k6 Z
//背景颜色
& K3 j* F; R3 I- H  p4 D& Cvar marqueebgcolor="#FFFFFF". m4 ~( q; u" B" J5 O+ R9 g8 {
//是否能暂停 (0=no. 1=yes)?
' c+ k0 Z9 K6 A; G! pvar pauseit=1" n/ D4 ~2 X; d. P8 N

5 I5 a. P# J% m8 G3 m, p7 f//修改显示内容' t: s5 ?+ }$ r& \7 E' f
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
# G- v& |/ v3 E4 v( `, h3 t
6 c; s  r! o7 U7 Y8 `/ i, {
; H8 P5 z2 Z+ v) i8 V- D////下面不需改变////////////" q4 {- R- q7 _# e- w. }

" j6 ]+ [1 R% D6 u0 D: tvar copyspeed=marqueespeed
5 P9 A; z" k8 Y$ I, p  V: f7 |var pausespeed=(pauseit==0)? copyspeed: 0$ F" ]: b; ^6 t# M: q2 @
var iedom=document.all||document.getElementById
: B9 k, C  W$ a, u, [- ]# Vif (iedom)/ T2 R+ k# w8 a* F& f
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
! @# l$ c) v; r. j$ dvar actualwidth=''( d7 L* i0 U$ f% t1 y/ k5 f  q. N
var cross_marquee, ns_marquee6 ]) C$ a  m( `8 I

7 d3 Y- Q2 J; N9 Qfunction populate(){7 ~$ b( _0 H% i  y: Y) n7 l
if (iedom){
1 @! V/ e. K7 ocross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee# R: ~. B; D9 h, ]% I
cross_marquee.style.left=marqueewidth+8/ O; E" O5 g" v1 x! }! I
cross_marquee.innerHTML=marqueecontent: p+ K4 }3 ~5 A$ a# p* Y6 {8 q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth+ P4 @% J7 s, G( @# H- A8 N- _
}) b7 w& j% S$ o) X( r- w& Q
else if (document.layers){
$ D, n1 i  x: K) X  n8 ]ns_marquee=document.ns_marquee.document.ns_marquee2+ \0 c6 \/ J/ R/ \
ns_marquee.left=marqueewidth+8$ o2 y4 X" x3 s$ O& W
ns_marquee.document.write(marqueecontent)9 B6 r: s6 u& v; Y0 N+ X
ns_marquee.document.close()
/ o7 }' A/ y  Xactualwidth=ns_marquee.document.width2 p) h7 N/ Z3 I
}
1 j, \) H9 p6 p, Ilefttime=setInterval("scrollmarquee()",20)
# `0 u' `1 @* Y! V! Z$ q5 e}0 u' U) V# y6 k1 G
window.onload=populate& Q$ _! P" w3 T9 q6 H" I' h

+ h3 h* p5 @3 I7 Z  Z* e) T+ n; kfunction scrollmarquee(){2 K1 y) x" ?% I  y8 {3 ~* \9 U
if (iedom){+ _' Y7 |+ j- z1 a3 |
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& {9 q6 f$ {& ]: i8 fcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed2 K4 Q% `9 x; ?5 C9 {" c5 t3 n' Q3 W
else
$ e2 f' y- Z$ Y5 y* v) Fcross_marquee.style.left=marqueewidth+8
' w9 P! _/ s; p8 s5 I$ b8 {1 M; }% ~1 E$ H
}
/ x6 M# w% x3 q8 y# m# n+ a! lelse if (document.layers){* j8 Y4 h4 O2 f
if (ns_marquee.left>(actualwidth*(-1)+8))& h9 r9 P, z& k$ o( Q
ns_marquee.left-=copyspeed
; ]9 P% `3 r: \7 K! y2 h8 gelse
/ p; ^9 a1 K+ s6 qns_marquee.left=marqueewidth+80 x3 t( ?& E6 A& m/ N
}
1 g. N% f, G# R/ P2 B3 q0 b3 O}7 f0 W0 \6 u- X- ]5 R  x- R: u7 t

6 C+ F3 e. p, z6 \) o# ~" }0 U# sif (iedom||document.layers){
4 p* D0 a* T' x  i! H; S3 Rwith (document){
: a0 h7 X8 J4 v; D. cdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')( S6 l; S" p& R
if (iedom){
. A. }+ O4 {  j' J3 U: Swrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 C8 Y6 z: B5 [write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">'). a% _( ?. {; Q3 ^, k# p9 j
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')- J+ a: c7 C7 F5 {
write('</div>')
8 C: X/ r; w* M( v+ }, R0 C}8 {' Q" v2 a$ r% n. T
else if (document.layers){! S7 p, [' @+ x8 |
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')$ ~+ H* j+ ?" [% j
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')) s. D! H" ~8 k, \! q# V: U% {
write('</ilayer>'); D4 b0 y4 k& M/ _/ I: x! N" a
}1 k" C3 v, G3 E: @1 N5 M5 M6 ^
document.write('</td></table>')1 s' P! V% `0 H4 \& k
}
% D; \3 ~+ _: f}  ]: h) l8 b* {' H+ w
</script>




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