标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
) _+ V! c5 R) }& B5 N8 `0 b- `: x
var marqueewidth=300
* W; c2 e& R- P9 c( z
//高度
" U# D" X: \% [7 ]- O3 K
var marqueeheight=25
1 J7 I4 k; q3 h2 B
//速度(1-10)
3 g. U4 f5 d# r# J& B& C2 }
var marqueespeed=3
% ?; b& M9 _) U' W |9 [( U
//背景颜色
$ w1 s3 z V; V
var marqueebgcolor="#FFFFFF"
( C, ^& W: G2 A q% e. B8 `
//是否能暂停 (0=no. 1=yes)?
! ~/ ?& f2 b" X- v8 d( K
var pauseit=1
9 s& F% k8 Q" D6 ~; c9 e
4 F( Y, i+ e* @
//修改显示内容
% V! y8 Q- h9 |) T
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 v6 l# B9 X! |' O9 h
0 h3 v- J9 w, @9 H$ q* h9 P
( z) A1 m( d% G' u/ f( \
////下面不需改变////////////
/ l4 O+ P* R" W7 A e- r
4 a. w0 w; T' Y. E7 m
var copyspeed=marqueespeed
# P" r5 Q! I8 J/ B
var pausespeed=(pauseit==0)? copyspeed: 0
% m0 A, @! O3 R7 m- l/ m. F
var iedom=document.all||document.getElementById
" @8 @3 o! Z# Z$ G/ {2 u
if (iedom)
. J8 S f4 P/ B1 H! U7 S8 W: v! t! W
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
D/ Y. d* L4 w1 i$ W: ~2 Q2 i4 x
var actualwidth=''
I8 h" J$ I6 @6 ]5 |2 i
var cross_marquee, ns_marquee
% ]' n$ x. X! y- [7 V* `
, S+ G$ H: H& O( X( i. y; z
function populate(){
0 K( I# g9 \0 E! z9 }
if (iedom){
5 i( S2 u+ B& {
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
5 U9 b& B. L2 J
cross_marquee.style.left=marqueewidth+8
5 i" H/ u# T+ K. \5 H4 \
cross_marquee.innerHTML=marqueecontent
X- a5 `6 a6 d+ k9 g$ w+ W
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
8 e. ?, u5 Y: _
}
' j) Y' y4 G) o* u5 w
else if (document.layers){
) Q+ l. l- {8 G# |
ns_marquee=document.ns_marquee.document.ns_marquee2
3 @; s5 m% [2 h5 ]
ns_marquee.left=marqueewidth+8
5 p5 O8 J9 r+ ~- ?5 Y
ns_marquee.document.write(marqueecontent)
/ I3 v' W% V) h
ns_marquee.document.close()
9 x C& b; Y# ]+ R
actualwidth=ns_marquee.document.width
4 D% d5 s/ ~6 |5 ~. ?
}
, T$ L6 m* [4 B% R' A
lefttime=setInterval("scrollmarquee()",20)
9 _2 P( e2 B C. `! ?) g+ U
}
/ H6 z% x- ]; c% P# k' v& V& g
window.onload=populate
1 N9 H( E# n+ P5 D3 V9 c. c
5 e+ r( v( w, r4 m V: r
function scrollmarquee(){
0 D' w- X0 y9 C6 e5 K) d! Y
if (iedom){
6 _) B$ U7 V" p$ g [5 l
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
; x( w# Y4 p. d! G% F5 r( m! a
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ T6 i& C F) g* t" Y2 H: l- }6 u1 Y
else
7 R" D% S5 k7 Z& u$ O/ D% O
cross_marquee.style.left=marqueewidth+8
: i7 r' h4 t, V1 ^! O
0 e u' |1 W- ^/ g5 n
}
9 [& k' L4 D0 L2 ^" {" X6 z# O5 L
else if (document.layers){
" [- J! P4 {: }( E9 C) I* @
if (ns_marquee.left>(actualwidth*(-1)+8))
# m. J( [6 B# E% [# O! X3 e; d% Q
ns_marquee.left-=copyspeed
: T' D- v( X$ p# r4 m! I9 j: V
else
2 q0 Q! R) E4 R& ]
ns_marquee.left=marqueewidth+8
4 f7 Y9 J7 k+ w! y/ f8 b
}
, U+ n( x" N3 w8 Q6 K# a
}
% f/ C) N l: H
6 j5 O$ l; U6 \1 d- m
if (iedom||document.layers){
" a5 K0 \7 s6 b, F4 b. ^
with (document){
) q" }. E8 h- B& N( y+ {. V" K, T
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
9 ^# Y5 o3 f& t* V m" E" O
if (iedom){
( q& l' q; I0 Q+ H6 o! J3 N
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 M% R8 B' M3 U; {: @9 u
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 F0 R( n# ]# z9 n M* }3 p8 M
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ n& ]0 G l( W0 O
write('</div>')
& Y7 | e* \. i0 k
}
\1 G$ y( ]; k2 w
else if (document.layers){
9 b6 F6 z% W" v, x
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
( ?! d* `6 ]' x* C; u' [
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
5 \- y( K) B$ w! n
write('</ilayer>')
; A8 q- q4 r1 W
}
# @ q$ y6 L1 \$ ^4 c8 f
document.write('</td></table>')
8 C/ G7 w g+ C. b5 H4 ~% U
}
d* f h0 x% t# D7 M
}
& m3 q' |. d7 E9 s- O$ L# B1 x
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2