Board logo

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

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

//修改宽度# E' |5 I' d0 f# p/ K& D5 h# y9 x
var marqueewidth=3003 o& j% j0 e! T' n; l5 R- s
//高度$ I0 Y+ U) y6 G; B! T7 p) r
var marqueeheight=25
; W' Y7 y6 ?& |+ l/ T+ ]//速度(1-10)
! J4 [3 Y; V: b+ Qvar marqueespeed=3
( C9 h* B* Y9 k8 S3 V6 A5 I//背景颜色$ w6 }: O: x% N& f
var marqueebgcolor="#FFFFFF"3 L7 n8 ]. Q: h
//是否能暂停 (0=no. 1=yes)?
3 u2 v; k7 v0 k0 B4 uvar pauseit=15 }4 _+ w0 {' ]8 }, D

/ a0 G# S* I0 q//修改显示内容5 f& ]2 f. S. G1 l2 J, w( L/ h2 H
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'' B9 F2 R8 ]- p4 P
0 P, G% \- G9 e: i5 ^5 }! v  ?
- k/ E- H6 S$ e8 L; h2 t* @% @+ j
////下面不需改变////////////
) j+ ]( n5 `0 L- d, _$ _  q2 A: L, S6 E- K
var copyspeed=marqueespeed
0 K+ f6 |9 @) \8 hvar pausespeed=(pauseit==0)? copyspeed: 0. R( e7 |/ H$ m0 P3 Z
var iedom=document.all||document.getElementById
3 S$ J' F% o9 u! _$ F) }if (iedom); f& J& ?" ]7 f5 n+ g$ o
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')7 ^! C! `0 n3 R4 {7 R( S
var actualwidth=''
9 K! |2 a& ?6 G1 P# n- wvar cross_marquee, ns_marquee# b1 }2 @$ ?' f% L) X
8 ?" F- E# T& R& L) q7 q1 J
function populate(){
. I" S( m* y& n7 ~3 S) w+ Uif (iedom){
0 i& z, P9 P3 ~cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee: {# m$ s+ V, B# ]' g+ g1 \; @$ P$ p
cross_marquee.style.left=marqueewidth+8# d; c5 T  y  E' l  n1 P
cross_marquee.innerHTML=marqueecontent
) E5 M1 u6 l# v# mactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth0 D6 {8 w2 ~6 M
}0 g% J( Z$ R1 Z4 p
else if (document.layers){" \. q0 {  i& w1 C
ns_marquee=document.ns_marquee.document.ns_marquee27 X" ^; H4 }' `
ns_marquee.left=marqueewidth+8
! K+ O9 Y( ^$ ?8 R+ E: q& uns_marquee.document.write(marqueecontent)  T" b9 s: b/ F' y9 r2 l' c: J
ns_marquee.document.close()
5 x/ [2 U+ e6 O2 J0 Cactualwidth=ns_marquee.document.width
: R/ d1 @! o; A; W}) w4 m: M8 Y, a) \  _( S4 _$ D
lefttime=setInterval("scrollmarquee()",20)* {+ K, ~$ A7 I( X
}7 v3 h0 n5 S$ ^* Z* `
window.onload=populate9 S  x$ a- P- n$ B. O
1 d- \0 T, K+ q. H: l( l5 F: b
function scrollmarquee(){
  O: ]+ F  K- g6 [" L/ bif (iedom){
" U/ ~- _0 H, p! v1 E* H: ~; Oif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
, v% W* x9 D1 U, vcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed( Y. A: }& _! Y2 u* p/ \! o
else
$ ^2 F; B3 g0 f" \& d! f# O* Ucross_marquee.style.left=marqueewidth+8
/ L- x* M6 M( S4 @; q+ Q8 H& P- T5 u
1 c3 t) a7 t8 j+ F}
& Y3 f; k7 H, F  t! S* ^; O7 V% J# o6 Gelse if (document.layers){) O6 b# g4 c# x, L# O1 A  r3 J
if (ns_marquee.left>(actualwidth*(-1)+8))
2 e$ C* n7 d/ x2 qns_marquee.left-=copyspeed
: y, G6 i8 S) Y- selse. C+ k. i0 s  C4 o# e
ns_marquee.left=marqueewidth+8
6 N7 i; n4 N3 [% r5 W1 y}
( `' J0 M  S' v3 y* V}4 D/ k" M6 K6 W
; }+ R' y/ O. `( t* V; J1 B
if (iedom||document.layers){& Q+ A3 ]7 A, i& F+ ^
with (document){/ m: R( j7 S2 I6 n8 g8 h0 h
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')* K* q  ?: D. `) n
if (iedom){
( {3 y' v5 [' twrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
+ h- G& V+ i( k) ?5 `' P% C( M5 Qwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')9 T+ |+ N: E( A0 Z& \; {  O/ u
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
  r8 g! ~" L6 H2 Q. Mwrite('</div>')4 a: A7 i5 K* x, {  S5 [
}3 B: w$ R9 I! D. V" s) Y/ _
else if (document.layers){
7 G; K* P' }5 X8 X# l1 {+ ~write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')3 `, C3 U: M( S1 u
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')' n0 h& b* o/ s! S1 X! @  B
write('</ilayer>'). x% }  w; i+ \0 ^; ^9 A7 a
}  k: W) }# B- U0 d
document.write('</td></table>')" Q8 [( z! r2 i" @3 x
}# [) K7 _" P9 x1 @
}9 X- K0 B& I& y
</script>




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