标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
/ W+ n# e. F# G, k4 A* B3 a. p
var marqueewidth=300
- Z- U+ X- e, r0 F) h3 Q3 g$ X
//高度
1 y/ p& m' z6 H) W1 T+ b# x3 D
var marqueeheight=25
8 E0 \3 i4 [/ N& Y% q
//速度(1-10)
$ i. `8 t8 n8 M: t
var marqueespeed=3
$ o1 t8 r9 }2 P' W: h/ k% d
//背景颜色
6 p% c _5 V* R9 F3 e1 T
var marqueebgcolor="#FFFFFF"
W1 {3 J* Y- _9 ]0 A* F/ c
//是否能暂停 (0=no. 1=yes)?
. G) K s. d* s6 J$ O" B/ K
var pauseit=1
1 ]+ i$ q- Y$ i8 \. g2 e1 \
5 e v6 T2 J* Z' Y
//修改显示内容
) Y) g! \+ w8 \0 r) E
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
! I, h( C7 T) i7 K" y8 m. y
. W: |+ A: Y# W
$ Y) x7 z: T: @* `2 o
////下面不需改变////////////
& B M! H0 g% E3 `: L7 {& U8 H3 C, G
: g+ t3 Q; G |2 F
var copyspeed=marqueespeed
% s$ `2 v4 S: D3 B% h
var pausespeed=(pauseit==0)? copyspeed: 0
% U* {0 t* e$ T3 t0 F- V/ Z
var iedom=document.all||document.getElementById
& Y! K) w+ K5 y/ z+ M- Y0 s. w3 A
if (iedom)
8 V6 J) d1 U! t( `+ r
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' q* E/ b' v* h* M [9 c) j
var actualwidth=''
4 I. ?' L& L( \$ q& S9 y' ?# a2 `
var cross_marquee, ns_marquee
0 Q* B+ a) U0 O' l$ I
g- o& z- \+ A" R
function populate(){
) B' v, U9 F/ F: F- O
if (iedom){
6 f; ]# K3 Q% N% Q" {- l" `
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
8 u8 x' Z8 @6 O: K6 `
cross_marquee.style.left=marqueewidth+8
1 o% M; x J2 J" n8 Z5 e
cross_marquee.innerHTML=marqueecontent
" i: j5 u& _1 C
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
, I# D" M" ?3 F7 o8 ~9 l2 I$ e0 l0 I
}
: p) O% a" ]" r2 N/ \
else if (document.layers){
) X5 X- R0 Y: R3 W7 _6 ]
ns_marquee=document.ns_marquee.document.ns_marquee2
4 g* W0 f9 f8 \) O
ns_marquee.left=marqueewidth+8
1 t ]3 z$ j" \2 Y6 u
ns_marquee.document.write(marqueecontent)
% Z7 z* }9 C' O; R0 d1 T
ns_marquee.document.close()
# `) h5 U' t! K4 f: c: i
actualwidth=ns_marquee.document.width
0 |" [- t: [: J- N4 V/ J- J1 C1 d
}
, [6 B3 e {( j6 B C3 w) A
lefttime=setInterval("scrollmarquee()",20)
: S+ u0 k5 y2 b/ w, d
}
, `2 |9 R2 V) [2 k& ^
window.onload=populate
8 c- [$ W7 h' U8 v8 ? _) c
( i9 N5 n0 v/ B2 T( P" ^; q; n
function scrollmarquee(){
/ @, u: j. |- e4 u
if (iedom){
/ v4 E" O. }! i$ O% D$ G
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
, P8 E( v6 E0 v" A8 F& M
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ s# H0 i, b R
else
! d6 h7 [6 i) l& O* J8 o7 |
cross_marquee.style.left=marqueewidth+8
b) c1 p* v. d. {4 k' Q
: \0 H" b, h" J' C, G
}
! W' F$ e. ~4 n+ e' V7 b# A W
else if (document.layers){
3 V5 J9 E/ k$ j( t2 o
if (ns_marquee.left>(actualwidth*(-1)+8))
$ H. s2 s+ e% y( K/ R
ns_marquee.left-=copyspeed
D# @4 @1 B$ W* F6 b# v, R9 B
else
) ]* C+ v: {9 c; A; W5 Y4 I! p# X( I
ns_marquee.left=marqueewidth+8
! }* d. ^( j- j) `! O3 u# U9 Z5 ~. u# h
}
+ `3 w* M: w3 o# e
}
9 n% T4 J! Z0 y0 l I% W
7 z, e8 G' s( j$ p: w
if (iedom||document.layers){
# D+ l. E6 n/ S3 V2 \
with (document){
( f. \0 b6 T2 ]6 }% w. Q1 ~/ }3 j
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
& _5 H1 Y! X7 X; X7 C( V
if (iedom){
' K+ F _! ?% P) u0 K2 ]& A7 |, B
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
+ B9 [& l8 O3 S
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
! p: `+ ?* T$ d7 r
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# U" V/ F! g5 M; N* H8 }# N
write('</div>')
7 |3 q4 j" m: }/ ^5 ]3 D1 t7 A
}
. D& @. G! X3 B m* h
else if (document.layers){
- j G/ @' u3 x3 o. s! f2 P
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 Q& T# N$ u1 ~. K F) C
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
! b+ I$ K" U+ i) l. _
write('</ilayer>')
2 v. S0 T7 Y; ?% W! z5 j
}
) }8 C7 R7 y3 r$ l
document.write('</td></table>')
# p1 w0 h6 e3 M# {- L7 _
}
# h* c% _; Z! z% p; ~
}
. T' y3 b6 B; h7 y, S
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2