标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
, }- K4 M. y T& O
var marqueewidth=300
* ?* a8 V" D) @1 R% ]
//高度
# O$ X' c( O( N+ r3 i! s; s( O
var marqueeheight=25
n. P# V; t3 k" I4 W) z1 s
//速度(1-10)
b% ]2 F/ c$ y, ?2 j( O
var marqueespeed=3
7 c$ E d! n: R! y$ Q2 ^
//背景颜色
- x) e1 ~0 |6 @" ]+ K$ ?3 w
var marqueebgcolor="#FFFFFF"
- {- s8 a5 m F# s+ B* I
//是否能暂停 (0=no. 1=yes)?
3 W2 O" x' M+ v7 H4 d1 L b/ n
var pauseit=1
" h+ B: S% L6 p/ L6 Z% I
3 x* z- L+ |# r% j: i/ t; x
//修改显示内容
1 H/ z5 l" x8 q \9 b
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
9 Z# p* } H2 A4 `$ o
* E* f- B x5 R# [+ E$ p9 K8 Y; Q
9 K4 a. ]: B6 W1 i: k7 G
////下面不需改变////////////
5 ?4 R) E6 r1 f
( n- }0 c- T. {% I f
var copyspeed=marqueespeed
7 e" D' f9 E! ?& N1 N
var pausespeed=(pauseit==0)? copyspeed: 0
* o* I8 ^6 v$ |/ o
var iedom=document.all||document.getElementById
# }+ }$ w K% A. ~
if (iedom)
: v8 T: Z4 F9 j- n$ V! Q q2 S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
: O1 k% [7 k; B5 S& ^' r
var actualwidth=''
, }+ D8 l" h* w7 M8 d7 Y9 ~
var cross_marquee, ns_marquee
& b( T, _$ J. b7 {9 K* [' S+ v
0 T8 N7 [ R: ~
function populate(){
; b% W# {+ T C0 n( ~/ X
if (iedom){
8 i( [0 }* A* v' {9 P7 }" Q6 U2 d
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! _" g; K! p6 j8 ~
cross_marquee.style.left=marqueewidth+8
. _/ v% B+ F2 t: P' ^
cross_marquee.innerHTML=marqueecontent
& {% i2 i- q3 d4 K, K5 r* v
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
% Q+ q3 y; z: ^* h( b0 o
}
3 Y0 t) X. i7 M
else if (document.layers){
8 H- i. `4 _- S, \4 q" T* ^7 P
ns_marquee=document.ns_marquee.document.ns_marquee2
! K3 a9 @+ L, d! O. Q" T* j* T L
ns_marquee.left=marqueewidth+8
% S6 g. R' E* X0 [4 X$ R
ns_marquee.document.write(marqueecontent)
; p7 P% A9 E' N
ns_marquee.document.close()
* |4 N: k* s( A4 y0 x! T
actualwidth=ns_marquee.document.width
$ s2 d4 L( N% h. H8 u! O$ Y
}
7 p! e; X3 X; H' E m2 Y9 }
lefttime=setInterval("scrollmarquee()",20)
: l' s" X; ?+ c3 [- {7 C
}
+ @% D" H/ J/ u3 y1 @7 E
window.onload=populate
; H% U* J3 s2 b/ p' o/ H5 {
# L, N; {) C* t& Y8 j* r3 ?. k
function scrollmarquee(){
k) H6 V: G. G# s
if (iedom){
2 G7 I+ K# g% g V) m, f* e" F3 h1 z
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 b$ O7 o- d* [5 N$ {
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
; P9 K! F/ h4 \8 v% N" |. e d
else
0 T- u, j; d- P' n
cross_marquee.style.left=marqueewidth+8
: o4 ]0 v5 t4 A% J) ] f s8 C0 @$ \
# p% K% U8 ^4 }. t
}
6 z3 a. n& H# x
else if (document.layers){
0 L9 w( T! }$ n
if (ns_marquee.left>(actualwidth*(-1)+8))
7 y& m; J0 J8 A ^6 e3 S
ns_marquee.left-=copyspeed
; e: N5 c' X. x3 H# e, K- i# J
else
! @5 V8 Q- o7 V! y
ns_marquee.left=marqueewidth+8
. ^, V( F4 P4 f0 [: U' M% k
}
: i) ?4 R* J9 u( G, v
}
% z& f* y9 o' Q
7 b0 a4 m7 A/ g ~; b) X
if (iedom||document.layers){
( O; c' j7 r1 [6 H: _" p( G
with (document){
& x' _( ~5 Y: q# H& @ J! E
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
) V& i4 W: a) x7 `' q5 {; l
if (iedom){
5 a4 r% X9 A. m% d+ `
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* o* N- v$ l% J1 l* g$ i; U1 A: G
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 O6 P" z7 P0 N( ~# w# N6 R
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' B1 W# n3 ^7 K! A& T+ c+ n: E" H
write('</div>')
) r# F2 ], x5 \& p/ C0 y2 D0 M
}
! q2 c w& C3 Z) m- h/ U" ]
else if (document.layers){
/ @5 m+ r# n- ~6 z L% q; d
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
' S Z3 l! Z( q" H5 \4 v
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 e5 [9 l; a0 H* N; H: f1 V1 ?% F
write('</ilayer>')
n: A# Z! z- J) i, A
}
9 {: y: O& x( b4 O& B% u
document.write('</td></table>')
; ?. Q, X& t- p9 Q2 R
}
6 h* c5 R" M, a* o& S4 s; w
}
6 L( j4 N c5 h4 l
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2