标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
5 K2 ]6 v: W5 ], ?+ @8 b
var marqueewidth=300
& u) k( @& L# m. }8 ?7 H" H
//高度
: B6 f* {2 m4 Z
var marqueeheight=25
1 N* [; _2 \8 g/ L
//速度(1-10)
7 P$ w( b* c3 |
var marqueespeed=3
5 c0 F8 X" s$ p# t/ \
//背景颜色
1 `; p2 d+ J9 H7 N- L$ S
var marqueebgcolor="#FFFFFF"
" e: S/ ?; g* q+ S
//是否能暂停 (0=no. 1=yes)?
1 i: ?; t! W' W F5 s- x
var pauseit=1
8 a0 K1 v$ R8 D5 |: m
; P* M. o8 P- H1 G" X
//修改显示内容
* W7 g8 a; P6 _4 P4 t! m# m
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
% S/ P' O4 z# i- `3 `; D
$ y0 B1 n1 f2 e" J- P* a
! |) y7 x) s& {: D& }0 T4 e
////下面不需改变////////////
) H0 d: v$ r7 i: W Q( j3 H! R
; Q- O v8 g- C; w$ i% P. E
var copyspeed=marqueespeed
5 ^. \9 m: E. E! T! c9 }4 P* ~; i
var pausespeed=(pauseit==0)? copyspeed: 0
" L0 \7 w% J# P& n7 i* Z
var iedom=document.all||document.getElementById
" v: `* F3 B( F8 f- E9 J; I1 A' W
if (iedom)
y- I* [/ ? ]8 n$ c4 z2 R5 B3 q
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
! V& x* E, U" J |7 @7 J% |
var actualwidth=''
/ N/ S2 {, l$ c: c$ a1 [4 `$ m1 O
var cross_marquee, ns_marquee
$ n; J7 [- O- ~5 e
0 t+ y: n+ m1 b! R
function populate(){
# d; I/ q [8 w
if (iedom){
" x0 e& r9 T' n8 ~" s. \
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ @8 r( D" z' s* \' n) ~
cross_marquee.style.left=marqueewidth+8
8 K$ o$ K$ n( {1 t. W
cross_marquee.innerHTML=marqueecontent
( L& P- Z* a- G8 n, [1 ]7 R( w
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
~$ F' q2 C# h# R8 @
}
7 X( m3 @& W9 m
else if (document.layers){
l' x x( x' F* F, R: ?2 H0 i
ns_marquee=document.ns_marquee.document.ns_marquee2
6 I) T( f; ~, v# Z" S! e
ns_marquee.left=marqueewidth+8
* @6 b S! k, M2 ^0 D) W
ns_marquee.document.write(marqueecontent)
5 z. d' C3 f! f7 C$ i+ [2 b
ns_marquee.document.close()
. k- G% `( i* D' p6 r
actualwidth=ns_marquee.document.width
2 D5 w% |5 r' E3 ?( u! F1 ^
}
9 ~5 d' E/ y6 z, m4 n1 I5 u
lefttime=setInterval("scrollmarquee()",20)
) `3 M4 Z; P; V" K: L
}
3 n" @& K, c$ `6 _
window.onload=populate
7 {5 I) Z' l- I% O. w
p! O9 O$ P/ y
function scrollmarquee(){
[" @' y @5 r" j2 W$ X
if (iedom){
, Y4 ^) Z; a2 c, v
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
s6 H1 Z+ f. R; i' I7 Y* {4 ?3 d1 v
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ ? d' L+ a* M- G ?
else
& r) [6 U# _+ y2 B* M; a5 I! m D
cross_marquee.style.left=marqueewidth+8
0 |* Y$ X% I; b7 G" {( [
3 r9 {) ~/ f4 g+ ?1 v2 e( z
}
8 w6 F( d0 C' k! a. ^
else if (document.layers){
6 d6 ]9 I+ @9 d) ]9 a' v
if (ns_marquee.left>(actualwidth*(-1)+8))
8 q- u% ?( r- Q
ns_marquee.left-=copyspeed
j' w! E5 G& c
else
) T" L" K: }( ^# q1 P
ns_marquee.left=marqueewidth+8
9 _- Y' V' {# ?9 N8 P8 R
}
6 }7 y8 C& f9 x- ~" X* t* m* D- @
}
! ^8 }. S' R- E3 m0 }9 x. H
" Z" n J6 J5 p; C9 O
if (iedom||document.layers){
4 }3 z. S2 s2 C
with (document){
3 }. Z, G7 d( |% M
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
8 ?7 U t7 ~+ @/ n
if (iedom){
& M e/ H2 G' ]( G; ]% t% X3 s8 j
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
9 H. A0 |' N$ K6 G* ~3 k
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
2 C: W* Q* y6 F' n( @; ~" Z- r9 u
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 r- N& _# ^: e, z* N( W
write('</div>')
. a2 {3 r/ r1 i& O2 h/ ?% K+ Y
}
' q- M$ x1 S& E7 C& I4 @
else if (document.layers){
* D! G- W* m- u) n6 g! n t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
7 t1 q! X& G# _/ o4 ~+ P8 ^3 ?; ]
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 t& \ _+ p+ k; h) e: F3 u* d
write('</ilayer>')
, A6 E) c5 U2 D% y* c* Z
}
9 M$ z4 J8 V4 D. J$ n& m! r: J
document.write('</td></table>')
% Q, U. V, P! Q
}
* B; u" Q! Q' I( V5 h
}
* i! \2 t( a- {0 S0 y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2