标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
5 g d# \' O+ p3 p1 p
var marqueewidth=300
7 m! K6 ~: C3 _# S4 m
//高度
' }, ?. T1 b: [0 }
var marqueeheight=25
8 Q5 A/ X2 a6 ?1 ^0 l) t
//速度(1-10)
8 S1 y1 R; j1 {) x5 D: H
var marqueespeed=3
6 o' ^0 e5 b# ]8 A# w
//背景颜色
4 ~* T9 \4 m4 O. r# T1 j
var marqueebgcolor="#FFFFFF"
) D5 U& z M2 ^
//是否能暂停 (0=no. 1=yes)?
) v [: q: B5 v
var pauseit=1
- d" t) i$ v9 {* M7 g& T7 n
& ^3 |) W. e$ x6 b5 g; W
//修改显示内容
& `9 [2 z$ J# J( T! Y" i# G
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
/ g' o/ O3 n8 c5 \- I* \3 o7 E9 @
# V( M' [4 K7 e( F0 L. R5 g' ^
$ q2 X( z* X h! h
////下面不需改变////////////
: M- a( i0 ^! C6 R5 I5 T
8 ^0 [# A2 V* }5 R
var copyspeed=marqueespeed
- a7 D1 J% a$ ^4 L, }! l) x5 Z' J
var pausespeed=(pauseit==0)? copyspeed: 0
" x. b5 a& w9 o5 w- I
var iedom=document.all||document.getElementById
9 c( i# h7 m2 f* u* s; ]
if (iedom)
1 M+ a9 N) C: ~5 _% ?* [
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
F/ M8 f3 \( m% u9 v" |# ^
var actualwidth=''
) [4 N; ~# D, M+ _! b
var cross_marquee, ns_marquee
6 ~" U6 c" a; B; A. R. c5 h( E
4 y J& r0 ^3 J
function populate(){
+ |/ ^" u7 i1 E% H8 @
if (iedom){
" l8 N3 w2 ?+ O+ d
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
. T4 ]* @5 V. L# C; K
cross_marquee.style.left=marqueewidth+8
6 r: @; Y! Z+ i/ j$ ~7 Q5 l
cross_marquee.innerHTML=marqueecontent
; f; u. F/ |/ O; B# I' r
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( ]* I6 S, K. V. y
}
5 Z% U5 U) [8 ?5 i( E- V L6 I; T
else if (document.layers){
9 E7 q V7 L2 T! ^" g
ns_marquee=document.ns_marquee.document.ns_marquee2
+ z4 C. ?! V3 E! N3 z
ns_marquee.left=marqueewidth+8
* m" o- k; o5 I& N+ f' J6 @1 b m
ns_marquee.document.write(marqueecontent)
* N+ P9 ^) A$ f/ w1 k- R
ns_marquee.document.close()
3 `4 m, B4 z1 F, Q4 q" a
actualwidth=ns_marquee.document.width
: O( D, u- O; w/ a; G
}
8 `- A2 ?" P/ `5 s* [$ O! u
lefttime=setInterval("scrollmarquee()",20)
9 I9 {2 H3 o& R8 t
}
# l/ K4 y7 {4 n/ {' L9 [5 l) _
window.onload=populate
" u% m" N- M2 z8 h( J$ D) `6 o
, Z1 j8 _" O C& r0 H' H8 U, } `
function scrollmarquee(){
- H r+ Y Z, R* k2 V( I5 p* o
if (iedom){
+ i( O1 B" ]+ M
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 {. {8 _! b: N$ W1 q& t
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ R! ^3 K' |5 F
else
* E8 ^* Q ^" P5 b
cross_marquee.style.left=marqueewidth+8
- [# K/ q" n y- o; q
' i T' Q' n) L
}
& Y R$ |) D* _( x
else if (document.layers){
" D y9 A- i4 b; a. N
if (ns_marquee.left>(actualwidth*(-1)+8))
$ F9 g K' G* t$ b* g
ns_marquee.left-=copyspeed
$ G7 b( D6 M5 n* A# p0 v( a
else
' X8 M3 ^$ S+ I6 s5 ~
ns_marquee.left=marqueewidth+8
' g+ X, \( Y5 F f4 X$ M5 T5 _
}
4 m: r2 h% \! ?0 I% e
}
; I: R T- }" t6 Z* s Q6 H. ]7 Q
# ~6 G- A6 r# E3 q+ x/ ^, L0 _
if (iedom||document.layers){
5 w6 V) [$ J7 m( J. o$ e
with (document){
/ U+ _2 O0 e3 x4 A4 k4 O5 Q
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
. Z8 o- U, c' a$ {# e
if (iedom){
! e% [2 m P0 A' Y
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
" S4 _) y( U, n4 L9 ]' w: P+ V
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. A9 ^/ V+ @ j0 T% [5 Q
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
: D6 ~2 ~. j ]* F. r
write('</div>')
, m6 p& S' t" [9 \) n# H( H3 h
}
' l6 S" Q M( E, N/ K5 P
else if (document.layers){
8 R2 F6 P( B' F5 O$ z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ f& K' i( x/ k; t# e! \6 c C
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
* G: n& ` ^: l5 i5 P3 T# R7 z
write('</ilayer>')
6 M+ Y8 u9 V0 X- u( z% t ]& R
}
& c9 k% k! {0 R: Q
document.write('</td></table>')
3 t1 k7 T+ ?* F0 _, d
}
& A% B. X/ w# B1 I& A6 D
}
- t& \9 y- @ V
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2