标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
$ E+ `; Z8 [# N u; n
var marqueewidth=300
2 D6 a" }* m/ k$ j, A2 R2 e
//高度
* w9 x; [# j @" o, o
var marqueeheight=25
% r4 q, X' ~2 { F! M, q
//速度(1-10)
( g. H2 H: w- }* r1 Y
var marqueespeed=3
5 Q, j, j% l, Y6 D
//背景颜色
8 R, m* W0 S/ l- \, y# Y% O
var marqueebgcolor="#FFFFFF"
3 V) o/ }0 q' S1 _
//是否能暂停 (0=no. 1=yes)?
% W3 u7 M% Y3 s+ C1 V
var pauseit=1
; r; f" Z6 m& Y& A0 p, D
& p( e* r+ x4 t8 V% O; [+ \0 `
//修改显示内容
5 u9 w8 T3 S, C+ p" m. R g
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 P3 e4 V2 s( N& r& S
- K! @) E) M y2 K
& _% z: N2 c5 Y6 j+ F8 ?
////下面不需改变////////////
. ~) j1 H/ c& n/ Q7 \" E1 Y
n# ?" a4 q9 q" _, @
var copyspeed=marqueespeed
1 s: L' `9 L! l/ W+ d6 g/ t+ \
var pausespeed=(pauseit==0)? copyspeed: 0
/ }8 Q. s# q7 V- w3 s
var iedom=document.all||document.getElementById
* [' b" U, r' k( o; w
if (iedom)
: D- k. H$ j. d* j+ R; \& H, ]+ }
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
: N9 _/ @2 i" T
var actualwidth=''
( a W: `0 Q' f& O- W
var cross_marquee, ns_marquee
9 D& Q+ }, q+ b7 w9 s
# P6 q. k/ @8 l: x: V& o
function populate(){
$ ~! `! ~4 b: @2 j6 K
if (iedom){
( |$ @5 m& `+ C7 W% u- Q3 ^& c" W) Q7 R
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
- G1 y* j/ N4 ?+ q+ |9 e( F
cross_marquee.style.left=marqueewidth+8
, o/ ~/ u7 ?, s, E! ~0 L
cross_marquee.innerHTML=marqueecontent
4 d6 N2 [" s' g# A) [' x
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
* ~! P3 M1 ]1 ?! _+ A" k
}
( w; H4 ]+ }! z9 H0 u
else if (document.layers){
$ r# D! n7 j' S
ns_marquee=document.ns_marquee.document.ns_marquee2
5 C+ r( v' |; n. J3 F) D
ns_marquee.left=marqueewidth+8
* r$ n* q: B! C' r1 ?, ~9 ^
ns_marquee.document.write(marqueecontent)
) u) g# B9 {6 `, y5 m
ns_marquee.document.close()
0 k. a% y' [! ^% t0 q( }
actualwidth=ns_marquee.document.width
6 Z5 S5 w& Z2 L0 k
}
& s" r. j4 @% z
lefttime=setInterval("scrollmarquee()",20)
* ~1 @1 K, Y! Q' {/ w$ s
}
* m- K' i2 B0 L: R
window.onload=populate
* ^$ L ?: H, t T. m6 R S& m
; Y- ] ?+ T0 b8 t
function scrollmarquee(){
1 z$ [0 [* \' w: ]8 A! }
if (iedom){
+ p& p. A" |! F3 P0 _
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 g1 w+ ]* w6 F- K# }# W: t
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
! |; ?7 w( D# {# V5 Y" C. W! y" K
else
/ v6 z8 B' b7 s6 Y% m! p
cross_marquee.style.left=marqueewidth+8
" ?# F0 L9 g3 {4 [
6 t* x% o0 M7 ?: ?5 c/ Z
}
8 e8 i1 V/ P; z0 {; N
else if (document.layers){
) P3 ]* c1 K- U% Y" K3 x# U
if (ns_marquee.left>(actualwidth*(-1)+8))
; r1 m% ]. |! _' J2 t4 C
ns_marquee.left-=copyspeed
2 R6 ]" ~% `: k% M8 N( Q
else
7 z7 ~, e; r5 M5 |4 G
ns_marquee.left=marqueewidth+8
/ r/ G0 d5 A: o: L% K6 ]( V
}
) o8 `- a3 t( d% h1 M
}
2 P/ N8 }. [- E% `' B X% x
; k8 y6 H* d8 D5 h
if (iedom||document.layers){
( C* w/ p6 D X1 E4 j
with (document){
! G" V& d* k" f3 `2 o" N* x! a, K
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- Y! q6 \/ Q$ j- J: D' v4 y
if (iedom){
1 \( l/ W. M& E$ Z8 a, ^. b7 m8 s
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
: N, s- a: \1 ?/ f
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
2 e5 H+ J; D: Y& O8 j
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 |) @8 I3 r( O8 ^1 h( j
write('</div>')
9 z4 N9 `+ ~& W- J1 N! F
}
, D% Q! N. E- R
else if (document.layers){
3 ]. U* L O: T/ y# b: J, I
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
( _$ e: W' ^3 u# h6 {) z
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 D$ j, @0 Q N* O
write('</ilayer>')
6 u. M) J" w2 R8 B. _* f6 I
}
0 D- U1 ]1 z: c4 {
document.write('</td></table>')
( o+ @& b7 r% |; {
}
: S, n+ D% Y y! S$ i f
}
* |6 r% A' K4 j1 |; C+ A$ E5 y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2