标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
* X/ F* _3 F" h, x7 i
var marqueewidth=300
. Z) P; a$ |0 K/ C
//高度
* M) V& B) Z& x# }
var marqueeheight=25
w: C) d8 g- X
//速度(1-10)
1 Y# Y& i5 }0 F! [% L7 o- | o
var marqueespeed=3
2 }" @# L( j' q
//背景颜色
$ I0 A& i8 }! s
var marqueebgcolor="#FFFFFF"
1 n9 f& q1 P) U* |4 x" `
//是否能暂停 (0=no. 1=yes)?
1 A: v8 c" k# X/ t
var pauseit=1
, r& w+ [) i* B6 U* J1 R( L; P
/ t& Z; ?" Q1 z' r+ ]7 E
//修改显示内容
2 g1 |6 j. ~! Q5 `* y- u, n* [- X
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
' N9 W: o/ T5 q. n8 Z: {8 W
. C2 x# ^# ?, s. E& m; Q
! L& _' {: J5 I$ C7 ]
////下面不需改变////////////
- Y# R3 ?/ j9 t! ~& z
! ?/ y4 Y1 d6 z8 s
var copyspeed=marqueespeed
2 M; d9 g1 y% z+ e
var pausespeed=(pauseit==0)? copyspeed: 0
" T/ t$ B. Y- @/ `
var iedom=document.all||document.getElementById
# r0 k! D7 v! r6 B. M
if (iedom)
8 c' \; y0 h8 e: k/ u. P" w) ^- h; s
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
1 X0 H$ \* `) F1 W) o8 w
var actualwidth=''
5 C7 \( y5 E, S
var cross_marquee, ns_marquee
[# L. ~( ^3 s3 Z0 q5 ?
' Y( x' q: @/ q$ R& \
function populate(){
# a% z$ u$ p$ k: `' P
if (iedom){
5 P5 I2 _ B6 ?3 y% [/ x- z3 C4 y
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
- G1 Y; r% ~1 ?* x6 Y: \! `
cross_marquee.style.left=marqueewidth+8
2 V2 J. ~0 ?# h8 h5 U( s
cross_marquee.innerHTML=marqueecontent
+ f! [7 J' S4 M [) C6 R# Z# H
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
& H3 M6 _* Z$ e* l
}
, D3 v% q u; J- i: b
else if (document.layers){
# y, A4 ?: i* |0 W
ns_marquee=document.ns_marquee.document.ns_marquee2
9 t6 r* ]) S. e0 s2 D/ Q) S
ns_marquee.left=marqueewidth+8
1 a4 i' U6 L$ V S
ns_marquee.document.write(marqueecontent)
7 \; m% {- o3 [' o" P
ns_marquee.document.close()
" {0 f/ }- C8 b* Z# k
actualwidth=ns_marquee.document.width
0 m, t+ D# B. Z' r
}
1 L7 S2 z9 w1 s5 {! |
lefttime=setInterval("scrollmarquee()",20)
5 w6 Q& |' d4 T( F ^5 A* |8 ^2 C! Y
}
! U( ^0 x- g/ ?7 a( w* f' E# J
window.onload=populate
! v9 D* Z1 u) ?+ |) e& I* m
' }$ q* p, f7 G- Z* D( F
function scrollmarquee(){
- V/ I4 L7 P; y* E9 y6 V1 @3 ?
if (iedom){
- G% l- `1 c0 n, i! c' _/ F
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 Q" a* c9 L c' s
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
- z7 u$ p( \5 t0 v& s K5 r; f
else
4 G8 I+ b8 l: N5 ?" M) t% T r
cross_marquee.style.left=marqueewidth+8
- _; I* R. |3 C9 Y, P' Z
' P% U* |! S8 G- ^9 g
}
/ V6 t B( E! H9 i1 l1 p" F
else if (document.layers){
' u/ o$ h& E$ n8 E0 c: x
if (ns_marquee.left>(actualwidth*(-1)+8))
2 s' k [, I U9 l7 I6 Y
ns_marquee.left-=copyspeed
) K1 u5 Y0 y0 x7 y" R
else
9 @( B! r: V7 T* c. @' v
ns_marquee.left=marqueewidth+8
/ l U2 r W. P: @- O6 k
}
) z1 |7 n5 K2 N* |/ d, N+ J* ~
}
! M4 S1 k2 k0 V7 i0 Z% f9 J
0 d8 w3 t9 _4 N
if (iedom||document.layers){
4 n! _' W" @( l% D1 H! K
with (document){
" Q+ X; E: `& Y$ f/ _4 u
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' T" H3 ^ t' l" e' f1 e
if (iedom){
9 I! i3 k( ]; q, I* R
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ n: s: b' s# U7 c/ {
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
3 Y# X+ X& u* ?( z# ?1 p
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' X- }2 g9 W% w! Y4 B
write('</div>')
" [) n$ c4 N" j+ K1 p9 H* O
}
9 R! Q% |" H, n9 Z# I, g& Y
else if (document.layers){
$ W' H, Q# p, }2 X3 v4 O
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
7 O! z) a7 P$ Y. m) k2 i
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 ] N% h+ y) |
write('</ilayer>')
( S+ @) j ~& W7 p! e; ^
}
& t, F. {+ D. x; F. x2 q1 O( c
document.write('</td></table>')
8 Q$ O- F0 D1 m8 {/ A5 I
}
" r3 ^/ v& `# G! F& G" i
}
! R# k4 D2 v( d0 S" |, f: r% m: m* j
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2