标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
/ o6 K$ k( Q2 S( K& c
var marqueewidth=300
6 {- F( R6 O7 O+ l1 f9 T% e$ t
//高度
, E# p& ~6 D: m* i- V' W1 T
var marqueeheight=25
/ ~) V% R% Q' F3 s: `. }
//速度(1-10)
) ~0 r7 z& E( s/ [+ }, [, F
var marqueespeed=3
+ W- |9 V! w7 R2 V! \) w
//背景颜色
6 [ G+ A/ K0 y
var marqueebgcolor="#FFFFFF"
7 V" D" D: t3 |: [1 b4 b
//是否能暂停 (0=no. 1=yes)?
4 ]( x% s# B$ i/ z
var pauseit=1
- `. J4 i: f2 r+ j
4 j" X/ Q1 E* M8 b4 `8 j/ Q
//修改显示内容
/ t4 f+ z: L, l# a* b! d* k
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
2 y! j3 J% I, B( E) y$ g
7 N- z: C% @ \8 _( y$ j7 y
" G- U. n- |7 C5 p
////下面不需改变////////////
2 u4 ~3 e& K9 w0 o
+ u: k: Z: z$ b8 t7 W: \1 X. z1 Z
var copyspeed=marqueespeed
& m% l+ O5 i5 X9 Z4 v. s$ s8 Q
var pausespeed=(pauseit==0)? copyspeed: 0
1 t" ?$ g' x& Y$ \
var iedom=document.all||document.getElementById
- Q4 Y) T. b0 j1 i/ J" Y" K) u; M
if (iedom)
5 ^4 {& F3 l# R; P! [. q# X! K e8 @" P
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
! W( h, o8 o: h6 Z6 ?8 u6 P
var actualwidth=''
9 _; P% n8 X6 R* [8 e2 |; L- n4 z7 E
var cross_marquee, ns_marquee
0 K6 B( O; y; R0 n. t# x
2 p" ^8 O# N" Y' l" C# z q% q
function populate(){
" w! U- w! V- Y+ {; X: T3 {2 q
if (iedom){
; S* y$ f7 O+ T
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 M/ Y) I, r. o8 e7 y
cross_marquee.style.left=marqueewidth+8
% V2 T& O: O+ x8 U# y+ b
cross_marquee.innerHTML=marqueecontent
6 a8 x1 F5 h6 _0 }# v
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
/ ]$ {$ M" M# q, K7 x3 u5 A4 \+ b
}
2 f+ f: X/ N8 C) g
else if (document.layers){
# x# d# \9 n* D2 {
ns_marquee=document.ns_marquee.document.ns_marquee2
- S/ l* g, b# R( S
ns_marquee.left=marqueewidth+8
3 u9 [- S3 B; J9 J3 U3 Y4 `% P2 Z' K& Z
ns_marquee.document.write(marqueecontent)
: D& @8 E4 u5 s6 d
ns_marquee.document.close()
' W* E; R* |; X2 v) D/ v
actualwidth=ns_marquee.document.width
% L4 H) T+ J6 h6 X& ^
}
" K4 _" V" x4 y( p& E" l: a
lefttime=setInterval("scrollmarquee()",20)
! Z6 U7 o: T2 s/ B; I8 O- b
}
2 L* k* X+ [" q+ c! _
window.onload=populate
, ?' Z6 X4 _7 Y; |2 S" V/ f
, g, d, r& ~; ?
function scrollmarquee(){
r! |3 z' f. }3 \4 M
if (iedom){
$ n4 V: g0 c8 |2 d) ~" @
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 t; M4 \/ i7 w5 k& c
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
% N; `+ c* q* F1 L. z
else
4 u, S5 C2 @5 J `/ i6 C8 g
cross_marquee.style.left=marqueewidth+8
. K8 Q' [1 o: \6 U
/ g) |* n6 o* @) \
}
5 C; a, p- d7 M; ] V6 W8 V
else if (document.layers){
5 }/ W" e) |# H& l
if (ns_marquee.left>(actualwidth*(-1)+8))
. T6 P. E9 R& C
ns_marquee.left-=copyspeed
" a. E1 ?, V4 ^7 ?' ?
else
5 Q3 \3 V$ J2 N2 ^" Z
ns_marquee.left=marqueewidth+8
# ^8 Z) R+ H$ M- F# G
}
, F; X* q6 `7 y. y# f
}
: p6 v7 ?8 }2 K0 y
" M8 L( m" d7 J' I. i
if (iedom||document.layers){
' q- K7 b& W' E" M
with (document){
( R4 q, J. u. L2 f
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 V& V: l9 x* [ N$ U6 b
if (iedom){
9 { R0 }! z) B/ g# ?! l5 j
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
) ~( Y. A/ d& e8 q" ` S
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ y! Y0 \, N7 D$ n% d Y
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# k' y7 A& r$ r! P
write('</div>')
* K5 ~$ j: U. i# P% ]
}
( w- ? I, e) a* U& I) j
else if (document.layers){
6 a* L& K- H# a# g
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* q+ P K& m6 y: Y0 |% J+ W. u- v
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 I+ s. i3 O/ y; ~% d6 F4 `, }
write('</ilayer>')
7 o7 m! x( X( H
}
; {) u' M9 @" z
document.write('</td></table>')
- h3 L; {& W* N4 g5 E
}
% x2 v* g/ r, S. A0 p
}
$ c$ m6 ?5 N7 g: z
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2