标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
6 r9 ?. K2 h" E- G7 f5 J
var marqueewidth=300
: [2 `: L4 r) |0 S( P
//高度
$ C; }, P- a; m4 O# n" p8 s
var marqueeheight=25
: Y- S. s: n; d/ t: ]. \, p
//速度(1-10)
/ J& [9 K% _: e9 p
var marqueespeed=3
- c& D+ [6 [, L4 O) Q
//背景颜色
. o& V( Y- _" K) I+ K; E( o$ s
var marqueebgcolor="#FFFFFF"
6 y) L; @! }. o! j* S
//是否能暂停 (0=no. 1=yes)?
/ o& J) J6 I, W0 e& U
var pauseit=1
$ `: H' A- ?2 h- p0 a. h+ F
( _) |/ S4 b$ u: D5 W0 V' N
//修改显示内容
8 H0 ^: y* E- s- @4 `
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ v' ^' z2 D L+ M
5 Y" u* x; J8 e( `2 n. i/ a, d6 X
4 ^& ?" H' Y, B9 a$ p/ a" x5 N
////下面不需改变////////////
+ Z" t1 }& J/ ^/ ]( h+ o
$ g3 E/ q2 Y( i1 {! Q
var copyspeed=marqueespeed
4 v B& y# V7 V. f
var pausespeed=(pauseit==0)? copyspeed: 0
7 `7 V! q* j. p( u
var iedom=document.all||document.getElementById
% Y" x3 g1 V3 i; y* S
if (iedom)
P" `1 n# f4 ^ l! {# e
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
4 B1 n+ j, o3 c& L# ?
var actualwidth=''
) H q/ E8 ?3 u" z) H8 b0 F- p
var cross_marquee, ns_marquee
, D6 r# A( W& ]! E4 b( G" Y6 C
! [- R9 ]; \; M
function populate(){
( }2 Q# B' A2 Z% U! A; F
if (iedom){
% q E, x& G9 P4 t- K
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
. s8 R, V# @1 P" S- k* B3 }
cross_marquee.style.left=marqueewidth+8
- w# R5 X" ~( [1 F w4 X% G
cross_marquee.innerHTML=marqueecontent
V5 H* t4 Q/ G& P
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
/ c. k8 ]; b4 t; d6 r& F
}
- J+ f* N, C$ K1 @1 W& g
else if (document.layers){
( ~% w& @& w5 A: ^" L! k
ns_marquee=document.ns_marquee.document.ns_marquee2
Z: `6 [: I4 F/ J m% r
ns_marquee.left=marqueewidth+8
0 b ?, v$ P+ {- k
ns_marquee.document.write(marqueecontent)
0 m* n7 m, ~7 u% `: M+ S; b
ns_marquee.document.close()
) ?- L! O: o3 {4 r) M; K
actualwidth=ns_marquee.document.width
8 L; |- }! u, s' c0 l
}
3 @0 g: ]. Q x/ d
lefttime=setInterval("scrollmarquee()",20)
1 R9 ~& p, T( @$ g. R
}
G( ?5 N# Z4 k
window.onload=populate
u6 q8 `* r$ e; Y
. j. Z7 G7 u+ r; k& {3 e
function scrollmarquee(){
- R+ ?( f- C6 \$ H3 s% _) f6 m. C
if (iedom){
. n5 X% A6 R6 ?% l# Q) r2 \% F! G6 {
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
) i* h0 W: Y# S7 s
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
3 W0 E4 P' V& y9 M# z4 C* z
else
3 h" q. k% r/ V3 P# n5 A: s( t6 n
cross_marquee.style.left=marqueewidth+8
" d8 |$ ^$ ^$ I; m b) m
1 t3 D5 W' R0 c
}
- t. f3 S/ m1 N( k0 A. L
else if (document.layers){
2 |* `! c4 K; H5 j- S
if (ns_marquee.left>(actualwidth*(-1)+8))
0 b4 r: v! q, f: [, @
ns_marquee.left-=copyspeed
1 ~" G/ Q: X5 ~, z4 `, g: h& r
else
3 f' r4 o4 u$ G# R& j6 Y. ?$ V+ \/ T
ns_marquee.left=marqueewidth+8
* J0 \- m9 T- j: t1 K
}
& X) k$ B% n& I( U- J; C
}
( F2 F+ I& b$ w. f ]
# J- g8 d W% d. t- Z7 t
if (iedom||document.layers){
8 b/ P$ E! j' V* _( f, W! P) }1 T6 T
with (document){
& a3 C+ G1 J6 J" P
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
8 i7 p# Y* R* E3 N' T+ ~
if (iedom){
0 S: v3 q* }: Q
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
\6 ~7 \3 X+ B" h; i
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
: U) Y, Q5 @% q" @' G
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
3 |. G6 H! l: e8 K1 q* ~5 r/ @" t0 K
write('</div>')
+ S. R; b' `4 u- S
}
3 ^5 y* v- q* e3 E* U: B7 D
else if (document.layers){
/ Y4 N( @- U: M! |4 p4 M
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 _/ S+ r: S4 S6 H: ^ z8 J) b0 Z/ t
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% g0 I X! x# l3 [ ^
write('</ilayer>')
4 B K9 j# I/ v& D0 u; ^
}
5 l% `3 @# D" _, d
document.write('</td></table>')
9 V, M0 a- ?* P% }2 n8 t4 L
}
- X" W: w8 t7 G; U" t
}
n* _1 O- r7 n. y5 d
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2