标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
* g# n/ A( f8 `% Q9 |4 C9 H
var marqueewidth=300
+ r& t( W& T: Z3 g& I$ y; q2 _3 v
//高度
: y, U; ~! f R( W, b7 U
var marqueeheight=25
3 i& @! a# w! r5 ?
//速度(1-10)
# D5 p+ |* j) K8 i d
var marqueespeed=3
3 F/ W1 d8 o% Q9 _# U
//背景颜色
5 F: l- q. m' b4 d Z5 A
var marqueebgcolor="#FFFFFF"
/ g; j, m ~5 m1 M
//是否能暂停 (0=no. 1=yes)?
* F( `/ M1 m4 h" h, t: o" R3 Q
var pauseit=1
1 O" k- F6 _# S y- b/ P; e
1 Q: J' I8 c, b: V9 k
//修改显示内容
2 o4 \- q+ L0 G p% v
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 R c# R& X, G y. U% x
% y2 K f# [+ J: L) R* \$ W7 N
" d9 x" |) C* r9 x+ d) |' J3 q
////下面不需改变////////////
- r- w7 S+ H; m8 x
4 E& b* b- U X. z2 j7 |
var copyspeed=marqueespeed
6 A, m8 j5 c9 c: a5 f3 n, I8 G
var pausespeed=(pauseit==0)? copyspeed: 0
6 O) C. L2 E$ D% @! e9 ^
var iedom=document.all||document.getElementById
8 B: X8 a8 [5 q: z' o+ D
if (iedom)
: F/ N, ]4 @) z# G5 s
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) ]6 B' B# b1 ?* H
var actualwidth=''
( W+ u _6 ? S
var cross_marquee, ns_marquee
3 s5 T S7 @# ]+ t9 i
, K3 \9 N' x4 W: @ B/ q1 D1 {
function populate(){
9 {3 L$ |. @/ U3 { P$ ~
if (iedom){
0 J" v. b9 D, H+ [: l" l
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
9 w" [9 d$ }1 _+ w
cross_marquee.style.left=marqueewidth+8
1 j$ x0 {5 O5 r
cross_marquee.innerHTML=marqueecontent
/ I( ^' f- G+ K& q$ ]
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. D& u4 r$ g- o/ Z0 X) P% I8 |& j- U0 o
}
( ~4 g9 B, Z3 v* E( s3 f
else if (document.layers){
0 L; z, g- F. Z* U- V
ns_marquee=document.ns_marquee.document.ns_marquee2
5 ~ O, n3 h, K5 S/ J+ @7 s% w
ns_marquee.left=marqueewidth+8
7 ^3 l: h$ l5 ]* I x
ns_marquee.document.write(marqueecontent)
3 T+ V* F3 X G- R- a( O
ns_marquee.document.close()
* D- ?$ G3 A7 X, h# V7 Y) V% X/ q
actualwidth=ns_marquee.document.width
/ C8 R% v+ a! x" D
}
' M5 q% }0 B# i: g/ J
lefttime=setInterval("scrollmarquee()",20)
5 V/ z5 t9 t) c6 z: O6 J6 x, o. g
}
* |* B0 X5 y! R ^8 m# \+ O
window.onload=populate
+ z. T+ J0 L/ u- V7 v9 Z( j' m
4 j' Q6 g( o' S
function scrollmarquee(){
# a: C: h* F0 S; J1 Q2 c! l
if (iedom){
! @$ S- ^& E: O4 G. I! {
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
4 B5 S2 A# G# V. P6 M
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ V( A8 P Y5 X3 q. J
else
# R% R+ x2 j$ o6 h2 x
cross_marquee.style.left=marqueewidth+8
. y, G+ r0 g; y& g0 G" n2 a/ |
& r* d7 [, \; `. a$ g; i
}
4 l/ k( O4 m* e# E& J
else if (document.layers){
$ `- q: w, Y l
if (ns_marquee.left>(actualwidth*(-1)+8))
6 Y0 H5 {, J, p; u
ns_marquee.left-=copyspeed
- k! @- |4 J1 S5 k0 C5 H. t
else
: t0 t0 ]+ N% O( s
ns_marquee.left=marqueewidth+8
7 U7 z& G0 g# }5 \/ X6 Z2 ^7 ]+ A- O
}
( a/ v4 }& Q, h# W4 t0 p0 `
}
; D. R7 Y' N6 K
" Q# b( I( P+ k6 N
if (iedom||document.layers){
. y% j, L2 e7 F" ?! b/ C7 h
with (document){
9 d! f# u( N2 x: C) ] _
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
% O ?+ f/ m9 A6 }+ T9 X
if (iedom){
. ^" j) Z* j7 l! v
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
# K7 E0 k, b& f L
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
( \' @2 K+ b1 d" I8 P6 B" K
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
. ~: \: Y: e2 \9 I8 a/ ]) J. u
write('</div>')
- R" `$ H- L/ P' A
}
' Q( a7 ?( i4 | B! ?# V
else if (document.layers){
# ~6 o. L0 [+ [: |7 c1 k4 T4 t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 R. U: k) v: C |0 w8 n
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
- S( W n' W- w H
write('</ilayer>')
; X+ f$ S2 |, n, M8 ~2 d+ x
}
3 o* J8 I* `& G7 N$ S& S
document.write('</td></table>')
. ]% x2 s9 _$ Q
}
. Q8 g$ |! k/ o' }1 D
}
2 P" Z4 @9 |9 l$ r$ l
</script>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2