返回列表 发帖

网页之跑马灯文字特效

//修改宽度# K  f& U) u/ ?9 [& q. h1 b4 X
var marqueewidth=300
( Y  |  L2 L; N2 M3 F5 Q//高度
& t( R7 H1 ]8 E* L  ^" nvar marqueeheight=25
7 p3 s4 F, M' q- _8 X. D0 Q7 a. h% D//速度(1-10)
( F; S' a2 h4 f  h5 Qvar marqueespeed=32 a# `& ]) Y9 X. o8 r/ K9 T; J
//背景颜色
: b  q2 z( D7 Hvar marqueebgcolor="#FFFFFF"7 T- j0 Y8 F" d1 y' C* c9 i
//是否能暂停 (0=no. 1=yes)?, T' i/ k5 y( j0 s/ d
var pauseit=1
( G# B/ b! `+ }- V: J; A& d! @+ r: {2 Y( T" y# t
//修改显示内容6 Q* z* R4 }& ]8 G( P5 O1 }
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
/ [: b7 ]; w1 d/ J4 g- ^+ Z+ u2 ^2 z2 z) h3 P+ p
6 c; f' O; \  e
////下面不需改变////////////
# {, D7 a( Q- P$ }$ a; b6 [! P& r
8 O+ h; n+ q( t& wvar copyspeed=marqueespeed* g+ o. [, x2 Y% q, K" ^
var pausespeed=(pauseit==0)? copyspeed: 0
+ j% l; q+ X# C  M1 C% ]var iedom=document.all||document.getElementById3 C  Q- O8 _# S* U
if (iedom)
8 z( p; v* \! s: M) n3 h* Idocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
  Y! c: g4 ]( z, f$ j0 a8 C2 g+ v3 Hvar actualwidth=''
0 t1 q8 L/ p: f, v" e1 `var cross_marquee, ns_marquee  b2 h; J# B9 o4 \' c

: ~5 w8 l0 L+ M9 U+ A! hfunction populate(){
. t1 v. R; g9 H2 f7 w- f5 ?: x( s' D8 jif (iedom){
* i/ v  L& b' Lcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ F  W6 P0 A7 _2 q; Lcross_marquee.style.left=marqueewidth+86 m; S0 g5 |( P  P2 o
cross_marquee.innerHTML=marqueecontent  P9 J0 _1 C- Q' m% L
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
5 f! e! w- J" h  N$ B8 ?. p  J3 I}- ]9 f3 s$ x4 O* {" i
else if (document.layers){0 W6 v5 V, Q9 [, U: }* X" D
ns_marquee=document.ns_marquee.document.ns_marquee2
4 ^- U. D0 j7 \  jns_marquee.left=marqueewidth+81 v1 n( D% r- A& v* \* T' q
ns_marquee.document.write(marqueecontent)
: L3 ?& Z' D, n: r" a; Ans_marquee.document.close()
' W5 _* V1 i7 ~8 p! A" S# b8 _actualwidth=ns_marquee.document.width% j; L* w3 r: S3 u( K
}
6 c% V3 s0 A4 m+ p9 v  ilefttime=setInterval("scrollmarquee()",20)
# m9 V3 p7 G8 Y, `7 `5 g* V: D}8 O7 p. Q" P( }4 K( Q
window.onload=populate
3 p$ ~( U0 k, T7 N# [2 _1 s! Y: Q/ [9 P& B/ N4 A
function scrollmarquee(){5 f& h4 q# J3 B, U( J( M5 ]# C
if (iedom){7 t9 [) t- R' ~" V5 i" x
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))6 h& M2 v, ]2 V/ ]( g  X
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
  t) Q" N$ l. r! g# m! R/ Pelse
+ N7 E/ n' _/ i) }cross_marquee.style.left=marqueewidth+8
; I- V; o6 k6 g- V9 i$ n5 ?  k. t4 ]- E( u( \, I6 ]0 r
}% l2 _% X  j1 R
else if (document.layers){
% d2 z" @( t( d# j, C; uif (ns_marquee.left>(actualwidth*(-1)+8))
( i4 A7 a; j$ ~( ans_marquee.left-=copyspeed* U6 w3 x0 V; [% p
else
  U# r9 g, P- tns_marquee.left=marqueewidth+87 S% Q5 u( H7 m. m  ?
}& W4 p/ Y5 L9 d0 Z+ T5 _+ u2 j
}8 D% e! }% ^5 o1 c
8 e7 W7 T6 a2 q: \' g& k+ C: g
if (iedom||document.layers){6 O7 t5 a& Y3 J2 J6 }) H- }0 k
with (document){
& v0 D2 i5 T8 A0 G  q! qdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 U1 J, P7 B! zif (iedom){% g' u  Q4 Y, I- b2 i
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')% Z8 r8 |0 O9 B  S0 s
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- P( b. {3 }" Z$ J+ A3 Swrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')$ |$ t. S! z$ Z* }- U; v! b8 Z+ h
write('</div>')2 |$ \$ J8 L* R8 t7 ^& W" x9 S2 P
}
9 A9 _# k+ f  T, Zelse if (document.layers){! A5 a- D  S. ?/ m5 V# x8 \  p
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>'), I& Q  u% Z, b7 g9 m/ q- }2 t
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
( w) d8 Z& F6 V9 Y2 o/ u! Qwrite('</ilayer>')
# O+ [1 n, Z# ~6 n- R}- i2 n. v/ @) S  q
document.write('</td></table>')
2 S. l2 c3 V' Q9 O) d}- X. x5 U. T. q) y& n8 r" L9 y
}) L/ ?. C3 \& a) n6 k) o
</script>

返回列表
【捌玖网络】已经运行: