标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
9 p# q% \9 n/ a0 o6 [
var marqueewidth=300
9 c" H/ h0 Q" E( _5 n" s
//高度
; k6 }* h7 H4 N& D2 H# @' z) \
var marqueeheight=25
% N M; q8 L, o5 p% D6 h: L) Y; V; r
//速度(1-10)
4 F* D9 Z% C3 \) s$ n& _' C
var marqueespeed=3
/ C) [* j! Q% C
//背景颜色
# g T6 v" D5 @& y/ o3 ^" t1 n
var marqueebgcolor="#FFFFFF"
$ {! W0 A5 |% [& O# z: Q( c- x/ i
//是否能暂停 (0=no. 1=yes)?
8 H% y: a9 A! x% v H7 l2 j! P
var pauseit=1
7 a$ d; M3 D/ `; `, s, H
3 r$ W9 }' E, L1 Z' [
//修改显示内容
5 g" U P6 V% t" J
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ g9 P8 Z5 X) Y
5 j7 n- e& s% g) U! L
. g) Y" r; n9 ]' c7 Q
////下面不需改变////////////
% i. L( N1 ^/ _- ~2 X, Z
+ e, I( s8 w$ n' ^! E
var copyspeed=marqueespeed
' ^" o6 u8 O' z5 z3 ` W
var pausespeed=(pauseit==0)? copyspeed: 0
' y, Z% ~6 j: m( ?$ x& |
var iedom=document.all||document.getElementById
) E/ h3 V7 b, J" J+ B
if (iedom)
B, w5 c- H0 e* }3 z2 V2 S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
7 Y7 [, f2 V. o. @6 x* u
var actualwidth=''
/ l7 i9 h& k4 [- e
var cross_marquee, ns_marquee
* W, e4 }+ M0 J( F
$ ? J( s- t9 n5 c9 B% ]
function populate(){
" G. L/ _* Q2 A3 k5 Z7 O& {+ c/ D
if (iedom){
9 @ `( ?/ w+ ]% n
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 O8 Y' @8 b5 y' I
cross_marquee.style.left=marqueewidth+8
' ?; ?- T8 `3 p# e9 }$ _, ~7 Q
cross_marquee.innerHTML=marqueecontent
0 y- y$ P+ T2 o4 f: N$ L$ F
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
% T' r$ P3 J7 t3 |2 e, G
}
\) L. z+ E0 W* C( D
else if (document.layers){
$ H- G H. \: t
ns_marquee=document.ns_marquee.document.ns_marquee2
' ?7 A: @# a$ D. n6 K- B( _
ns_marquee.left=marqueewidth+8
3 v" }5 `0 J/ O; l0 }' ~2 E
ns_marquee.document.write(marqueecontent)
% i" e) ]6 M9 |
ns_marquee.document.close()
$ B/ R7 D+ u. [( [; P
actualwidth=ns_marquee.document.width
2 E- z3 Y8 x" g4 O
}
; e6 k% q/ k8 r
lefttime=setInterval("scrollmarquee()",20)
! T5 }* c& z& N0 I1 g, _
}
& X4 B+ H$ P& U5 v8 I' }; E" d* [& o+ s
window.onload=populate
! A8 ~7 W& L! F( c/ h/ P8 G0 _+ ?
2 T- W9 W3 |: y5 y! ?
function scrollmarquee(){
9 I1 W( Y t5 i8 q/ s7 } m
if (iedom){
+ h2 |- H5 s$ T* b+ f1 b! A
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 `0 v O. w, l
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
3 ]0 F3 x, _1 D ^! T! |- M: G
else
: e/ Q8 m/ r" e: G; P
cross_marquee.style.left=marqueewidth+8
) y& U: u* S- R8 C
# [$ J8 r6 y& P6 F# t9 v
}
D+ W. ]7 F9 I: E- U! `2 H1 j! O. |
else if (document.layers){
. d* v! G1 k' W* J# F5 h1 [) J
if (ns_marquee.left>(actualwidth*(-1)+8))
% v* f" Q, Z! W( y
ns_marquee.left-=copyspeed
% G3 I% r, J5 }# C* ^1 ~
else
; E3 |- Q5 l# v2 |9 [
ns_marquee.left=marqueewidth+8
8 D1 O: _! D% z, o- N" m
}
% X* q1 q9 e$ G% g; Q/ l# @
}
. {# K Q5 w$ h6 D7 w/ P
. }; {, ]% k0 N$ {5 \$ ^
if (iedom||document.layers){
1 ]' B& f) k3 E- F) D. D
with (document){
, i9 A5 p( q' [6 C3 D5 a/ o/ K
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' @$ T( J. P0 u/ L- _: i
if (iedom){
$ b! n4 G+ N) T% C) P
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
5 u. l6 V3 z; V/ m% w: n% I! k
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
9 L# A' R6 ^+ h# K0 E
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
& y( l3 q4 T$ y, @
write('</div>')
) h, X) d9 R+ y
}
: h0 x: k! ?& q n: W! v
else if (document.layers){
7 i: ~6 T* e0 M, ?; m$ b, L. n! m K
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 d1 q) @. t/ ]9 i3 l- z. u2 G
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 z) \ n. Q0 q8 z
write('</ilayer>')
% B+ _7 x* D1 X. J5 G
}
/ w1 t6 I! [( I P; {- e2 ~" ?# a: A0 P
document.write('</td></table>')
0 D5 v) R6 {8 ?( m. U5 m' O
}
) f7 j8 y( B9 p+ {! u S+ x" b
}
+ B: ~6 C( S- F
</script>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2