标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
8 d8 U5 c! @ u4 ? c% U# @
var marqueewidth=300
* v: T3 ~& r6 X% h5 {$ `" o7 P
//高度
+ X' `9 Z: A9 Z9 ]1 R
var marqueeheight=25
' j! x l5 j7 y6 ?6 ]1 Q
//速度(1-10)
) h* E5 e0 I1 X) ]: n
var marqueespeed=3
5 \0 ] v4 S: Y" G$ o
//背景颜色
- y- d6 U0 L; |
var marqueebgcolor="#FFFFFF"
: |8 _) _1 F; s8 G9 `
//是否能暂停 (0=no. 1=yes)?
* L7 S! O# x T: x2 I
var pauseit=1
, i+ [ ]2 [2 i/ i3 x; O; h; @' z
1 r+ H8 q7 M$ D* e9 B' T5 [
//修改显示内容
" V2 m- T6 [4 v/ g+ D
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
% T. B" [/ [3 e
2 x& g3 W, g2 S9 r6 {7 j
3 I+ m2 l6 o5 d4 S# c* ^
////下面不需改变////////////
$ }$ X/ [' ]; S! d5 v
: d+ Z, h4 V0 L6 {
var copyspeed=marqueespeed
% t1 e D/ E* T$ I
var pausespeed=(pauseit==0)? copyspeed: 0
4 b6 A; w$ }. e8 D
var iedom=document.all||document.getElementById
2 ~+ y* O9 q4 Q `0 ~9 S( n
if (iedom)
: ?' }+ V$ A8 B7 a/ } Y; p
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
; X" ? R4 Y9 q
var actualwidth=''
* q' ?" e) U5 s" C" ~* T
var cross_marquee, ns_marquee
& D. u% F9 j8 x+ v4 Q J
1 R7 ]; f7 C8 E+ u0 _! }, q b7 c0 U
function populate(){
) u0 P6 Q' J4 h# A% f/ b' N' a: b
if (iedom){
4 U# z" Z/ E8 o+ T9 V/ j
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
" }$ u2 u( O5 Z! P
cross_marquee.style.left=marqueewidth+8
! p- L7 U2 ^# A9 f, y" Q
cross_marquee.innerHTML=marqueecontent
& D3 a$ h7 q% M) V1 f( l
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
5 ? s) T2 |- y, ~/ o, I' ~
}
) y2 ]* K7 ^+ `; L3 n6 @* K" f
else if (document.layers){
/ v; \9 y: i Q) M/ v! ~. g
ns_marquee=document.ns_marquee.document.ns_marquee2
; [2 h M. ^3 c$ Y- u) q
ns_marquee.left=marqueewidth+8
) P+ M" }' ?% [& F5 F! I
ns_marquee.document.write(marqueecontent)
! ^( N: b `: h
ns_marquee.document.close()
3 c6 Z% Y- l9 k1 ~
actualwidth=ns_marquee.document.width
4 l; X$ @7 Y/ U* x" k" ?3 k
}
7 G% U! x. N' p5 Z/ n
lefttime=setInterval("scrollmarquee()",20)
% Y# t& s- m/ j3 K/ D
}
; s; r" D8 { ~! e
window.onload=populate
+ a: S% |8 t9 R8 i- q
) v, N+ x V2 A j9 [6 T
function scrollmarquee(){
6 w6 L# i. J7 d* Z8 e) D! V
if (iedom){
/ K$ c8 {' e3 F1 _+ f4 k
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 }: i3 j/ U K
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ ^. t& ?, p& ?& b; ]' i2 p
else
% D+ i7 s3 A6 _
cross_marquee.style.left=marqueewidth+8
, b9 G( Y4 V/ T& [. N
# T, M, ?4 C4 d. ~5 A; Z. I
}
- `6 W) q9 J4 @) s g9 ~* }9 u( Y
else if (document.layers){
! J$ J7 [4 x( t1 b; F( B2 d
if (ns_marquee.left>(actualwidth*(-1)+8))
' }. }' E+ ~9 Z
ns_marquee.left-=copyspeed
: g' H: S6 l7 V, o
else
$ X) m2 }* \, E
ns_marquee.left=marqueewidth+8
/ G8 h F7 p2 a# x
}
& L! M7 l9 U; Z% `; Q; d
}
6 V" q" I* V3 c* u4 V" d
4 x0 u6 E" l* F% D) I, ^
if (iedom||document.layers){
3 L6 X- V: \& [# l
with (document){
' i$ `; g8 x0 ?7 P7 n
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
& B' _+ U+ K1 C; N8 ^4 Q E! r- Q
if (iedom){
+ A" m' n2 a# H! I
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
# E2 b2 t! ]6 g( G5 }
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
8 v8 a2 N7 Z5 x- r6 ?" v3 I
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 ]3 X/ V+ j/ X, f) p0 [8 X" \
write('</div>')
" f' B) f% E( \; z; n) D; s
}
8 g% s2 P, Q y# ?
else if (document.layers){
% c7 |0 p2 @" Q4 f2 {
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
' w! v( i7 ]+ l9 a# _! s9 l3 g
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 t" Q( G; ]; m: O* L) F3 ]
write('</ilayer>')
7 b5 Y" e! z [+ {+ ?! y9 k+ |5 v
}
3 P- d: N0 D# i4 Y% r
document.write('</td></table>')
% G% h' n. X. x
}
$ A% ~) z m* l- V2 e7 [( ~& B" r; J
}
$ |# E0 |/ W8 l( w r5 _
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2