标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
7 _% o7 C: i* k4 G8 f0 D; k
var marqueewidth=300
+ i: b9 L0 H/ L! D3 v4 r
//高度
* s' x5 Z/ S/ j; |$ U5 \
var marqueeheight=25
8 O: G6 B/ L) s0 Y! X# F
//速度(1-10)
( c) a( ` h& H; ^' P1 q3 k
var marqueespeed=3
4 t) o6 m& C, E' ` D) S
//背景颜色
$ p1 |+ x. R0 m" C
var marqueebgcolor="#FFFFFF"
" j5 F* u& J( e; K' p% i, i1 H
//是否能暂停 (0=no. 1=yes)?
}6 S6 |4 G5 W% ]' Y. Q Q
var pauseit=1
& D, V; ^' [2 h) g- I/ R, A* b+ C
" k8 a* T1 o% Z0 U6 [3 x% ^
//修改显示内容
* E9 b6 h9 F- W" f" Y ^
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
, Z" O4 S- V1 Y: k
3 h) `* g- p; d# m+ V
' w2 i6 Q/ N( y! C8 T6 j
////下面不需改变////////////
6 b+ v* w! {5 q7 B" i
+ U2 B9 I4 a# ]. R
var copyspeed=marqueespeed
; J0 c$ h% E, K$ N- [
var pausespeed=(pauseit==0)? copyspeed: 0
- F) u2 P# N! [0 C) }5 \* b
var iedom=document.all||document.getElementById
6 S5 J3 i: x1 j/ G% L" e, P9 e
if (iedom)
% M2 M: }; X- b0 g8 _. y* a
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
( W# |; z9 j2 ^: E% z$ u4 Y A
var actualwidth=''
- y j. P! y& r" V0 O
var cross_marquee, ns_marquee
8 f) ^! P0 M% X+ k `
: f% V* O: }1 }% U8 v+ B
function populate(){
1 g/ _" s* \5 j+ S
if (iedom){
0 e, Y: q) s/ _. j
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
) L, Q) p" `; \' d. y" R, c
cross_marquee.style.left=marqueewidth+8
6 _, R1 X" v( h7 {9 y' b' ^, W+ w
cross_marquee.innerHTML=marqueecontent
, e0 O' J$ g# {6 J7 [
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
4 q9 U6 j, R% s0 p; G( J. D7 m8 z
}
8 o- ~( B9 V- N U
else if (document.layers){
$ v( a/ v6 k4 o( B `6 b% ^
ns_marquee=document.ns_marquee.document.ns_marquee2
5 A* t/ J; y% L9 [2 H9 q+ f
ns_marquee.left=marqueewidth+8
$ b9 e d- m4 J" A4 Q7 e2 F
ns_marquee.document.write(marqueecontent)
/ n8 B, W+ H# R. \, ?$ r
ns_marquee.document.close()
& ~; g8 n. r# k/ p1 G
actualwidth=ns_marquee.document.width
1 Q* O* p! R5 [, C7 P
}
* n6 J4 n' V* J
lefttime=setInterval("scrollmarquee()",20)
: c9 e0 y* G7 T, {" T
}
6 P$ i" F2 `& a4 j
window.onload=populate
1 _8 Z [# ]1 \* Q& U$ e! ^
7 Y+ l1 d3 a% f. f7 z
function scrollmarquee(){
# h6 I! R, A/ k( Z O
if (iedom){
% p/ ?, U. C1 ^8 m, X- \$ i3 A! O
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
Z1 A; \5 S9 [/ z$ Y4 V
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ n* t% _, }: T# F( M" G F# j1 j
else
0 O6 w6 g5 g! r. f
cross_marquee.style.left=marqueewidth+8
; Z7 c* k1 T" J: a: `- G# F3 u
x; ^6 R# U/ F- h5 q
}
; W0 I. X! y/ a8 x5 e5 ~, S' T3 ^3 G
else if (document.layers){
2 z' W1 \# N# w: H) @+ O4 l
if (ns_marquee.left>(actualwidth*(-1)+8))
( {9 Y# V* \& F: a' U0 e( K& Z
ns_marquee.left-=copyspeed
9 O9 P: w# V6 l3 c
else
2 Q& K: [3 A' ^: S1 v* D6 Z
ns_marquee.left=marqueewidth+8
' a4 f8 x4 o3 ^+ Q/ B
}
+ g* X( i6 J- H& m
}
2 ?/ I/ Y& b/ f) L2 g7 \$ R' M; a
8 I+ ?" P( l* p
if (iedom||document.layers){
3 u; o4 \6 Z* F. r
with (document){
: t: F1 @; ]" l6 r9 l
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
; H8 u- R& Y$ S" ^- Q7 W* Q
if (iedom){
5 h' H6 o# s9 ]. f& Z
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
, Q( W m/ R# I9 V) \
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
1 N4 @$ ^) S- V' o9 H5 k
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
. V) ]8 B1 L z
write('</div>')
% k" p; e* F1 f+ r
}
+ p" c6 {, ]- l) C) y8 Y
else if (document.layers){
) y7 B! h) Y/ Y9 o6 z$ j: B, x: A% s
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
) v A9 _0 L% I
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 n4 K& `* O! h. ^9 w% Q
write('</ilayer>')
" `) _5 b: l; X6 B. x
}
C; d( L" t3 G1 H0 r* j
document.write('</td></table>')
5 t; N, ]1 l! C( B
}
- X& J+ p. ]7 d/ ]
}
) z8 w& C+ X |- {6 I
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2