标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
- V0 M. z; k6 l8 h! N- a
var marqueewidth=300
/ [" ^$ g0 ^- U( |7 F$ v: @1 Q
//高度
- r+ o. p0 G, R# r$ {7 o& J
var marqueeheight=25
8 ]/ M2 ~& U% \% s5 X
//速度(1-10)
: P$ C# M( q' L
var marqueespeed=3
; w4 [9 j, D# N+ \
//背景颜色
X$ z% N! I' C L2 e& n( ~' {1 s
var marqueebgcolor="#FFFFFF"
- K2 [; S6 R; X {8 y. F9 p7 q! X
//是否能暂停 (0=no. 1=yes)?
+ o( E* P. y! j n2 ^' C0 Y
var pauseit=1
) V% C9 G6 b: L6 F
/ L3 _) V- a8 d5 `" n! l+ y
//修改显示内容
$ j% C" M: I1 X* Q: o, ]
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
( G% r; R1 R0 L6 T/ q- f' v# o! f
0 q0 R) G. W! }3 e7 y) \
; W% w' O" _7 b0 L5 v' U$ k& X1 c
////下面不需改变////////////
; v" j: `. N& [( ~; M- U
( l p, _0 y y1 i4 t, m- U
var copyspeed=marqueespeed
" ` L3 z o- ?8 `' d, M. D0 ~9 C6 t
var pausespeed=(pauseit==0)? copyspeed: 0
* G/ C. q9 G [4 o ^% ]" ?
var iedom=document.all||document.getElementById
& Q; i2 G4 m% j: X1 K- b! ^
if (iedom)
^! q& [8 e( x. b% i/ M* O
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) E; n b# Y5 L0 e
var actualwidth=''
% V5 g2 ^5 B' [" ^
var cross_marquee, ns_marquee
- j* g! M9 \! A& l% v
6 B) n) W4 l( _3 j
function populate(){
& Q; p/ {: y$ q0 G# e' o
if (iedom){
8 e" k1 B ^" N" b$ P
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
) P1 q$ ?. C+ g5 M/ N0 M
cross_marquee.style.left=marqueewidth+8
( n6 l# J/ J1 R
cross_marquee.innerHTML=marqueecontent
( C2 _/ l, W, W+ V
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! }* y; z9 `! V6 |8 `& Z" [
}
4 N* y0 R7 w8 Y8 D/ y9 I. D
else if (document.layers){
* z! |' t! Z3 O, s/ }( R' v
ns_marquee=document.ns_marquee.document.ns_marquee2
& g0 t% ~& c1 ]7 O; Z/ ~; X
ns_marquee.left=marqueewidth+8
2 J: I! I8 a, F. T1 u& G
ns_marquee.document.write(marqueecontent)
" }( a8 R8 K9 b4 \$ Z/ i
ns_marquee.document.close()
$ k% e1 u! j4 [
actualwidth=ns_marquee.document.width
( L) b8 F- H8 t
}
/ V! d0 ]5 v6 \
lefttime=setInterval("scrollmarquee()",20)
1 s, u% T9 p( T0 c' l) j# ^
}
& L4 m& v& g% b( x! D" ^
window.onload=populate
) k8 |* ~0 q9 q
" H2 H; c ]: {8 G: N3 { L# G* O
function scrollmarquee(){
' ]9 T& f/ f: U- C6 `
if (iedom){
& h; _/ }: N" d) X7 @
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 j+ J- p9 O+ q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
( c/ r: |* b+ ?4 z' x/ \
else
/ {0 r5 P2 R; [8 I% _ Q+ s
cross_marquee.style.left=marqueewidth+8
/ z; n1 |& V- \* s( x
$ Y R5 q/ A" ^( R
}
3 ^9 ]/ D8 @3 `. K7 k
else if (document.layers){
2 l& B% W: H6 L
if (ns_marquee.left>(actualwidth*(-1)+8))
, G1 l3 \$ J+ {2 V6 o$ q4 Q
ns_marquee.left-=copyspeed
8 _2 _& w) E- ^; h6 R
else
+ g2 c* V0 B9 w
ns_marquee.left=marqueewidth+8
6 a. x0 @1 a- ~$ t4 u9 P0 `! Q
}
: @( A c2 {, }! f9 t" T* z: _
}
) w3 G) y2 J8 I
, n! K8 r# u E5 M+ L
if (iedom||document.layers){
, y1 Z5 w' {9 x0 m, j/ p* E
with (document){
4 e2 p8 j6 q, X9 h/ r- G
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
: U4 j. N7 z" Y$ g. u- Y# x
if (iedom){
" O }; C- ]$ z9 m% }: H- g
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
~0 t5 k. q( W3 ?! h5 P) D! Q+ P
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
# p; d l. O: a
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* T: \* f1 C/ ]
write('</div>')
8 X; `* [0 ]) Z, `
}
+ s1 V1 \, g. E' u( m/ v7 s
else if (document.layers){
6 _' X; ^$ c* e
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 \6 I- r8 I; e
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% L) d# T6 k) [) M: r
write('</ilayer>')
. Y: B+ ]. M4 M" s' O" u' L
}
8 D6 L% J& f8 P7 P
document.write('</td></table>')
6 D0 J) W* Q, `1 Q. p* G5 W, L. C
}
0 a, v, }+ C- C ]% d& K* `. f
}
W" z3 ?. H( R% K$ S) j- l
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2