标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
h2 @9 O( v, N5 {7 v
var marqueewidth=300
1 v$ r1 |( ^! a7 n; M4 |
//高度
' z+ s) v7 v7 S3 V2 c, W: e; o/ k2 o( E% J
var marqueeheight=25
3 X7 z- U9 n- ?! P4 z. U9 b
//速度(1-10)
% @9 S, g! I! B+ d
var marqueespeed=3
/ b/ _+ M0 E: T* S0 \) w7 z) W R( Q
//背景颜色
0 N: S8 K3 g# e. E1 ]
var marqueebgcolor="#FFFFFF"
5 n. a8 [+ I- h! P$ o# R
//是否能暂停 (0=no. 1=yes)?
P! u2 o( \: T4 ` }9 w" z
var pauseit=1
- p! C; f7 R) Q/ o
7 d2 X* I- b$ r
//修改显示内容
; B# d x3 u( g) }
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 |7 ?+ N# e- g, g- e" e, V
' P& F7 s# P t% t
6 z" X3 G( w) I! i! V
////下面不需改变////////////
. S7 i$ u) \" Q' b
( W$ n: ?9 W' q7 z) g
var copyspeed=marqueespeed
6 ~7 Q8 P: i5 J; z2 l) p$ [
var pausespeed=(pauseit==0)? copyspeed: 0
1 \; c0 D- C, e. P* ^2 @ b" U L( {, W, C
var iedom=document.all||document.getElementById
% p6 w6 O& J& q7 C
if (iedom)
* v& y( D$ p" c7 T
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
- M5 a4 l0 X, A) s4 b
var actualwidth=''
9 ?% E0 k3 l" l( d' x( C W- m: D
var cross_marquee, ns_marquee
" Y" K" x0 M2 O
/ F* S' z, k/ @% q1 l" W" u
function populate(){
" S. {! Y" O C+ [' `* B
if (iedom){
' l# N4 l! q; T& E8 u7 Y, |0 r
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! X) D9 V) D: z5 f n3 J3 y
cross_marquee.style.left=marqueewidth+8
0 Z) E4 o9 a6 |! U6 G# d/ F9 n
cross_marquee.innerHTML=marqueecontent
/ `% p3 n. B3 o8 ] i) v) X4 z& k
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" @' @" u5 f! [- ?
}
0 P0 q7 h# V" z: C
else if (document.layers){
p: A9 l8 k z' x; a% ^5 o
ns_marquee=document.ns_marquee.document.ns_marquee2
$ `8 z; j4 H- _! L J. n; s
ns_marquee.left=marqueewidth+8
, I! p% m8 S9 a ]
ns_marquee.document.write(marqueecontent)
2 p- n2 ]9 i4 B6 v( ~ | r1 M, w
ns_marquee.document.close()
4 l7 }7 q1 O" q, X" [, h6 m
actualwidth=ns_marquee.document.width
: n) O# b) n- U+ L4 W$ G
}
# f: y# \; }" C9 P: e
lefttime=setInterval("scrollmarquee()",20)
& g( X. B' L4 c
}
( I8 s$ _8 [6 y+ d
window.onload=populate
1 M* u/ a; J1 x0 l- z' w
1 ~' ~1 G0 R' } \% W9 ?6 ?
function scrollmarquee(){
$ h4 n1 `$ k# s( |
if (iedom){
. d0 h1 m7 w. @% a1 p% k+ [) ^% o
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
$ T8 r& d+ ]& x1 s
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
- {8 M" F! Q- `
else
: F& _9 x8 E2 K
cross_marquee.style.left=marqueewidth+8
8 f. b) G7 b- k) T( h
! c/ \. @% q* I, ?( @
}
& ]# ^% F1 m% A8 c- w" ^
else if (document.layers){
& y- }0 m$ Z+ g5 b! j& s' s
if (ns_marquee.left>(actualwidth*(-1)+8))
# @3 u& z* g: k6 G0 e. J+ c: n
ns_marquee.left-=copyspeed
) q0 \$ v4 q6 D# n R$ ]1 ^
else
, c% Q% T' V# k0 V( L }$ F$ j
ns_marquee.left=marqueewidth+8
, t3 P1 I* R2 Y. B$ U F( Z
}
& r* @, H' N! e' L
}
6 @" P, e9 ^1 q% ?, z* }! t5 u; B6 a8 L4 |
3 E! @$ O" N) l& p: D- v' d
if (iedom||document.layers){
# V& y+ }1 n; o/ n5 G
with (document){
: ]! V( `( c u/ ]; }/ ]
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
`" `7 S6 U! n( ^ ~, C
if (iedom){
' D! |" O" Z7 X% w$ @& K! C
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! A2 i. S5 l c
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
' z2 n- H' S7 _, `( N+ m
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# w- |6 d7 t# O0 |5 y& V/ }
write('</div>')
6 y$ j* b+ U' _2 I6 o! k
}
e; B. G' s! f/ d/ u
else if (document.layers){
- i3 Q% O) D# D0 m- @
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* z+ h( M& p) D+ t6 y) g
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 O" E5 S3 f& c2 T6 s. v, W! n1 Q
write('</ilayer>')
* [3 K9 i# l) A% m# }, j3 j6 O4 h
}
' x$ k5 r7 r' v' A: f! P: p; c* X
document.write('</td></table>')
% p Q6 E4 W: J' \. e0 M' \9 N
}
+ e3 Z/ M5 f! O) p, ]) C
}
$ |' k) V5 M. V
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2