标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
( y( e2 _9 a# @- B( b' Y
var marqueewidth=300
3 y0 z# A, J" `7 M5 E8 Y" p
//高度
$ j$ r& a D! M7 k5 z% S
var marqueeheight=25
1 x# U7 p, x: s
//速度(1-10)
P" G# F6 m g9 o z
var marqueespeed=3
' ^" L0 Q* {" R( Q) @4 c
//背景颜色
) D+ V8 a: v# O. x$ ^" \9 m
var marqueebgcolor="#FFFFFF"
. Y" e {6 n6 C- ^4 Y
//是否能暂停 (0=no. 1=yes)?
. ]- ~3 c$ s; `8 S5 w0 L
var pauseit=1
) Z0 \8 m0 s! J3 m
. I/ K+ p$ b# c7 h3 l# l
//修改显示内容
& {# \( t( K- g/ k1 N8 r* o' ]
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
; `) b d; p4 Q* z
# W9 I' G* B2 }9 n' ?" ]
7 _( V0 ]' g5 i$ J
////下面不需改变////////////
8 s9 p) p3 p" C
: O" o/ k, v+ q: c) D$ ?
var copyspeed=marqueespeed
% z! J) q* `& t9 Q, S% G
var pausespeed=(pauseit==0)? copyspeed: 0
9 g4 L/ M% }( P2 \
var iedom=document.all||document.getElementById
) ~: S, R! @7 u8 S2 a0 K% [- l. @# I' e
if (iedom)
) u: P4 ?8 E: V/ t; v! t6 o' y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
" u F3 ?# T" Q! H( J
var actualwidth=''
9 Q0 \1 i/ w' d
var cross_marquee, ns_marquee
/ [. v6 v. x. a% O
3 P% J8 G& O" s4 K& r) _! y7 R
function populate(){
9 m, V7 ^$ P3 W9 s# B5 q5 C3 q2 M
if (iedom){
4 |2 Q- ?: K7 e* m) l. R
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
. }9 d* [, s, x: a! t
cross_marquee.style.left=marqueewidth+8
: K! ^ j1 Z0 c1 p& D: H8 Q* l# ]
cross_marquee.innerHTML=marqueecontent
/ Z/ j- g7 n) C/ I/ z
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( T/ `# E: D4 c1 H% K$ L
}
P/ Q; c* X+ h' V/ R3 V9 r3 r7 B
else if (document.layers){
3 o1 b, {/ P3 t
ns_marquee=document.ns_marquee.document.ns_marquee2
1 Z* y4 L' A- X: P o$ r
ns_marquee.left=marqueewidth+8
% ~4 n1 r" {# z7 `
ns_marquee.document.write(marqueecontent)
5 {/ ]+ V* G% ^+ c
ns_marquee.document.close()
f- l, E0 S! y
actualwidth=ns_marquee.document.width
" t+ V3 z% n' a# F0 p
}
6 i" u8 Y8 {/ u) g7 q, I! Y
lefttime=setInterval("scrollmarquee()",20)
1 i4 w' A5 D: v3 B8 n. b
}
3 e* S* u5 D% `& I6 ], `
window.onload=populate
3 }/ O5 a- H$ O) {5 I9 L$ d/ @% Z
" o+ _. K9 u5 [) J- P# v/ d! q
function scrollmarquee(){
7 P) }1 r, L6 g i' Y
if (iedom){
; o0 t: g" D( ?
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
" s$ i& i0 H1 q* H
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
0 }( |. F$ I1 F. x1 X6 b! v9 i
else
4 O& E- G/ C' i
cross_marquee.style.left=marqueewidth+8
! |' W5 ^8 H" J6 Y4 O
+ B0 q( N" |$ }) [4 R
}
4 D0 c1 [7 V) J% x/ v& K$ \+ E
else if (document.layers){
& f! q$ h& K' d. B; U
if (ns_marquee.left>(actualwidth*(-1)+8))
j, t% s1 e9 ^
ns_marquee.left-=copyspeed
* h) {8 E2 K L m6 S# Z
else
; _6 K# s2 H& C
ns_marquee.left=marqueewidth+8
( M7 Y G: }. u5 B& J; E( g
}
, q M* K3 S3 X4 @" [$ e x
}
5 m% O8 R7 P$ ^. a# }
" p3 w V& E g( G
if (iedom||document.layers){
3 p# f* m+ r+ h, a! m
with (document){
, k) Z6 N7 X. U6 C( e5 L
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
# d V, K0 \# z4 I* H
if (iedom){
5 P4 L8 \* a' ]1 v% Z2 w T
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
' y7 ?& h- [2 V6 p2 m
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; ?& H. [3 Q# x9 T0 Z% B
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
1 A# A: C5 N3 N' b t+ f6 I
write('</div>')
0 K/ Q$ B& o# c; h
}
. t b) w4 {$ k
else if (document.layers){
2 g# v; p+ n; A; u% \3 M
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
7 l$ b9 _; {* u# _' d+ B
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% N- {. r' N$ _ }
write('</ilayer>')
& h' ?/ t+ p# r
}
8 S" E. }9 U3 K
document.write('</td></table>')
/ G: V, _9 j! ?0 p* s0 ^7 l1 k3 t* R
}
. x5 _# A4 z$ R0 m
}
& E# v$ j4 C3 M5 \$ {
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2