标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
( d- A9 n1 X7 Y4 R/ f ]' Q' Z* n7 ?
var marqueewidth=300
: J. e( j4 q& L6 Z# [
//高度
7 l, X6 Q0 ~# f2 E1 `; A0 g# m4 X
var marqueeheight=25
/ n+ S9 k! a5 K+ L
//速度(1-10)
( P4 Y0 U0 Q( P2 q
var marqueespeed=3
/ F; p3 A" {% G; K
//背景颜色
/ [8 E/ O: v$ K
var marqueebgcolor="#FFFFFF"
5 y7 B* F k3 ~; U
//是否能暂停 (0=no. 1=yes)?
. u( n" b5 I; V$ L, T
var pauseit=1
. q+ U6 n) d/ i' D0 i) ?" _, e
/ g0 O3 I& |. m' n3 I$ D- O$ ?
//修改显示内容
l: k1 k+ L' P6 X8 G/ @
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
* x2 n& O+ Z+ Y: ], ]6 O
0 s7 i+ t# z) i- G/ h8 o' z# A
, {1 l3 F% g: w. f0 v% M
////下面不需改变////////////
7 Q, ~! u6 {: K' N7 b* ? ~
& Z6 V1 X& B( d" g8 z$ m. X
var copyspeed=marqueespeed
( E: Q, \ |( d) r, J+ d
var pausespeed=(pauseit==0)? copyspeed: 0
, Q$ D. p# p( [6 o9 n
var iedom=document.all||document.getElementById
; D C5 r. z6 h4 k1 A; A5 J# u
if (iedom)
; U4 P- `5 h0 V6 Q( T! U7 G' K- `
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
5 b# ^' o5 l: r6 l7 r
var actualwidth=''
! S7 [* c+ \' }& K
var cross_marquee, ns_marquee
0 a! O2 T0 X3 j
2 f/ z0 ^& } P' I; R
function populate(){
! f1 \% L( ^! m: d2 p% S9 {+ c1 W
if (iedom){
, m8 v4 [/ k* ^7 G8 I$ r% U
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ L/ Q: a2 C9 g6 U2 F" P# L
cross_marquee.style.left=marqueewidth+8
/ J, B( k; J' J
cross_marquee.innerHTML=marqueecontent
9 u, c6 ] v$ b, d4 e! y8 Q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
8 I# ` O3 ]8 V8 _- @9 }+ e& U% U
}
1 g1 H. D0 F" a* L
else if (document.layers){
/ N* T. i B% i L1 Z. `; q
ns_marquee=document.ns_marquee.document.ns_marquee2
# b9 [9 w: \1 G& P. `$ |
ns_marquee.left=marqueewidth+8
! @+ I; K% P* z. T' D
ns_marquee.document.write(marqueecontent)
: Y% t0 \2 h1 u. i. K& C
ns_marquee.document.close()
W6 i% ]" m2 O$ f( f" W( M5 v4 x
actualwidth=ns_marquee.document.width
: y7 S& n; W' e7 A! k# P7 r
}
$ Y+ o4 X% [: B
lefttime=setInterval("scrollmarquee()",20)
; [9 k* p2 u2 z" r ?) a
}
% Q' T; e7 Z$ Z# p2 w" }( x! x) p& L' ^
window.onload=populate
5 i6 B3 \# i1 Q/ l
& |1 `$ h& o! R
function scrollmarquee(){
3 a# h+ s3 g# l# ^! W
if (iedom){
& J" @1 m8 Y- A2 J: `$ s- P7 H
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& ^% Q1 k! ]$ z, t& n
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
' o ~& d# h& F
else
+ F" x: ?4 j5 @- s# L8 R; M2 }
cross_marquee.style.left=marqueewidth+8
) R& j8 \4 a/ r2 F" p3 [
$ }6 M5 r Z2 ?/ \+ U
}
P( i- e9 _! O( A. ]
else if (document.layers){
9 w* ?' \0 m0 Q. y2 y3 Y; E, o
if (ns_marquee.left>(actualwidth*(-1)+8))
0 w& v( `$ b6 T
ns_marquee.left-=copyspeed
) h$ W/ c/ f& r2 Y, o
else
5 s7 [) V% c' y/ e' I, @3 B
ns_marquee.left=marqueewidth+8
, s* P# z; G; Z* u8 Y
}
) }$ M2 U: G( W0 p( K" I. \! u% @
}
$ P {2 H7 a' V# x6 G; F, }2 b& f
# |% P R; L4 ]
if (iedom||document.layers){
* R" l0 i$ a" A$ ^
with (document){
7 Q2 A) {1 G- T+ E1 B C2 O) ]
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 d* @' L# ` h& ]. B ?5 g+ J( L' x
if (iedom){
! S$ i7 G! q9 z |: \
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. t; I; W; d, l. a0 ? n
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; G: y2 |( g" ?$ H- ?0 O4 \
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 V. u9 Z; T! E7 @( ~& t
write('</div>')
+ V* t9 ]: H; s- M' [! K2 b2 o
}
2 L1 h$ s& U# f) d) J# C: Q1 s6 F" {
else if (document.layers){
* i2 V: r( u1 T0 x8 A' R
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ O6 w# l, e- s
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. e. @4 m7 Y4 a3 @
write('</ilayer>')
4 i$ P" D( M3 E0 K6 Q" [
}
4 J. g9 B4 \+ x) \ J, [
document.write('</td></table>')
/ D6 d- o& n* ~& ^" c6 X
}
0 |) E+ c1 W) V0 O) }9 U- X
}
4 F; g3 @ L. `! m ?7 d
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2