标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
2 {, N0 @. @2 ?6 D
var marqueewidth=300
- h) j h6 u L- Q" G2 C
//高度
$ B/ h# L# P8 T' F7 s
var marqueeheight=25
2 b- I3 j# M( h, k5 w4 i. N2 O
//速度(1-10)
1 \& J# q8 r3 p! {6 v' C
var marqueespeed=3
; X- t5 I9 N6 O3 c
//背景颜色
, m* F2 p5 y$ K) E, a, v
var marqueebgcolor="#FFFFFF"
" |3 R& C! P5 k7 Y
//是否能暂停 (0=no. 1=yes)?
9 B8 ]7 z7 L8 q! ~$ w+ }$ D6 z' Q
var pauseit=1
- x+ P+ C6 w! b
/ d. G' T; e! f' d
//修改显示内容
) n' v2 Y0 z5 Y) ?: R
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ q I/ q' ?1 Y: P# E
; v L' @- {! S2 F' g
h: C. x0 J8 Q8 A% w# D( b
////下面不需改变////////////
) \, O4 Z1 o5 r- J% W8 c2 Y8 g6 {
- i& C1 o! e9 t
var copyspeed=marqueespeed
9 u5 Z L9 b" r) }7 i* ?
var pausespeed=(pauseit==0)? copyspeed: 0
" p% W' ?5 W+ v
var iedom=document.all||document.getElementById
3 \7 B0 S1 M% q! Y
if (iedom)
A$ V( `1 f ]: n
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' R! a. m& Z {! N1 q l! i
var actualwidth=''
* H- T' O. h0 x& f2 J( `& w
var cross_marquee, ns_marquee
8 H- _! Z0 X( N0 Q" J1 l8 S) l
! ?. Z* W+ ]# J A+ Z
function populate(){
' g( Q ^/ V7 j) l& d. ~; v. q# M
if (iedom){
0 O3 S- ~ _2 u
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
. ^6 Q4 [* V* F! N1 l# X
cross_marquee.style.left=marqueewidth+8
6 F7 G8 h/ q; a3 T; h
cross_marquee.innerHTML=marqueecontent
; F" z3 B1 a; Y6 w8 E5 m }2 ^$ X
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
& H! i$ _; E, S* v( ?3 `0 p0 z
}
6 d5 F! X0 i5 b) y. {
else if (document.layers){
0 ]- b6 t. y' G% H
ns_marquee=document.ns_marquee.document.ns_marquee2
& U+ E3 f2 Y% ]/ ` ?
ns_marquee.left=marqueewidth+8
. y% B' e9 z S4 m& Q, L" d; I
ns_marquee.document.write(marqueecontent)
& e7 q a8 b; s2 S
ns_marquee.document.close()
" A/ C: g/ |8 r) L3 u/ |5 p. k
actualwidth=ns_marquee.document.width
1 f& M* K! g/ d6 Z1 w$ B9 f
}
6 N7 ^! I/ T4 ?# ?% c
lefttime=setInterval("scrollmarquee()",20)
$ \* v+ J: j( s4 v3 A4 S/ |
}
% e0 X; |$ G8 x! k3 Y
window.onload=populate
* ]9 N+ K L: U5 Y9 P
5 k) ^. z, x# g, k1 J
function scrollmarquee(){
; p5 ^, C- z* i# R6 _; f$ G
if (iedom){
! O% l5 h2 d2 Y
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
+ C* n; k9 C) p8 D
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ R/ T) t( U! Q8 L
else
0 y2 {- j' T. k/ R; s8 c0 O! P
cross_marquee.style.left=marqueewidth+8
0 {( s& N* H% B
7 z; R, _2 V3 [' l2 j, U" j# c% y0 N
}
0 U3 \. b$ V5 s$ j$ z$ V
else if (document.layers){
* M$ z) O4 N7 G4 C: ?+ q! n
if (ns_marquee.left>(actualwidth*(-1)+8))
+ j) H9 b& U; a) C* e: H2 v: {, e! N
ns_marquee.left-=copyspeed
2 [: f, d$ ~' a* c- u4 x0 {1 @
else
! }9 Z# }& Q. T& P8 Y' v2 A
ns_marquee.left=marqueewidth+8
2 e+ L; V1 }/ P9 Q
}
0 X8 c7 l3 M) Q5 V7 K
}
* z4 M/ L9 f5 x8 B
4 i9 Y1 ]; w: S3 g
if (iedom||document.layers){
! S/ I$ `+ ]/ o, y9 P6 ~7 k/ b
with (document){
, H1 I, T6 C, V/ U
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
7 }! R! E) q u [
if (iedom){
5 t* e6 D [% ]$ |% G' b, i ^6 ?0 y
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! I# p! z$ O0 Z' @7 a0 c
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ B$ d- n' S. s3 t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 g5 {' ^+ b, S4 n; B
write('</div>')
Q+ |3 r3 C" l! l7 H' l
}
& `& @* m) q4 I/ ~. C) f# ^. U
else if (document.layers){
+ I) k5 r7 }7 k6 J( G% G* ?7 L, ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
- g6 }# `/ K5 [9 n7 z# M! D
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 o& I% _2 |% s
write('</ilayer>')
1 {9 f" Y! _1 P( U Y& m6 U) Q
}
- w* u2 [8 H4 s4 `% K
document.write('</td></table>')
6 m p- N( K7 X. t
}
+ }+ |3 q1 x9 M. t; d1 j
}
( S" _6 H3 t8 \
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2