标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
& t* Z2 h2 H6 ^7 j1 B8 O
var marqueewidth=300
% D/ K8 y8 n% I; A3 O) c
//高度
3 X* F- m. O( a( b1 c% B* W
var marqueeheight=25
$ K2 v. G B9 W, n! j0 y
//速度(1-10)
/ x9 E! e' F) {! F F# h7 A+ V. E
var marqueespeed=3
$ D5 c7 @& y# S. X: q5 W9 i+ X' V; V
//背景颜色
0 c+ f, O) @3 o
var marqueebgcolor="#FFFFFF"
- g" g% o, `- D2 f; R) G N! t. j
//是否能暂停 (0=no. 1=yes)?
8 C/ c3 w+ B, F5 q( Q
var pauseit=1
5 L& }. l1 Q& Q( i$ p p
' C, e9 [/ D8 l0 @
//修改显示内容
$ ^$ t# |; P" j$ I& }4 h7 l P
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
& H9 @; `. i2 @) z; S* H% f
) E0 a: }8 u4 r3 h- a
; p( \3 \: ?8 F) O. }. F8 @2 A
////下面不需改变////////////
7 j2 k: V+ q' {/ _$ l
$ \% z$ z r5 s8 y4 d
var copyspeed=marqueespeed
2 ~5 [0 _) k$ l6 O8 G
var pausespeed=(pauseit==0)? copyspeed: 0
& r( c5 A3 e3 {& n2 F$ u. Q
var iedom=document.all||document.getElementById
" x! f2 F. r1 k9 E0 S4 r$ u4 F1 h
if (iedom)
; i- N' ^+ J! ?. t2 D
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
8 f/ p' x9 |$ Y) z* |5 S
var actualwidth=''
3 Q# C9 B* ^" }' l) T
var cross_marquee, ns_marquee
; N2 B/ A/ Q5 f: ~9 p {
% y( u" J' t2 e2 ~" ]( C
function populate(){
5 W) S8 |7 T% a+ b+ X6 `1 p/ ?
if (iedom){
5 c" f5 ~+ J& n
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
, R T0 \0 | q1 B
cross_marquee.style.left=marqueewidth+8
3 N& R8 r) L: b* Q' d% W2 v
cross_marquee.innerHTML=marqueecontent
5 x9 A* b0 v0 S, s4 z' {- z
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
; n; H& ?6 z9 P6 A
}
2 _% J6 ]7 x0 ~% n$ m$ [' M
else if (document.layers){
5 r( M; U* Y: T) z9 [1 c8 h% f
ns_marquee=document.ns_marquee.document.ns_marquee2
& s! \0 S8 ~( k
ns_marquee.left=marqueewidth+8
1 C/ p( I1 r# t$ V! N* l: {
ns_marquee.document.write(marqueecontent)
; l8 d" P- W# H$ z, ~4 X
ns_marquee.document.close()
) i4 y; Y. ]$ V/ K1 C9 ?- @
actualwidth=ns_marquee.document.width
6 m- E0 Q+ m. C' p% V; D
}
C* V" @+ Y; m$ A+ |* K: a/ s
lefttime=setInterval("scrollmarquee()",20)
4 I% C( p8 s) T5 O. a* i0 ?" g) c
}
) ^9 u' V% h& w& f- E* N
window.onload=populate
5 `, q( Z/ y) z2 L
. I* ^7 Y- A% m4 \. A; }
function scrollmarquee(){
: J0 Z p. @* W: l
if (iedom){
8 g8 ~3 m: w. _7 T: T
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
8 Q% g- G- I) I7 P- L0 h; G/ V
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
& r. Y& z' x! N/ Z
else
. n# \1 ^; t9 A0 W: U* J
cross_marquee.style.left=marqueewidth+8
* E& Q: X. f" @ |
2 L" n7 |8 l- \ j; Q
}
# Y# }4 H2 i1 D# u+ r* W5 i m
else if (document.layers){
! }+ y0 _/ I* l. V# g( F* K: m
if (ns_marquee.left>(actualwidth*(-1)+8))
0 }% a! I# U& m4 ?
ns_marquee.left-=copyspeed
0 G+ }( x, V5 ]( o" Z1 Z
else
- C1 E! j" w0 b1 Q* S' O) m( g
ns_marquee.left=marqueewidth+8
( ~" y& g, W5 O! C5 n! c* {
}
" E7 b! {2 h& {3 B% U: L9 r5 x
}
" {& C/ A- x! N Z) Y+ i
: `+ D' A! P" m
if (iedom||document.layers){
( \# P5 @: j$ n6 P+ I& J
with (document){
6 `% G" o) N+ h4 D0 R6 F' G0 ]
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ Q: C! v$ u" d9 l. B- Y
if (iedom){
4 r9 ?6 {2 W7 a: y* v
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! O# n1 ~) R3 u# I" _7 Q8 }7 n
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
" [" V5 s6 ]9 ?$ V$ x5 N
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
0 U2 i1 n& `9 t) O p' O3 {
write('</div>')
: h( |( p1 P% k
}
0 R" M2 V; g2 U3 G
else if (document.layers){
h) p4 w6 L( J2 ]- ]6 u
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
L1 |. C+ o4 }7 L0 E" l' {$ |
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
7 v. H* K& u$ r! l6 X# T3 A
write('</ilayer>')
+ X# N7 K8 M6 \ w' r2 e9 w* |9 h+ N
}
2 u! q [& l0 e; @# r: A. x e, d; C
document.write('</td></table>')
" ~4 f. o' y+ V _
}
/ f ~6 d) |% \1 l, C( e
}
" F/ q+ Q1 P" E5 T, v0 @
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2