标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
1 E8 X! T7 g6 l7 X. g8 S
var marqueewidth=300
2 W0 f2 D* N, Y5 t; ?2 A
//高度
2 X' r: J3 h4 v( @
var marqueeheight=25
4 L7 p2 t2 {- K
//速度(1-10)
0 Y* ?1 y" H# \, }1 m- S( U
var marqueespeed=3
# G) }. K% U }' U" B
//背景颜色
1 I, N* v7 ~1 v2 R, H
var marqueebgcolor="#FFFFFF"
8 J" o# e' e2 E- O/ t- y0 _0 d
//是否能暂停 (0=no. 1=yes)?
! z4 I5 {8 R, [8 R& g6 [7 I
var pauseit=1
/ z( [# D# H9 y8 s$ \
; A3 j! c% C: W# Z$ q" b
//修改显示内容
: s P7 b& H _6 v& y
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
4 j* t( t4 j8 B2 E4 e
' X g$ f6 F: j$ H9 z6 d
5 C* `2 N% E5 Z4 J
////下面不需改变////////////
0 j( z3 ]6 S6 H: r( x# F1 o
3 A1 C. j& S E' t/ T
var copyspeed=marqueespeed
! c7 u* B& T+ h; Z
var pausespeed=(pauseit==0)? copyspeed: 0
' K$ h; e3 U# V+ a2 I' c4 _
var iedom=document.all||document.getElementById
$ c5 C+ I" e# {; l: V2 O) Q& n' k
if (iedom)
7 Y" S, Z$ W/ u
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
7 s( L3 t$ ?6 ~! a* F* W0 T) d9 k# C
var actualwidth=''
4 P% o9 {; `( B. U
var cross_marquee, ns_marquee
7 f0 ?2 n1 d2 W6 q& T" G
3 y+ G# |. `- [8 p; C5 Z
function populate(){
- g4 T+ M) ]) f$ m$ ^; e6 }, l
if (iedom){
" g. ]7 s# |+ Q* o! g+ i( e
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
: P8 L1 l$ ?6 I! V
cross_marquee.style.left=marqueewidth+8
6 W- {( B- J2 p( N
cross_marquee.innerHTML=marqueecontent
3 V9 n5 e8 x0 U8 g: v% B1 F
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
9 ~! N4 v2 _3 c# M6 L
}
/ `5 K- a7 i# |
else if (document.layers){
$ ~, Y6 Q/ n) C5 D4 a; U
ns_marquee=document.ns_marquee.document.ns_marquee2
" r! U3 x) a6 u A6 X) x
ns_marquee.left=marqueewidth+8
( s8 e+ S# ]* G% J5 `; E
ns_marquee.document.write(marqueecontent)
& J) X/ |( B4 B2 J5 g
ns_marquee.document.close()
+ ?/ _) [' k( l2 O2 g% a
actualwidth=ns_marquee.document.width
& R, B0 y: ^2 ]2 C: h& |5 u
}
& j/ x0 Z# y6 H: ^' X
lefttime=setInterval("scrollmarquee()",20)
0 L4 E: q* v$ N) P! E& |- n
}
$ v% i% s0 p' t4 k% b, E
window.onload=populate
! R g8 v4 ]0 \% }' r' T* e
; D. i" \$ g2 K$ W3 n. Y+ {
function scrollmarquee(){
. t( S: l9 j/ Y0 e! \5 D
if (iedom){
4 v/ A0 P& |8 N* } d* R
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
/ S* R1 V/ b5 X- e$ q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
' U: w3 c4 ]5 ^4 ]# i D7 }
else
7 G/ j( q" f; Y3 b7 R
cross_marquee.style.left=marqueewidth+8
4 r2 {7 j+ }! U. x0 L! v
- E' C9 P8 p& L% p; C& q$ A3 A( d
}
8 B: |* H4 `. ]0 p9 z) T0 [
else if (document.layers){
$ M( ^% L$ D& _, M1 @' N- ^
if (ns_marquee.left>(actualwidth*(-1)+8))
/ a9 F5 \' O e1 Q
ns_marquee.left-=copyspeed
' Y4 ?9 T. f8 G- |# ~
else
# d9 v1 O# _+ `5 O1 u5 Z0 }
ns_marquee.left=marqueewidth+8
; p% Y3 D; ]0 [+ F" Z6 Q9 V
}
2 X7 N' l1 g, j* s& J
}
8 K. Y( B$ [- |* D, d+ Y9 l
* Q4 x9 V/ b# ?' [' t+ [
if (iedom||document.layers){
* v V9 K0 w* ?# x1 Y- a
with (document){
2 T3 n6 p- i; Q
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
8 ?5 R' I. l$ {) m
if (iedom){
1 I8 x: @; j' ?1 Y) E0 z; _/ v1 }
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
9 r* B, d4 @# X
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
1 ]% g* U9 s/ D1 C6 \8 P: l. c+ T
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
, R+ M! r3 D1 e. p4 V: y$ l' U
write('</div>')
( Q( N% c/ i$ {1 c( _5 m, h+ V
}
# y8 l1 k" h. R& h3 m# n% L
else if (document.layers){
# I6 V; q6 X3 _+ g" H
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* ~- A2 i( q7 t5 y
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
0 v/ j6 z3 C+ ~& W6 t2 r
write('</ilayer>')
2 e+ v- {# o3 c; t
}
" |8 b1 K6 V: J! Y
document.write('</td></table>')
) S* T( E+ L" q V5 f8 U# B7 v
}
2 ?0 E( ^) l7 d! K1 R7 I
}
) M5 f9 j/ F, z" o
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2