标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
& q: u8 H1 I0 R+ z6 D1 r% q
var marqueewidth=300
( s% p2 {& e1 ]$ ~, T3 q0 y, J
//高度
% o/ x4 N/ o# `9 ^8 |( J" s
var marqueeheight=25
& P# w6 C# A& Z3 M8 Z
//速度(1-10)
R/ c5 p" u6 a
var marqueespeed=3
) b. T; N! l# I
//背景颜色
% U9 b# p5 j) O H
var marqueebgcolor="#FFFFFF"
2 e2 k& \0 C8 q8 ^* i
//是否能暂停 (0=no. 1=yes)?
) \' X) Y0 s" D
var pauseit=1
. r* J# w; F# |0 P
5 H* \! S4 k' `0 k' ^8 F2 o/ n `# a
//修改显示内容
* [+ ~" B& J1 f1 m" O8 B3 C" ?$ o
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
8 b `3 l" ~/ I2 E
# P" Z. L6 Y4 ?/ `( Y; U* N( o
$ o* ~$ a& [' t% Z
////下面不需改变////////////
, U! S, X$ u9 f( _3 _5 x+ w0 `- _
9 p% d' `; j( ?! x9 W
var copyspeed=marqueespeed
: p. q" P; x4 o! `
var pausespeed=(pauseit==0)? copyspeed: 0
, e, r& p% Z9 E+ R" _
var iedom=document.all||document.getElementById
) B" n; m+ V' I- U! Z) g# T5 @/ |
if (iedom)
7 d7 `$ x) | o4 Q( v+ _+ c
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& q J/ ^8 s, B F! e
var actualwidth=''
3 h- D4 t1 h! c
var cross_marquee, ns_marquee
" H: w+ M; y1 z& W
0 G: @1 x- ^ v& y
function populate(){
2 J* {9 U5 d0 a4 Q/ V7 B
if (iedom){
. ~8 Y. _& r' {$ V' \ y4 P
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
' `) E5 `) n, ]# w/ T
cross_marquee.style.left=marqueewidth+8
/ e$ c& A1 Y, d2 m; O+ C
cross_marquee.innerHTML=marqueecontent
- l* A# W F6 L+ e4 I; N z- y. R
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 A! z0 g& [, k) V9 h& s
}
K# a8 c% t- M T
else if (document.layers){
* g* K1 a1 J3 G1 |! y& N
ns_marquee=document.ns_marquee.document.ns_marquee2
4 B+ M. s. ^$ |
ns_marquee.left=marqueewidth+8
1 G/ ?8 x5 l, U; \3 i
ns_marquee.document.write(marqueecontent)
# F9 ~2 |* k' ~
ns_marquee.document.close()
( q( [$ L0 [6 t% J* b' f
actualwidth=ns_marquee.document.width
3 S9 X+ A, C1 I! d5 P& B3 }& A2 j
}
$ h8 L) d/ a6 t5 P( D, ]
lefttime=setInterval("scrollmarquee()",20)
X0 V, q( ~* o0 j8 R$ m
}
7 J7 Z0 P4 Q. @+ x' U2 C: P* a
window.onload=populate
4 G( I8 M u- V+ Q( Y
5 \. ~# j* ]+ t1 j* W
function scrollmarquee(){
& w# N1 ^) E) G. \, f
if (iedom){
, z7 a' ~2 V/ O) R0 Y
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
. B& Y3 t& A8 N3 h
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
8 T1 G2 k T6 E, L) h+ y; p
else
' |7 p: {& g3 _( T8 a( D" m
cross_marquee.style.left=marqueewidth+8
6 J Q7 D, L* h; ~7 {
! F5 b) W- [ N g7 q+ W
}
& T E K. K+ U O/ B
else if (document.layers){
5 u: x2 M% N' Q7 W& e
if (ns_marquee.left>(actualwidth*(-1)+8))
, X% w1 T5 u1 i# m+ Z
ns_marquee.left-=copyspeed
. x+ i& }. I) w1 X9 ^3 Z$ `. V
else
5 ~& @, i( _/ H, W$ W
ns_marquee.left=marqueewidth+8
4 U: U7 E* }; |: d$ u' O
}
: p& d+ |1 R( N% |! Z
}
$ ^" b% N5 o. a! E w& Q
* i1 ^, R" k, P: {7 ^+ K2 H
if (iedom||document.layers){
4 m! O& T2 w5 e
with (document){
4 `8 r& s" \# ^ ^
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
( n1 E7 e+ c8 l. N3 A! H& O
if (iedom){
$ ]+ z- |1 F& m% T. Z7 f3 m
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. I9 |+ }/ ^; Y& u0 B# \
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
) \" K* p2 L- n* `: P. s
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 F$ ]- a. ^+ H$ |0 `. m
write('</div>')
- D+ a6 @5 a% L7 _; g0 G2 G
}
* K) `, G) M# a( a' |! G: S" @
else if (document.layers){
0 u3 Q. ^" X" [
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
2 ^' D. t5 m( b4 `
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
& L% A+ K( p$ ^
write('</ilayer>')
0 M5 P# O+ [" E9 C
}
' B4 k8 C3 q# s! w& t2 U8 f1 y
document.write('</td></table>')
" w$ g/ Z$ f6 R' b7 V
}
: u7 ]4 W K0 e+ E1 O7 t' O: c8 ?2 H' Y
}
s2 `% e! x8 a/ k+ s* s
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2