标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
/ v% m+ p3 z4 ^, S) j; X3 e+ U1 \$ ~( w
var marqueewidth=300
1 W2 {4 O9 Y1 O6 z
//高度
) c( x1 |% \3 e' W3 T
var marqueeheight=25
% C: P# L, c4 y2 _) w/ I
//速度(1-10)
' |1 `* W+ l; S5 ]) I0 B
var marqueespeed=3
4 a0 _( L4 h1 h4 f0 ^7 G( {7 }
//背景颜色
: |3 ~4 ^1 t- o! X3 D
var marqueebgcolor="#FFFFFF"
+ R$ v, d* u9 }% ?4 r
//是否能暂停 (0=no. 1=yes)?
9 Z5 x3 T5 H, s3 `& g( o
var pauseit=1
( \6 n+ W7 k+ [) B
9 q" h* F" D# Q8 K
//修改显示内容
6 U% Z+ N: i$ e8 |" z
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
0 \( w0 J% s! B) |+ l3 L
( {. u; ^) \. k6 r" t" `9 L
' R7 ] c7 G( f
////下面不需改变////////////
3 d$ \/ _8 T3 R: P4 r6 k
% e1 ?0 F% n4 Q* @8 J5 u. l, V, U
var copyspeed=marqueespeed
, a2 _2 E, s7 y. n" n) t# g
var pausespeed=(pauseit==0)? copyspeed: 0
" e1 J# G! }5 ^% M8 W, m& E4 A. A
var iedom=document.all||document.getElementById
: d% M0 f9 `" b
if (iedom)
7 n. k& V) r* h5 ]" O& a0 ~
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ j$ U5 Y6 V! i M
var actualwidth=''
# D1 \# W& S* q. s
var cross_marquee, ns_marquee
1 Q0 U& B, F G3 Z# ?; d
2 ~9 S/ {$ l) a1 c
function populate(){
2 r2 b' b8 ]+ A( U* K6 C
if (iedom){
; i/ l) m" \7 P( g
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
# q' k6 }4 e+ B, }
cross_marquee.style.left=marqueewidth+8
, c* j2 q. H$ q, R
cross_marquee.innerHTML=marqueecontent
2 }4 f# |9 {3 e, [6 P X
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
1 u, w0 z& b8 K5 K8 l( [' U, d
}
B7 x) m1 x8 T7 T4 P, Q4 R0 @# c
else if (document.layers){
; q( ]3 j: V# X9 H. t
ns_marquee=document.ns_marquee.document.ns_marquee2
( f7 L( Q9 p3 |' t
ns_marquee.left=marqueewidth+8
2 ^5 l5 v, U4 H6 j- `9 D
ns_marquee.document.write(marqueecontent)
- s( ?5 s4 }" F0 g7 a$ M
ns_marquee.document.close()
: G& e$ C, A0 C: O: N, _3 `) P7 n
actualwidth=ns_marquee.document.width
1 z( B" Z; i" c8 _
}
" w/ k+ @. f+ R& h8 _
lefttime=setInterval("scrollmarquee()",20)
8 Z$ g \8 G8 }4 `- p* H
}
( m S# Q: D* m4 m! {
window.onload=populate
) h9 v8 B) |# S g; y
. _6 o2 z' `" b3 f/ |) h
function scrollmarquee(){
: M0 W; r& d. A/ p
if (iedom){
* z, n: F. l& w2 C* a: [
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 x# b/ L5 Y7 g3 Z8 V C9 T
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
" \' I. e0 }2 ^. R; ~
else
) R! I7 m3 g6 K, o* X8 i! _
cross_marquee.style.left=marqueewidth+8
/ h6 x) q4 S5 _9 p3 u
6 G9 ^1 j: K% a4 ]/ e
}
: _9 W4 U3 V- Q; a0 J" U7 N
else if (document.layers){
3 r" @5 u* [# @3 O
if (ns_marquee.left>(actualwidth*(-1)+8))
& ^5 ` G- l( d) q! ^ X; z( _( ?
ns_marquee.left-=copyspeed
$ e; `" k* {4 Y5 A: A0 G
else
7 I/ { [( V" [7 }3 b: h6 I: U
ns_marquee.left=marqueewidth+8
# [; H7 e; [- ]% Q
}
- a% t; l# Q9 m, f8 G7 u7 y
}
2 l( K, T8 N3 G6 T, Q
2 Y# `) ~4 O1 K; u5 U
if (iedom||document.layers){
3 q. ^: k S+ p2 o3 S, C9 j1 h* A
with (document){
, k' O0 J8 R0 B% t2 F8 j
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 _0 J! d3 Y4 g1 N1 ?( y& e9 ?
if (iedom){
* p& d0 I) n. g$ }0 r( J
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
1 `* S+ a0 C+ K! h# F! |3 i
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
9 t$ r/ i9 o' u- D/ ?# `
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
$ M' ]# {1 i: I3 X3 n
write('</div>')
( @4 S. Q U5 G4 s% e) A
}
: t1 h4 u r2 J% ]0 p+ n! l
else if (document.layers){
' q- a; F1 W4 N0 q; {3 `: R1 d i
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 h1 r" Q7 }+ p
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
/ V5 i! z8 s& p! W$ B5 f* |, x
write('</ilayer>')
# L% j$ R( {9 v( T
}
0 n) Z" O: w z' d2 \; M3 A
document.write('</td></table>')
% |0 h1 J0 s" O% ?2 f/ P
}
" i, v9 P1 c! D% Z5 X4 k0 @
}
8 ?/ f+ S6 Y; M P
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2