标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
. N- N8 `- d# t8 J# e
var marqueewidth=300
- T3 u5 P, A) x
//高度
; ?& R' W% H" P* K: t
var marqueeheight=25
6 \4 Y1 m/ ~/ ]8 f
//速度(1-10)
. W. f' S5 s+ R1 B. H/ P& l/ l0 k
var marqueespeed=3
1 g% Z3 X1 ~; {. Z/ j
//背景颜色
3 g- l [9 S3 k6 P! ~
var marqueebgcolor="#FFFFFF"
* S6 E& R7 }+ @4 ^/ y* {% m
//是否能暂停 (0=no. 1=yes)?
+ ` R5 ^( Q+ {& j' _6 k( Z0 e3 d
var pauseit=1
* m0 \0 }% t" Z; O% i
+ k8 G& H, t, P8 r
//修改显示内容
7 a& @9 n9 C( A" J4 b+ T
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 Y( N4 Z! J i8 W) K6 x
- P* V; ?1 f* |* T5 s7 Z8 T
7 }3 C" }; [: b
////下面不需改变////////////
: J* R+ _ ~: R$ z: W& a- a
! }8 Y# ^* y6 D9 I# f1 U1 L) C
var copyspeed=marqueespeed
% c# j1 ^3 F5 r
var pausespeed=(pauseit==0)? copyspeed: 0
: M: |" ]$ z' g, r- Z
var iedom=document.all||document.getElementById
/ v; n# J/ [- B- b* U( M
if (iedom)
8 h% ?# e, K7 V& \7 E7 T9 ]
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
1 T z! m1 V2 ~; q N- }, \6 {: s
var actualwidth=''
" ]9 O+ e8 k3 R2 q% D# _" u
var cross_marquee, ns_marquee
4 T( z% T! q" _0 K7 F
* L$ w- S# n# m# m# y w0 R
function populate(){
2 L" K7 G) d n( d, ?3 y
if (iedom){
1 `% ^2 R1 ?* D% E8 J1 ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
$ r; E) r" o# T" O) ?: C$ t
cross_marquee.style.left=marqueewidth+8
; v* P9 l s, S. i s3 @4 J4 T
cross_marquee.innerHTML=marqueecontent
' Z! ~( _# M; b8 H" a) Q8 V
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
# Y# l: m/ \2 U6 c, m8 B
}
# x: |+ j9 U/ l: q
else if (document.layers){
. D2 [; p. y& w
ns_marquee=document.ns_marquee.document.ns_marquee2
2 a( M" Z& n# [: D* u8 u
ns_marquee.left=marqueewidth+8
; h- N3 N8 g& d' Y
ns_marquee.document.write(marqueecontent)
0 S: O8 S0 t- S! K+ G9 [9 e- a
ns_marquee.document.close()
6 a- C. ]2 J) Q* F( q% X
actualwidth=ns_marquee.document.width
1 l/ g# y S0 o6 {. d( F
}
/ ^2 Q: x, w" H! X& ?0 w3 M" `
lefttime=setInterval("scrollmarquee()",20)
4 B7 y7 S4 D) K4 A- k( C( P
}
8 |5 M+ k2 k1 W! L& J6 Z/ m6 r
window.onload=populate
`+ ~ e! o2 m, `' Z
/ |! a; [% V2 y; t/ Y
function scrollmarquee(){
/ G) d# ?; e# R! g
if (iedom){
j3 P0 [9 B8 k# L h" C
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
7 X5 x# T# Q& I0 x5 k
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
* M( e' [3 K( |' I: G) G: j2 z2 G
else
$ I0 y3 ~9 M4 ?
cross_marquee.style.left=marqueewidth+8
# }* o! G& d: ^( n2 Z2 s# ?
& Z5 }. C5 c2 E6 k' V. c2 j
}
8 U8 ?. |4 l, W) p# q5 F
else if (document.layers){
) A9 ~/ o. U7 g
if (ns_marquee.left>(actualwidth*(-1)+8))
. r8 g% s: ~: Y( x) `# r
ns_marquee.left-=copyspeed
# I+ z* Y# E1 D) r* Q. l1 t
else
8 U8 F) J' ^& o$ J5 s% B
ns_marquee.left=marqueewidth+8
; [" o' j+ v/ K$ T j7 K! D3 J% |4 p9 X+ h
}
( e* T d6 c1 f* S
}
6 D6 n' K; K3 x3 @" A
e b% i$ k! X# X* D: F5 v
if (iedom||document.layers){
# Z: ^$ R/ z" Y: A/ `( K
with (document){
5 l, u; L! t% D0 K [3 i5 r
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
1 q/ E6 I$ e5 O' h4 m
if (iedom){
, v* N [" X0 p
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 D' L) f9 }% @/ I7 `+ e
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
, I& U3 U; M5 |$ g4 a( B# S' w
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
1 a! Z) `1 c0 q. i+ l1 ~
write('</div>')
* Q' c; J3 G% _2 r6 k" \6 [0 z' q# A
}
' N0 }2 L1 w+ c2 S. f& V6 a
else if (document.layers){
2 \& w6 W2 K0 m, j( _( I5 S
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* l6 L+ q; g m- v4 F
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
7 d) ^6 e, D3 N( J4 i* \ h3 y
write('</ilayer>')
. S; Y$ T3 v$ Z/ l
}
, k, j$ L+ y* [9 e0 D9 |$ F
document.write('</td></table>')
]) h; u- Z, {3 v7 ]: ]
}
% o5 p% m3 |+ U1 Z& C" Q
}
o4 R! A% `, Y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2