标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
3 E1 s: ^8 I# W' x1 _
var marqueewidth=300
) A7 L- Y: X% N. a3 q) ?: @. ~
//高度
. M! w4 ]4 e* M) E8 T* I
var marqueeheight=25
/ d2 M+ c# w) P6 W
//速度(1-10)
. k; p, n- ~$ b! ?7 S8 `
var marqueespeed=3
- O6 b: u$ Y( D. R
//背景颜色
/ t( }0 X& ]1 B' _- p
var marqueebgcolor="#FFFFFF"
" n; X( ?, T9 O& Q+ }2 E" _
//是否能暂停 (0=no. 1=yes)?
% m& N# N3 ]( B- `
var pauseit=1
- y; h$ m9 f* D4 w( |3 d% a; f
1 a* ]' v2 e5 F' ^
//修改显示内容
) H/ ^: x8 X' [
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
" y- w; B4 G0 t- x9 |! [
7 v5 O4 c# T6 `; t' w) k, U
: Q- \# e# S6 L8 p" i( B$ f
////下面不需改变////////////
8 f9 x& Z2 \' O q5 l. }
0 v- ~# O) e" n+ ]5 J) K8 f
var copyspeed=marqueespeed
7 o6 `- q) ~( l% M' f
var pausespeed=(pauseit==0)? copyspeed: 0
* t# U4 c; F8 ?2 E
var iedom=document.all||document.getElementById
9 [ L# p% i6 V
if (iedom)
; E, Z3 F3 u( C# {- T' j+ X% `1 @
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
( L P; r! z, f' V" e! k6 v" ~$ H0 t
var actualwidth=''
2 }: a3 U2 b, Y5 n, S. S7 l( i
var cross_marquee, ns_marquee
1 F9 n; Y) t! {, t. ]% N
8 `/ c% R2 @$ A( F' e9 R% X
function populate(){
: ?" Q3 g; F) ?+ K
if (iedom){
4 v; M4 N9 N7 `6 E& Y
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
' ?" ?0 p* p& E( G* G$ c
cross_marquee.style.left=marqueewidth+8
7 F3 i/ m0 L4 R* a A
cross_marquee.innerHTML=marqueecontent
& S, [- w" g- b3 C2 F8 ^
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
) Z: I5 W- T# d
}
`0 j' K; L$ t, e6 E# l
else if (document.layers){
5 N/ Q; T# \9 p9 _) ^( y. i/ @
ns_marquee=document.ns_marquee.document.ns_marquee2
3 F: z/ a# G( Z( ~6 l
ns_marquee.left=marqueewidth+8
5 ~2 R6 C9 v& r1 C
ns_marquee.document.write(marqueecontent)
$ G% i* j# O; g( j2 k# j: z) K
ns_marquee.document.close()
1 q$ G7 A3 o# j l# P( t/ {
actualwidth=ns_marquee.document.width
" B6 i9 H" {( `3 g3 ^5 o
}
, g, s& K8 n4 N x9 R
lefttime=setInterval("scrollmarquee()",20)
; j, o# p, D% O5 s* u4 N, t. b- h
}
( b8 b$ Y# g5 l3 D" Z6 }2 M" a L
window.onload=populate
; l& \0 Q: m) u$ Y5 a4 ?* |0 Z/ K& t
/ Z7 R8 X: ^7 l R& E
function scrollmarquee(){
4 o1 ~. G' n8 E
if (iedom){
% d( y9 R- h2 G6 Y6 V1 M% b' g9 F
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
# O8 p5 O% t, F. E# p5 C
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
6 m3 w; ~' U. H7 _! z
else
* T) k' J; ~3 Z0 D& u/ q J l9 A
cross_marquee.style.left=marqueewidth+8
7 p1 [( |! R! J. Q
8 ^- p4 ]& i! `) [3 A/ |6 ]3 }
}
) S2 A: N; D$ Z
else if (document.layers){
& o: P) ~( k: t) @7 d, n0 ?
if (ns_marquee.left>(actualwidth*(-1)+8))
. Q( @7 Y7 @1 G/ t$ j& ~5 S
ns_marquee.left-=copyspeed
& r+ F0 L1 E" R# M8 Z# m
else
$ C3 b* F- B: N
ns_marquee.left=marqueewidth+8
- q2 K8 ^+ `$ l* V) U! V R7 T
}
* c1 h$ A7 H- D# d; D% `7 Y
}
n; B1 z& ]5 |
5 U% \1 X, D4 w/ U9 k4 n, Z
if (iedom||document.layers){
0 X0 Z4 c7 T6 i. J
with (document){
/ b0 h, v! @6 A1 P# V1 y8 N
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
1 w6 @9 F& a7 F/ c9 Q2 {+ Y7 e
if (iedom){
k1 u/ G* l' h3 P
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
7 K c. G7 q2 U) ^. J' z' B
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; ?6 S" M4 ~ K
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
5 r+ S1 V/ S$ b$ n O0 L
write('</div>')
: C; p' h/ }7 O* d& {# I% L
}
( ]7 T$ w$ q5 w: x
else if (document.layers){
! q1 H9 B9 W& F& q. J1 v' q9 \
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
2 m! u3 O/ T, L5 J" I7 t0 a
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
! k" @. Q" f6 e9 T
write('</ilayer>')
|5 }" W# O5 Q1 ~; X1 D
}
' W' z0 y+ | G2 X- V8 y+ s: r+ `/ t( g
document.write('</td></table>')
$ w! k6 ^" z J9 `+ O$ G
}
6 `% E. X% E( o& j7 c4 E" K
}
7 c( }( V, Y* [% C8 ?% c
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2