标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
7 h7 n9 A# Q: a% k- O" q# o
var marqueewidth=300
0 V4 [; {9 f& s
//高度
: q, R& t, [ V) x1 c
var marqueeheight=25
2 u1 ~5 {8 |, @) \# n/ ?
//速度(1-10)
+ V8 {1 t6 J6 C6 v4 B6 t
var marqueespeed=3
! _" ^& v5 [8 V
//背景颜色
2 d- W: x8 m8 v9 M
var marqueebgcolor="#FFFFFF"
: U8 M! z6 N4 y0 H9 X0 K0 j) d: S
//是否能暂停 (0=no. 1=yes)?
. _$ b- z8 F' D" ?# R
var pauseit=1
! m% Y& R4 f7 U+ F; G! P
% o# S( ] p# ?; K$ q
//修改显示内容
' x+ U- \& |: |5 ^3 N
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 ]5 Q8 s, q3 V
+ o2 w2 h4 }0 c. O! H
. B: i" U+ j! H" p) h+ a
////下面不需改变////////////
6 R, Z8 A6 G5 {4 R# g Z
7 N) j/ g/ q; H: Z5 \2 `
var copyspeed=marqueespeed
1 z [& r* D; k- Q
var pausespeed=(pauseit==0)? copyspeed: 0
- q8 B0 M* R" V+ h
var iedom=document.all||document.getElementById
3 B: r( K3 W" h; ^. o
if (iedom)
. s( X" R Z# N, k
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
8 s' h' M# O9 U) X
var actualwidth=''
4 E- i# V/ T& _0 {" s, i0 j4 u* W! D
var cross_marquee, ns_marquee
P y. D9 E. [. s- |- s
& B: U1 _! h' D+ D. x$ N, `
function populate(){
: s% ^5 m! p5 C. O6 ]
if (iedom){
2 O9 z3 n0 z* Q7 Z+ h2 p( H, [. W
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
7 ~ L/ o0 \- c/ s
cross_marquee.style.left=marqueewidth+8
4 U( W3 Q6 `# ]9 V% I. |" ~ D
cross_marquee.innerHTML=marqueecontent
7 I" {0 q4 B' Z, U7 C* r6 K7 y
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! N" O( K+ J& ~2 f% K' [. z0 x
}
0 S. `+ h2 h0 d V$ f
else if (document.layers){
& h* Q, H4 E( g3 z8 y& `
ns_marquee=document.ns_marquee.document.ns_marquee2
' g( `3 @% O) g+ H$ F/ ]
ns_marquee.left=marqueewidth+8
: U- w2 {! g' b2 }4 y
ns_marquee.document.write(marqueecontent)
& [# \" L" R# s* `4 S- E5 \0 F. A. P
ns_marquee.document.close()
9 _% p+ m; w$ \/ }- I% r/ [; w
actualwidth=ns_marquee.document.width
% j5 }+ L- m: D
}
" n/ n* u9 {8 G- k0 Z2 p
lefttime=setInterval("scrollmarquee()",20)
4 P* U+ h, }$ U0 X
}
3 N! ~1 e7 l# Y. f' v0 h0 J
window.onload=populate
: Y# D2 t- M7 O$ F: r; u& k! W' d
* e, R2 n% _0 Y( e1 W1 N
function scrollmarquee(){
" [ I5 Q; G1 J
if (iedom){
# X# s) X I" t$ D9 A3 ?6 @. j$ K
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
- |5 s) ^. O) T8 R' c, Z
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
! q1 h! b7 I1 k: S
else
( T: e! m/ [7 ?
cross_marquee.style.left=marqueewidth+8
4 d: m) a% K p5 S& [
f3 R; p% ?6 `" N7 y7 Y3 T
}
, w$ ?8 L& G2 M0 _2 l9 h
else if (document.layers){
) u. h3 K: q& Z8 p/ R. H
if (ns_marquee.left>(actualwidth*(-1)+8))
% p8 d- W- [5 B2 n5 a
ns_marquee.left-=copyspeed
& V. }/ ]0 Q# s* U E5 C
else
" a+ P6 b- k* O# M) O
ns_marquee.left=marqueewidth+8
( e: N+ n* y r. Y1 C
}
$ X7 A" M1 p) I6 [) \! R& X
}
2 f- g4 d1 {7 D, E5 O
, K3 i9 F% ?. G. [- w9 {; Z
if (iedom||document.layers){
0 \6 H$ `( W1 t, o5 q) ^* q% e
with (document){
, ?, O! Y2 \$ j+ H6 d
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
; g) X# O+ t. ~) V# }0 [( u; a
if (iedom){
9 b( l5 ^' Z6 H9 O% |1 t
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ e9 x: P; F# ]! n- T# |% m/ i
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ ?( a. w$ X. m# g0 Y+ d) w7 Z
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 w8 k8 S: R2 Q0 G! F( q5 R
write('</div>')
7 ?% C$ ~" v: A) _0 p
}
8 g# a4 y* c7 l a7 O
else if (document.layers){
5 [. A5 L' q/ C2 K0 E# }
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
- r4 N9 k- ?5 E8 E6 F2 S, j& z
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
2 o5 y+ O) N2 j+ f
write('</ilayer>')
. N/ |6 X- n0 C
}
8 c, B7 R9 U/ c: U. W9 n
document.write('</td></table>')
# `+ F2 k$ r) P1 e
}
( N) w1 x) ], F- B/ @+ u
}
7 m1 l4 X9 `" b2 g _7 R
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2