标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
& k! J; |8 l a) W- p
var marqueewidth=300
& q) _% g' H" X E2 T/ t
//高度
0 x, I+ y1 D0 ~( a7 |0 s
var marqueeheight=25
6 o$ B& h# }' k. g1 V' Y
//速度(1-10)
, G) U; k! A, U( Y* }
var marqueespeed=3
+ A [' J |! K9 C3 y
//背景颜色
- o( W- l) o2 M; F2 w2 h" q
var marqueebgcolor="#FFFFFF"
3 L6 F6 F9 E- k% H! b
//是否能暂停 (0=no. 1=yes)?
% p/ J9 i6 v: }3 K" t
var pauseit=1
5 I s( p1 X' a
# q9 x0 o6 w- [- D
//修改显示内容
( s5 p9 x: x( _, L7 M; u9 }8 S2 ^
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
# S# g0 s8 ]! h3 c
. I+ P1 Q2 n% @
$ D: ~- r5 e' u6 d: G
////下面不需改变////////////
* k) ]$ W# I1 Z5 n. t
& Q1 n9 e8 e8 |8 V4 B+ M
var copyspeed=marqueespeed
, h N; k$ f, |! z6 v
var pausespeed=(pauseit==0)? copyspeed: 0
9 u8 j0 J; e3 r9 H9 ~4 j0 i
var iedom=document.all||document.getElementById
9 e! G* f# q+ q J. h
if (iedom)
! C: s+ K1 z% v& U6 e2 o D* C8 |0 X
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
3 U: y# N2 \) j+ e9 }
var actualwidth=''
: F8 G: G' K. f1 s, z y
var cross_marquee, ns_marquee
/ J+ N; F, D( N+ X/ U) P
9 f$ ^! k/ ?: D& _ `$ n
function populate(){
8 {3 L" J. B$ u' r5 R; C. S1 u
if (iedom){
9 a! {, n, X5 s$ ]$ N6 e
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ \% W/ v# u/ I u" \! }- |4 d$ d
cross_marquee.style.left=marqueewidth+8
' @ G: }% }: m; T
cross_marquee.innerHTML=marqueecontent
+ n4 _1 [. |* s( U7 s% j
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' p0 h. a R: z2 T
}
+ u6 F. {1 _: y \5 c
else if (document.layers){
+ r! N3 y! K. e( g5 Q
ns_marquee=document.ns_marquee.document.ns_marquee2
0 c% o8 r; i; X$ O- e/ M
ns_marquee.left=marqueewidth+8
0 l d* x$ G: Q5 x1 z
ns_marquee.document.write(marqueecontent)
# ~- s% V8 c% J2 w; X$ s# R! r
ns_marquee.document.close()
( R6 k8 L* |- l: g$ e& k
actualwidth=ns_marquee.document.width
6 I+ s0 G( G2 C: W% c
}
) `* [% M3 `1 |1 e" w
lefttime=setInterval("scrollmarquee()",20)
: m7 C- ~3 A& u# k) S8 I1 J
}
$ {" [- F& W# \3 ~1 F7 _9 R
window.onload=populate
2 N) U, g4 }" B
8 [- H) z# I( P# G; d2 x
function scrollmarquee(){
% G- D0 g( C1 z- T
if (iedom){
" m2 z6 E0 m/ O. Z, Z0 K6 a
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
" @& K+ O( }% O& g1 C) B l+ G
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
( @. n* ]* h3 Z
else
6 u& |2 j* m) a3 ]: F6 w
cross_marquee.style.left=marqueewidth+8
8 I! I- J6 u) C' G6 Q
7 j- |* w" {: {. s/ `! {& N# k
}
& x, J3 j4 u) e7 l0 X* G8 y
else if (document.layers){
' ^7 {8 v2 j3 P+ j( Q) G( [
if (ns_marquee.left>(actualwidth*(-1)+8))
8 b$ x. r7 K3 _ }: T
ns_marquee.left-=copyspeed
0 a0 k8 L$ u+ j. i# y' s
else
T4 d' l; v% x. b% \: @% C* v
ns_marquee.left=marqueewidth+8
, D4 z/ a) ]. |* b* d. O9 s+ ~4 ]
}
4 j1 {. ~& M' l" Y j% M
}
) H+ d3 C2 ?9 S* Z4 O. q5 f7 x, h
" v. @2 O* o- F" B T' F, \/ K) N
if (iedom||document.layers){
' t, S5 Z b8 ]
with (document){
* s9 F. {# ^. S
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
* O1 T) F1 y' ]+ y6 Q# p
if (iedom){
2 D6 P, i3 `6 y g0 m6 x5 K3 n y
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
' F% U: e+ @8 c& h7 s! g
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
B- U+ w7 G7 L/ Y: I: h% i
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ ^$ x( y. ~! V, p$ K- ?5 H) o2 H6 ?
write('</div>')
. I$ Y/ B% R Q' _3 f& H+ o+ t
}
" w* V# w& v; c5 G6 }( [
else if (document.layers){
$ L, e% ^* H* G. ^& B J# i/ S' B
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 @3 t' V: U7 {" s2 V) G4 ]! }
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 ?; l8 ^ X! l
write('</ilayer>')
1 t+ T( V8 [3 n4 Y; E
}
" K: G; D5 G1 q Z9 b) L5 I' y$ W
document.write('</td></table>')
5 j. U3 u/ n* K c! m
}
+ m, Y/ h6 b0 z! M
}
4 \8 e3 W! D7 X& C& p
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2