Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度
/ q4 D, R+ s+ _8 _2 `var marqueewidth=300
% E' N  `0 ]4 L( U/ c//高度/ x! b- d: J) G! a* g" U
var marqueeheight=25
; ~$ a6 [7 F& H; r& z/ q9 K- \6 Z" }, l//速度(1-10)) [* \5 W, F  A' t
var marqueespeed=33 l+ O3 P) V0 [; H7 Z- ]0 U
//背景颜色. F2 v2 _1 Z% p% A" ?' X) Z
var marqueebgcolor="#FFFFFF"& l/ o  k% p" e
//是否能暂停 (0=no. 1=yes)?
+ P5 m3 B2 ?4 P6 T( P( {8 ?2 y4 vvar pauseit=1
5 L& b5 Q) @6 `( {, L5 H" B& @0 }: q; h/ R; @  p
//修改显示内容
0 `; q' I- j! x" T1 G2 k2 ovar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
: @, x% h6 _* X& ^& M8 a  y6 Y
+ b2 A/ j$ L6 g3 S% @; ?
////下面不需改变////////////
# i- {' G7 e. p8 d$ C" z
. d/ @( `, _, F3 k, N0 Y9 Qvar copyspeed=marqueespeed3 z/ l5 j$ ~8 m) M) k* W7 G& D
var pausespeed=(pauseit==0)? copyspeed: 0' m% m# S0 b! F5 O0 ^$ J" l3 G* y* s8 u
var iedom=document.all||document.getElementById
6 _* u' L/ D  uif (iedom): G5 W! i& P& E# ^, x
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')& H" k2 d! u: x+ {% k
var actualwidth=''
3 ~# @( ?8 F: m* v: l8 ]1 lvar cross_marquee, ns_marquee6 c# q; P' B' F* |# U
+ p# u4 H, P$ |
function populate(){
2 F, A* l# s4 ]if (iedom){
7 l' ?4 }3 q. {, a- P4 ^9 \) t% ecross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
' y" p$ ~1 C4 v- H. rcross_marquee.style.left=marqueewidth+8  w; w9 `9 r' O& Q& k4 r
cross_marquee.innerHTML=marqueecontent4 X4 J4 P2 K; i7 s5 k- ^* K" Y9 C. {
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth" Y. T, ?5 W( r$ p4 a
}/ Y) f4 ?+ Z9 Y5 a
else if (document.layers){3 j; d' w; _" F8 E( e6 V' U
ns_marquee=document.ns_marquee.document.ns_marquee24 ?5 G/ r4 w- G1 H- ?( G1 A" f+ d
ns_marquee.left=marqueewidth+8
8 E( Q5 E" \1 y0 \( D* b' Y8 Uns_marquee.document.write(marqueecontent)& T6 q9 B+ l5 g8 S! R, m
ns_marquee.document.close()# Z: r* e! r3 I3 I
actualwidth=ns_marquee.document.width
) _% m5 o% }; o% }& K$ {  J/ x1 Q}
: N0 Z+ M# F' d; S- l+ Qlefttime=setInterval("scrollmarquee()",20)" v  O) Z# U5 G
}4 q8 ~: {- M" y: N" C; X7 e% x9 y
window.onload=populate
; @' O- u- e8 D. _+ \
: d5 _( a' N* n8 V  A) ?4 r: {5 \function scrollmarquee(){
5 z0 j* r( a& k8 h$ I# bif (iedom){$ {8 ]& @3 d# s; a+ ]
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))6 ^6 o( K7 _% N5 i
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
) Z- w: F; l3 s1 z- C6 |0 S2 aelse8 g2 p0 e  b2 ]5 X5 Y. P
cross_marquee.style.left=marqueewidth+8. I+ U/ J9 G9 j0 p. M) }# O

+ m# T$ @- S; d4 Q9 }' I}. N; }  X/ E2 y4 J1 [$ T
else if (document.layers){/ A& ~" V0 K: v4 `$ X% I8 i& p5 j' i
if (ns_marquee.left>(actualwidth*(-1)+8))
/ I# ^: U8 F  C3 b% @4 Yns_marquee.left-=copyspeed
. q, g5 o+ T+ G3 _7 S0 _8 gelse0 g$ H1 f6 @; F! W: S
ns_marquee.left=marqueewidth+8% ?8 t$ j, H- [/ R
}
' A) X( J9 b4 z8 Z3 _: O* v9 F}. T+ b" X( b$ _+ c

8 N4 L, V! }: J, M- Yif (iedom||document.layers){
$ N' O: O2 d5 r9 e' Z8 k4 }4 |3 {with (document){2 `& d/ z3 U& \: ^
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
3 K/ V3 h$ g: f$ W  r  M$ Tif (iedom){
! C1 U. M5 R' g6 f) q1 D# c0 Bwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* a+ ^" o. r; c' a; Cwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')5 ~9 ]  d& _3 n: i8 S9 {: l( v' Q
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 E$ W5 b( L( n9 E5 j( Z- k( Lwrite('</div>')
3 I8 u/ C! ~9 W% m}9 G# G6 u4 S1 W" p: x$ v
else if (document.layers){
& [( ?# O- ]' B, t2 o8 M! rwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
: O: r* j  i4 d7 A2 C. Y- Swrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')6 Z: l, a7 [) A8 l: _
write('</ilayer>')6 L  p' K  D9 T& [& o
}
# K3 M1 b/ q$ Y/ }) R5 p. S9 zdocument.write('</td></table>')
* ]. }+ H& m/ X% \+ ?/ m( L6 r1 _; G! U}* c8 M% N" K) k
}
7 B/ u( T' o2 Z9 y. r</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2