Board logo

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

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

//修改宽度7 R+ w: b% V4 H  @2 B! b" d* s
var marqueewidth=300
* D1 t) v7 [' |" ~//高度) S( Y4 s) @. I0 s  I; `# I5 B
var marqueeheight=25
+ Z" D: ~$ j2 d! N1 F//速度(1-10)) x* o/ R+ N) Y/ m0 G
var marqueespeed=3# t3 B( R% b- F/ r! K- x. y- X/ E! o
//背景颜色# V9 u$ ~. X3 K0 s9 u6 h
var marqueebgcolor="#FFFFFF"
; o2 {  g! r" D0 d* b5 d' d//是否能暂停 (0=no. 1=yes)?* N5 ]) q% ?$ y7 J& `# H
var pauseit=10 ?% b6 n4 z# W  p" F
; q) C( i* W! o0 n* A( t
//修改显示内容- u# m& l  v. W5 j  B' M( N
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
  r; A. _1 z8 U" a6 R4 W' `+ {. |3 m
5 ^5 m, _4 j& r+ F9 [
////下面不需改变////////////4 \1 k+ Q/ f2 E# I+ P. z
' B+ R9 V. d, m
var copyspeed=marqueespeed
0 Z, s) A" v# I8 o! R: Z4 Xvar pausespeed=(pauseit==0)? copyspeed: 0$ j1 @$ \# L4 [) M& m, A' h+ k: T
var iedom=document.all||document.getElementById
5 C( L' N) G9 g& {: I8 fif (iedom)1 T0 P5 B8 l+ R9 K
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')" X) b+ ?, f2 }. }. X
var actualwidth=''
! A4 I. d# @5 q' ?  qvar cross_marquee, ns_marquee' }) h" K' ]$ q
  X$ X" ~* \9 \# u
function populate(){6 h& {/ ?2 d* u
if (iedom){4 c3 F3 ]: F- D& F0 Z
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 N1 d* y; I3 F9 O2 `$ Across_marquee.style.left=marqueewidth+8
1 w6 r7 s( ?% a5 z8 J: A2 ?cross_marquee.innerHTML=marqueecontent9 |: X9 x# y2 Q9 l! ]( B
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
2 u9 B' D) C5 I}
8 y+ v# [- E  S4 t; C" Kelse if (document.layers){$ X9 Q; \1 @' p/ g2 g" D
ns_marquee=document.ns_marquee.document.ns_marquee2, ^9 n2 A  Y  Z; @( @4 @! A/ w
ns_marquee.left=marqueewidth+83 ]2 A* c( l1 p6 U$ i% x+ g* t. \
ns_marquee.document.write(marqueecontent)* _# f8 R; |; C! S4 W; n
ns_marquee.document.close()4 Q8 Q/ j* U6 Q
actualwidth=ns_marquee.document.width! N% @) E7 V  b& g6 D$ r$ t
}5 D$ \( q3 z' v' c  ]3 u" k8 k1 T
lefttime=setInterval("scrollmarquee()",20)0 s% z6 y$ j; S: V
}
7 P( \, Q  D  `window.onload=populate  \5 `3 w* X/ w9 O( v- m

* _4 Y. M2 n# d5 O; y1 _# p7 S  wfunction scrollmarquee(){
+ u* [6 H( W: v4 [# b4 Uif (iedom){/ H2 T6 T+ C4 o0 {8 d- ^/ }
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))( ]& [# y7 l: X( w* y7 J
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
9 X% S+ I, \" `* }2 nelse
# M$ H5 `: R3 C4 b8 bcross_marquee.style.left=marqueewidth+87 u7 s& M3 w3 i! _+ w) M; x" l
8 A  r$ p  v, v' B0 Z: Z' v
}
% U. K, Z) x+ D- q8 T. ?. Ielse if (document.layers){
4 I# {2 u& \8 m* {! \if (ns_marquee.left>(actualwidth*(-1)+8))+ r* _8 m9 v7 b$ C
ns_marquee.left-=copyspeed, E3 \; y4 a2 H: j; D! \8 l
else
1 T# D2 J0 }7 M- J7 l3 m1 Lns_marquee.left=marqueewidth+8
# G( o( F- [2 E: S}
4 M" u8 L8 l8 D7 `' g}' j$ A3 q: @/ _% [# k
- h. S8 a, F, n/ L2 ^" `
if (iedom||document.layers){- O2 K5 A$ X. W  M
with (document){' b8 r( r" ?! E2 V
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- f. X& F/ A; O; O) oif (iedom){
. N! X$ r7 \) }; Ewrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; @5 n7 P) E) lwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')  n8 \9 g! Q7 l; }' U9 |8 r3 X& N
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' @) m* Y7 k8 `2 G' Qwrite('</div>')& _" P) e4 T% p. ~! G$ J% o( j
}
+ q. U8 O4 b7 s/ g9 A3 Relse if (document.layers){
. _# e2 Q1 i! Q8 pwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')% Q. O4 r' s  ]2 x
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')# j: ?) h' Q% y5 P( e+ j
write('</ilayer>')& q8 }, {3 H; k' g+ D6 Y1 E$ I: }' X
}+ v/ Q: F% k" V: J0 `, i7 V7 x
document.write('</td></table>')$ @5 x6 s9 Y6 ^+ R, O
}) y  h9 m) k$ Z& a% }
}
2 q5 L1 b! A+ L7 I! o</script>




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