标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
7 f/ R6 n& O* d4 m
var marqueewidth=300
_' F2 h3 |2 B
//高度
9 E( h# A( L2 k1 T1 ^( h1 ]
var marqueeheight=25
1 S' q4 p- J. n4 A
//速度(1-10)
1 y! W- K% g( N( v0 B- C
var marqueespeed=3
/ r8 b z6 `7 ]5 S7 d
//背景颜色
2 t3 b$ C, g2 Q+ Q
var marqueebgcolor="#FFFFFF"
( ~- u) l- G: m3 r- R' O
//是否能暂停 (0=no. 1=yes)?
+ ]! H; d$ C; }
var pauseit=1
6 t4 Z! U i7 P2 Y6 f t, j
( |% a/ K/ o0 D7 u7 j' N/ r
//修改显示内容
0 z/ O4 H4 t2 U! g5 D) Z
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
, N" l0 B6 P, @: Z/ O1 s# m
6 {- D! W, J0 j1 ]
& N+ q- N5 m/ F8 ^
////下面不需改变////////////
* ?$ w, \) s1 o/ ]! t/ G
% {% r% W2 N, l5 M
var copyspeed=marqueespeed
9 v( a2 b7 n# V `) A
var pausespeed=(pauseit==0)? copyspeed: 0
7 g0 z8 p& \9 P3 a
var iedom=document.all||document.getElementById
* j$ _+ M8 s; r" C, n9 b) K9 Y
if (iedom)
1 q; y9 ~: ]% ^1 g
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
, _) D* g9 S8 i2 c
var actualwidth=''
; l0 S& c+ m8 }5 n
var cross_marquee, ns_marquee
% p3 v, q H/ h, z$ D6 r# \
, D0 X% s" r4 H7 S4 z( w: z
function populate(){
2 I! _7 f: k3 k7 D% m5 N
if (iedom){
. q4 [* I2 Q2 E4 l5 {+ v
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
; d' o0 K, W8 I( Q3 _+ Z
cross_marquee.style.left=marqueewidth+8
, n$ a! O4 Z' @! A |
cross_marquee.innerHTML=marqueecontent
7 `% M% q- e% `, ?& h8 F J- c/ v1 q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
3 B! B, A- t1 k5 E3 G4 V
}
0 c5 Z4 c9 F5 H1 J
else if (document.layers){
) |1 O% A8 D% i) O, u2 M
ns_marquee=document.ns_marquee.document.ns_marquee2
. Q( ^$ c4 z6 }% d5 t
ns_marquee.left=marqueewidth+8
/ h# e# y' r7 ? J
ns_marquee.document.write(marqueecontent)
1 n+ K5 m/ v$ Y# ]
ns_marquee.document.close()
8 s& R& ~( c B( a6 m7 R/ n
actualwidth=ns_marquee.document.width
/ ~' d& j7 c2 b% g( c M$ j6 j% W
}
( s* t: O3 s; c0 ?/ F D9 x
lefttime=setInterval("scrollmarquee()",20)
& N5 m- H4 T! f
}
0 B. h) J6 r2 D( o
window.onload=populate
1 j' ]8 W' [ I7 B* B c+ X
! d9 u' p* i( \9 r q/ R7 ?& E
function scrollmarquee(){
7 w8 j g# W& H# b4 j+ ^6 ?
if (iedom){
* p7 S1 Z, a. u/ k% Y9 y( l
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
! B* R' F; _ N
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
: Y7 w% r$ G8 x6 N9 J
else
' R4 f& l& w$ ^9 @6 x
cross_marquee.style.left=marqueewidth+8
% K' K. l1 A, C( v, F
* \( p& V6 e3 q9 w4 f
}
$ x5 ?7 z, E7 P, l0 t. C: d& N& r5 ^( ~% w4 r
else if (document.layers){
( _ V7 C9 g% N8 b7 ] d
if (ns_marquee.left>(actualwidth*(-1)+8))
' u! N, h9 b+ O' z1 w! o
ns_marquee.left-=copyspeed
( a0 u2 o' u; w9 R
else
5 D5 y4 ^" `; a( O2 N9 p# Y
ns_marquee.left=marqueewidth+8
" ~- A2 s: h# I) f0 H- [- f) `/ S
}
9 ?" D* Y" a' L s
}
5 u- ?5 |& l. s' S
" Z6 v) t' g$ H% s0 s
if (iedom||document.layers){
& @, I1 W; i! [5 P0 X7 ~! J/ V- x4 F
with (document){
`* l: T5 A& w
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
& p. v: N: |( c" M: J
if (iedom){
# @6 z7 E' ?; e" E5 V
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! {8 ^8 [3 [( f
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
7 |9 R+ m2 r+ @; h& R4 k. |
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* F" U' U3 x2 W- }
write('</div>')
1 m' A- x+ J) X& g2 |
}
2 u! {$ z4 U7 ^4 {+ r/ \0 {/ C
else if (document.layers){
% b! p/ k% m8 r# w7 f# c5 f8 B: n3 p
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 W Q2 Q3 Y0 P* H+ ]: X
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
/ W+ c* J _7 Y
write('</ilayer>')
- m2 n5 ~ n( P! |6 k
}
$ a8 T0 M0 \ |2 I: J0 y, F- {% V. F
document.write('</td></table>')
0 N2 L6 e* q }" s7 @
}
* ? l6 F3 W5 o. ^' m
}
0 W7 R' z& n" v: f
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2