标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
! o1 b. x! U2 K/ A8 F# N( v
var marqueewidth=300
: r. }! L8 v: K
//高度
) ]. y* ?9 j3 z5 Q3 {4 }% X6 \' h
var marqueeheight=25
5 Y( Q1 O7 I7 L" K
//速度(1-10)
, v0 H k2 {- [# t. R& l7 N6 e# ], k
var marqueespeed=3
# [, P0 T2 N6 |/ Y ~; x
//背景颜色
4 I/ k% t! B) f: n$ o& \8 g
var marqueebgcolor="#FFFFFF"
% A! _+ G. v. p9 h
//是否能暂停 (0=no. 1=yes)?
* j: Y1 b9 S6 w' x3 K
var pauseit=1
# c4 U4 J! Q$ A
+ H! p# x: S; b+ U5 k- F
//修改显示内容
! c2 T; a4 |4 X5 w
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
4 D3 I5 o; a0 v3 g2 n
: b8 {8 g& B7 X T" N; ?
+ B8 U1 A( b! B& A/ C8 H
////下面不需改变////////////
5 y+ e4 T+ R9 b8 b, N
9 j5 p* u' `6 g
var copyspeed=marqueespeed
/ J9 y) K0 ~7 i0 b" S
var pausespeed=(pauseit==0)? copyspeed: 0
! Z1 j5 H% i' H7 s& [
var iedom=document.all||document.getElementById
! W8 |( S; u3 u& j* E7 K
if (iedom)
) }& t* O6 n' h- l* U& ^' W: r
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' Z) e* q7 t9 s! I" |
var actualwidth=''
- O, M6 z! k' I* N K8 d
var cross_marquee, ns_marquee
# n( Z" L8 \& _
P. o3 ]$ l7 g( Q& Z( p3 Q
function populate(){
0 Q3 Q) R: E# u8 u5 s8 S% v
if (iedom){
( s0 _1 \( N9 v- C- ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ ~; ]; N& R5 q+ M n! b
cross_marquee.style.left=marqueewidth+8
9 i0 F% }1 @3 D4 o: E& U
cross_marquee.innerHTML=marqueecontent
2 |% |. i2 x2 H9 D% A g+ @
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
/ `+ e' K0 l; H1 z) l
}
* u3 \/ K7 d" ]+ R) \% d
else if (document.layers){
' a/ L3 S/ B+ P" n8 L6 y; N
ns_marquee=document.ns_marquee.document.ns_marquee2
1 k: v2 F* ?# N. s7 n! L
ns_marquee.left=marqueewidth+8
8 k* |7 ~; a3 w
ns_marquee.document.write(marqueecontent)
, | R/ [% h0 \/ ?* l( _
ns_marquee.document.close()
* y. K* Q7 T' C, u. p$ L
actualwidth=ns_marquee.document.width
8 E' I+ U( U3 ~1 x y
}
7 @; ?+ G ]- x/ b
lefttime=setInterval("scrollmarquee()",20)
% [ t" @! K1 }/ x5 h( H
}
3 z! b% i; f$ ~6 h U8 s/ q
window.onload=populate
6 T% Y: Y6 r8 C5 T( T! l
P. C6 M' B0 [/ b( D
function scrollmarquee(){
) H p% S, s& a) j8 N% x
if (iedom){
4 c' X9 S) l& ?7 x7 O2 P! u& B
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
$ s+ [% _2 a& R5 c- Y' X) r
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
* B8 Z" c/ x* ?5 R' d9 t' w. _
else
3 O* {: S2 L0 \* `: c5 V! v
cross_marquee.style.left=marqueewidth+8
7 U! r6 }! ]0 z: z( c4 p
! V+ _3 ?: g5 N( h* k- A ^5 x
}
+ R* o' k5 `/ v; Q. h) c
else if (document.layers){
0 M. v5 g) ?6 G- v" j
if (ns_marquee.left>(actualwidth*(-1)+8))
) c2 k3 g2 _5 g
ns_marquee.left-=copyspeed
" O+ Z3 z( t7 g& b3 F! K
else
7 o" o* E0 H+ s" ]( K
ns_marquee.left=marqueewidth+8
2 Q* G2 _( q! h8 r% K
}
1 u& y, R9 q: m0 @9 E8 U- m! L* H6 X
}
$ ~- n' ^0 z8 R% x
8 f7 f2 t% W0 l
if (iedom||document.layers){
6 l# C6 O1 w% [% h
with (document){
2 e7 D* z5 Z$ x" @
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
/ b# m9 H8 N' t
if (iedom){
6 q, I& ~" a/ W" e( y0 h- V2 d
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
" k3 D/ |' Y4 ^3 T: S8 f
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- _. |! }! a5 Y
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" T, z+ Q; `1 y: w, `- W# _+ H% c
write('</div>')
" G7 ?7 O! O" B0 b) D' l
}
9 q/ ~4 T/ K* C
else if (document.layers){
+ `* G; M6 o6 a
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
: z% E& o: V$ G/ W" x8 p2 _
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
/ t' ^, n. t, A# y: e3 G
write('</ilayer>')
K+ A1 ]$ w9 w8 Z
}
- f8 d2 ]2 J, C" I
document.write('</td></table>')
4 g/ c, Z$ f/ C) C
}
4 c) Q7 Z, h8 j- f7 ?2 O6 h l
}
3 b$ Z) N$ v5 B1 S
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2