标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
8 o5 z* }' e; M
var marqueewidth=300
, `* c0 N6 _( ~
//高度
$ w; ?4 E& S9 W7 J9 ~( {
var marqueeheight=25
5 X$ ]( A8 r: N4 o8 i8 H( ]6 S
//速度(1-10)
3 d, |( I! A0 e1 y }" ^; C4 s
var marqueespeed=3
- L% r5 y( V8 u7 _; ^; G7 N0 W
//背景颜色
7 G7 H6 R p/ {3 y+ g
var marqueebgcolor="#FFFFFF"
) B( K( z! D: J
//是否能暂停 (0=no. 1=yes)?
& g2 n. J9 v0 l( _7 A: K, b
var pauseit=1
, r7 W* {% p5 k+ I
7 W- @& s. Q$ V# Z; _) W9 W. Q
//修改显示内容
6 `1 T1 F: B1 b: i
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
Y* G; r- f( h2 D2 d
- Y1 g4 r+ e, A! {: k; K
% e( W! W3 ]- B: H4 F
////下面不需改变////////////
: Q/ c4 ~ V! ]4 P: d% \1 U
3 J* A: e4 B: P- ?, Y5 Q
var copyspeed=marqueespeed
& }& E8 v& p8 h, J
var pausespeed=(pauseit==0)? copyspeed: 0
. B$ [2 }( d# X# y! ?2 {$ e- t
var iedom=document.all||document.getElementById
; }$ G/ W# M8 a
if (iedom)
1 E# ~: d, X/ W# _
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
! f) `: B9 X1 t+ b/ Q& {8 f
var actualwidth=''
5 ?7 m& D0 ]0 B4 C6 q% `
var cross_marquee, ns_marquee
' S8 h% b; F4 Y* k n( o
$ L# m3 P" V0 @
function populate(){
$ y% j! V' W% h" d- u/ W: P6 p/ ^
if (iedom){
- |5 B* R$ Y/ B
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
2 @9 Q6 n$ j. j- W
cross_marquee.style.left=marqueewidth+8
( D" j h: A5 J6 k7 A
cross_marquee.innerHTML=marqueecontent
! f8 C( P0 m4 H S0 s1 P
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! i& H) u8 q+ I
}
6 d# L1 i3 T. R. z9 \! e: ]2 |
else if (document.layers){
2 e7 {" d# c; ]2 C. e) N
ns_marquee=document.ns_marquee.document.ns_marquee2
4 n7 c6 C1 F+ q
ns_marquee.left=marqueewidth+8
; w' n, M% x# C- E* i4 ?
ns_marquee.document.write(marqueecontent)
9 H8 |) ^) ` L0 C" o9 @
ns_marquee.document.close()
& ?( O6 ^# ?& R/ N8 | T
actualwidth=ns_marquee.document.width
" n1 R# C) R+ X, Y Q* q
}
( n7 Z% H2 a* P( _/ ~9 h1 Y
lefttime=setInterval("scrollmarquee()",20)
8 @$ m, u+ ~, N) c* y
}
* V) z5 L3 T3 t; [. h
window.onload=populate
* M$ N# Q: F5 b ~: Y
$ i" X W' J6 z
function scrollmarquee(){
! {. S1 k" h; G8 V& c' |8 P+ j* P
if (iedom){
' F3 N4 `/ g/ I
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
+ \( D' \8 ]: L$ `( T+ M
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
- S* u. S/ w3 w8 Z
else
$ ?: ?8 P& F2 E0 [ o& X# C
cross_marquee.style.left=marqueewidth+8
. f/ }9 m/ t" @1 U I5 ~
6 g5 n, L; k9 B/ d" w0 V, ?
}
1 f2 X0 r. p6 q C& e7 [5 W2 ~
else if (document.layers){
3 _7 o9 t5 c' P5 Y* v. R+ I
if (ns_marquee.left>(actualwidth*(-1)+8))
8 g- J( \6 M% N- O6 K& p' Y
ns_marquee.left-=copyspeed
% b) N; J& Z* m
else
6 g; p6 R9 B" x! H- c" D6 Y6 E4 P. @ y
ns_marquee.left=marqueewidth+8
# `% ?- B D# x9 R3 e% C
}
1 a: s$ E1 w6 A+ V3 R3 S7 z5 @ v. |
}
+ R8 }& B! k! I
8 m0 H1 q, U" Z, t( X2 v3 ^8 C. ~
if (iedom||document.layers){
% F' g0 K7 {1 o! n
with (document){
! C! @1 u2 { w- P/ g$ D( Y1 r
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
2 |$ o0 t, W {% d% l* `8 m
if (iedom){
( t" e5 l% Q% g$ u7 Z' u
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 t9 T+ y9 [, t
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
, i, u# E0 w4 B- M9 @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 Z1 O+ a8 S2 N' v5 M
write('</div>')
# o& ?/ ?% g; i7 E6 ?
}
, e. W9 H" w# k* m
else if (document.layers){
2 G! S8 @# R0 z9 {1 J/ E, |. {. y
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
& \. n3 q9 B- X: t
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 T H9 U- @% W) @: ^8 V
write('</ilayer>')
) T0 i( G# `! w' x6 f: T4 E4 v
}
4 I: s$ `1 R ?6 o+ y
document.write('</td></table>')
8 C' ^1 x6 ]1 ?3 B8 o0 i
}
: Q% `. c. Z( F a( E
}
9 [* G3 Q/ E9 Q+ ?( t
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2