标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
( M8 a3 [# R, e' Z O* t b0 C
var marqueewidth=300
! w. i- c( ~; H1 r$ k7 U1 J7 D
//高度
1 Q, t* u8 M G7 e& k
var marqueeheight=25
( c0 b; _# w$ l
//速度(1-10)
6 Z! {) M& [4 P9 l; x- x
var marqueespeed=3
- C" b' W1 |% D% d# B
//背景颜色
7 G8 X* F+ U. d8 C$ o
var marqueebgcolor="#FFFFFF"
' v9 {; U' o+ N6 L% y
//是否能暂停 (0=no. 1=yes)?
6 V9 ]1 M. {- U6 u4 V6 ~, Y
var pauseit=1
) Z5 g* N6 E3 J' c/ x- K
3 Z3 W& I; m5 l- D5 P$ l# v& g/ t
//修改显示内容
( Y; I3 L' f+ y
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 b1 H" {' [; Q, l7 e9 f
; H# r* h9 j8 \0 ?- e( D5 p
/ [& a1 C9 b0 j8 [1 {5 W
////下面不需改变////////////
7 B0 B/ a5 A, w1 s0 y
- y# ^; H1 u! d% n
var copyspeed=marqueespeed
$ n$ U, z4 Y: L9 O" m
var pausespeed=(pauseit==0)? copyspeed: 0
+ `( U5 G. R3 X
var iedom=document.all||document.getElementById
. H! d" g1 S) }
if (iedom)
+ D2 r, \; y+ I4 ^9 [, I
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
# E- t! b* n$ X
var actualwidth=''
6 C5 ]& H F, m9 b, B% X. t! C) Z( t
var cross_marquee, ns_marquee
! J$ F/ S$ c6 m1 ~/ I* _
7 V5 [+ X% f, }/ F0 k
function populate(){
( P6 Y! O A7 w8 \3 d5 \# C2 q
if (iedom){
7 j, j0 w$ H0 f) J+ V, }! a
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
( @ E$ @! Q% W* @' O' S
cross_marquee.style.left=marqueewidth+8
6 X' Q# k* @+ {8 {! M: Q8 {0 @
cross_marquee.innerHTML=marqueecontent
2 t+ O [$ n& P/ O( u2 G
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
5 _# e0 U& u1 o% v y* J% r* K) V
}
! ] w$ U1 [- ~& p% A0 [+ [ L8 v
else if (document.layers){
2 ^, _0 u2 h! R/ p7 Y& H
ns_marquee=document.ns_marquee.document.ns_marquee2
. T( @. i8 K3 o" \- k
ns_marquee.left=marqueewidth+8
& S) Q8 S6 r ` D- p: d
ns_marquee.document.write(marqueecontent)
1 a. ] e( `+ d- T, r
ns_marquee.document.close()
0 m8 p. Q$ k& E/ M5 {) o
actualwidth=ns_marquee.document.width
, R" N; G" ]4 \7 u( S$ U- k
}
U1 ?8 \& D9 u- t; i% H4 }
lefttime=setInterval("scrollmarquee()",20)
; |& K! d: g1 R& y0 r
}
) ?: X1 m1 Q0 \6 L! i9 V
window.onload=populate
: y& F( s) G; m: Y- }
6 W0 M* d/ F' Z, ~7 R- A
function scrollmarquee(){
0 V2 ^4 b3 u2 x/ L' n& v
if (iedom){
9 ^' j( V2 ^9 V: C
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
9 `( I3 ^ F; {5 {. x6 s& [
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% b' m- D/ e i9 ^ N# ^. {
else
8 ~: ?8 J- R# u! U) i p
cross_marquee.style.left=marqueewidth+8
: P, B) x4 R; [. ^$ }0 k1 w
5 V6 `" R/ w, g$ G& S
}
' G: k5 l% z# v, g6 |
else if (document.layers){
" ^1 c' R2 A, u6 A! q
if (ns_marquee.left>(actualwidth*(-1)+8))
/ n& I$ I# V' q: h; r
ns_marquee.left-=copyspeed
; W, D1 S; p! @7 X
else
. d" x3 a4 m6 }6 H4 B4 u
ns_marquee.left=marqueewidth+8
4 p8 P& t5 W M* ^( y7 l! N2 f$ x+ p
}
/ J$ ?; ?. W3 d6 o
}
- E3 d1 y2 ~* n/ c( |$ m
8 E, h, Q/ g8 w4 h! T
if (iedom||document.layers){
5 f+ M5 v6 \/ U- o% g& Q3 A
with (document){
- `( M% v, N$ P9 w" ~
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ ]; [% D0 A5 x
if (iedom){
$ O% t9 D6 }2 Y! \4 H- n% w3 K
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 i* L9 I& Q; T8 z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- I3 r* ~6 f' _- d- P. e. K. `# j
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
1 J6 z& j6 h7 @; n3 w* a" V
write('</div>')
% t* W+ T9 ^4 v5 l/ D- U
}
: C; u5 O8 Z! S. q! K, c
else if (document.layers){
1 c9 _# C o4 C3 R7 t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
5 [, b& f: ]% p* s
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 q. ]' ?. M y
write('</ilayer>')
' U* F" P: e! \. N9 f
}
! J9 J. ]2 S+ F% y0 A N& w @$ @
document.write('</td></table>')
! ~3 y- x/ I% T. Z5 _6 z6 ~
}
: d5 i: M8 [5 p4 ]
}
, k. a% h5 D/ o3 ]3 d! E
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2