标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
7 O# o, K0 C( i# h$ d: X
var marqueewidth=300
. I7 O% g, L/ D8 q
//高度
8 M. Y/ s4 G3 t, K
var marqueeheight=25
8 T, W( v3 `8 q b6 M' P# D: [6 w6 G
//速度(1-10)
4 e8 O, K- J1 M! j. c3 N% _+ |
var marqueespeed=3
( i+ I) w9 s! j9 u
//背景颜色
- u1 Q) ^- y7 J( e& S8 h5 `
var marqueebgcolor="#FFFFFF"
, S: O' n* O/ v$ {
//是否能暂停 (0=no. 1=yes)?
8 ?6 J% L+ Y; L; r' Q, \, ?6 `
var pauseit=1
! Y' Q# x4 D1 K5 D( O
8 }) j3 j( @/ U5 i6 x R; ]+ x
//修改显示内容
" o+ q! E: {7 m. o( L
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
7 V" C v. U$ T/ k$ N) O' \
* V% w" Z u- Q( x' T5 P3 m e
6 _2 p4 t% t+ v* s4 y; R
////下面不需改变////////////
# D4 `' o8 r) [3 W; r
3 |6 o* B* s$ ^4 ?+ V
var copyspeed=marqueespeed
" \$ ~" \2 F2 s6 j6 E" v
var pausespeed=(pauseit==0)? copyspeed: 0
: B: g/ K+ h* R: v4 l& _& |
var iedom=document.all||document.getElementById
" W: i8 A/ l- I
if (iedom)
" l" C; z) k9 B _
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
! N# x! x9 h1 l' L
var actualwidth=''
* S7 R( w' z; }
var cross_marquee, ns_marquee
. K* U+ z+ F& ?! V% }) ~
$ ~; v; b7 f; r3 [1 S, M
function populate(){
. N0 Q' T- o4 C7 i% _6 l x
if (iedom){
# j6 c2 G1 N- j4 s4 }% q
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! S% f, `; x" B U8 z0 ~9 A
cross_marquee.style.left=marqueewidth+8
. ]/ I/ m, X# B/ l j8 D* g
cross_marquee.innerHTML=marqueecontent
# C( S) r, R3 ?5 M9 x
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
5 S- z8 b9 w! d% \
}
( A% T9 _: c) s; y) \, o4 T8 a
else if (document.layers){
# ]9 b* \6 C: F
ns_marquee=document.ns_marquee.document.ns_marquee2
2 Q7 [, c s/ _; h7 I7 }1 m3 o
ns_marquee.left=marqueewidth+8
; R, q& b% v/ W4 U$ ~ i
ns_marquee.document.write(marqueecontent)
% u" Z* g) Q1 A; x" |
ns_marquee.document.close()
/ ^6 n( d9 K5 |- D1 G
actualwidth=ns_marquee.document.width
9 \7 G3 n: t8 f% X# c
}
0 W7 t' x# T" P! `! N( ~
lefttime=setInterval("scrollmarquee()",20)
% u5 F- ~! S. C9 u* ?, }- x
}
. L) N0 }. ~, z/ P; R
window.onload=populate
; A0 q& b; l8 a2 X/ j6 y$ P9 E
V; \4 j2 e1 `+ C/ [& A3 L$ `
function scrollmarquee(){
7 C) b5 x; o8 P; X( Z, c8 ]3 s+ O3 t
if (iedom){
7 Z9 b, k% ]/ J) \- V
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* ~2 u2 W8 ~% I7 c
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
$ G6 ~' a* }# c6 c4 Y8 b- H
else
" |4 z8 K C9 v: J4 d
cross_marquee.style.left=marqueewidth+8
8 c, P7 t3 r5 }/ F$ c Z5 k
- k( d/ o/ j* t7 l6 W3 n6 [
}
/ r0 ~) L. C+ B2 s Z3 _( ?: u/ I+ T4 b
else if (document.layers){
7 H. W2 V/ f$ {
if (ns_marquee.left>(actualwidth*(-1)+8))
! J. k2 E& i" l
ns_marquee.left-=copyspeed
" ?; G" T2 G- U4 W3 U
else
8 Q# O# n6 z9 m- A
ns_marquee.left=marqueewidth+8
* N+ F# q5 k$ S7 j
}
6 m9 f; \7 E/ a" |" _4 i
}
/ Z: A. Q5 g1 i
# q* `4 d1 L* u1 U) v1 }
if (iedom||document.layers){
6 Z7 P5 n( q" Q& \4 |5 p
with (document){
# z2 b* q8 [4 @- V
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' R% w0 M1 }; x% J6 s# W
if (iedom){
. X% z0 y" x* e) E& G$ @* i
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( X* y) s" z! V% H' z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
0 y3 s( G$ |$ r
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
5 c* B& R! s. _) e3 h
write('</div>')
H ~* Q; m1 L) i' Z% \
}
2 B% d" E" N/ F' f. G
else if (document.layers){
9 d. t7 y! ~0 W' q! F& c
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
. O% y9 X0 s) _& ?
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 Z) p5 B( p# L: v, _& i
write('</ilayer>')
8 P" a) J6 y# g- b5 D. X' }, J1 O3 Z
}
$ B% X3 Y4 D1 A( H! K
document.write('</td></table>')
& m7 `4 A8 Y8 E" d$ B
}
- b# l) G _1 ]: c {9 D4 l, B
}
& ^; l: T& ~" J s2 s
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2