Board logo

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

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

//修改宽度( w3 [4 t. M7 u
var marqueewidth=3001 |9 l( E: K9 }
//高度. j' n7 H9 b1 g7 {2 J* n
var marqueeheight=25
1 S4 B2 l( g' O" z% r//速度(1-10): j8 Y( B/ x" M: w- H
var marqueespeed=3  t. m1 P7 h6 p6 @& x  `
//背景颜色
+ w7 r2 I" n$ u4 m" Z& Z8 R8 Rvar marqueebgcolor="#FFFFFF"8 k5 I4 L0 z; p, N9 C1 b
//是否能暂停 (0=no. 1=yes)?
* E. a# y5 S3 u0 ?  ]var pauseit=16 t- h6 a; R6 b5 [& O" u, ]) [

3 b+ s0 `4 K% F+ H//修改显示内容
3 y9 [  W: n$ O) N9 ]4 W, Wvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'- T1 Y. g% u" ?1 j3 v2 D0 R+ e& a
& K  c8 e9 _7 f( l# I; U

3 z. U+ k2 m# T. Y  |$ e' A7 k* H////下面不需改变////////////( L/ n4 N( T' O! X$ c+ V

1 y; S4 P1 [  j, p6 L" Svar copyspeed=marqueespeed7 s  I) H% p: {( W; W( }0 A
var pausespeed=(pauseit==0)? copyspeed: 0
7 f5 R( G1 o8 |& _5 W! Xvar iedom=document.all||document.getElementById
' H" r" m# W8 w. W' W* x4 {/ |if (iedom)
" D9 y( d4 A9 l; udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')+ ?' o7 o" L0 n# Y1 T& z$ h
var actualwidth=''! ~0 i3 X0 b$ C% D5 T* e! {4 |$ w
var cross_marquee, ns_marquee
3 \, g# n4 H* U/ \8 r; m0 S0 y- H. t$ D; G% [: w
function populate(){" K+ V" r0 ^) ^, L/ ~
if (iedom){
" ?: O& j+ w) t: |- n% g$ Fcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 [( V2 |; n# ^3 x/ U) {4 f$ ecross_marquee.style.left=marqueewidth+8
6 \8 L5 P3 p9 A7 Y% _cross_marquee.innerHTML=marqueecontent
) W" T; M. F. Y  J$ u' }2 {$ f0 l* xactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
& W$ I6 x; N' ~: j& g9 J0 b}
& \+ y* A& J- w/ q* y4 s8 w% w4 ]: v) celse if (document.layers){
6 r/ d  G# S) ]3 P3 X1 q' R1 Cns_marquee=document.ns_marquee.document.ns_marquee2( t( Z- R0 h$ a' {  n$ R6 }
ns_marquee.left=marqueewidth+8% H# O! K+ {; }  V4 I+ G
ns_marquee.document.write(marqueecontent)9 p/ [8 {* |6 z$ L' v& {
ns_marquee.document.close()- L( m+ x; M# O& r6 W  n
actualwidth=ns_marquee.document.width
6 K) A6 Y4 y# n% T) |& w}) U- [9 N, p5 k0 I" \7 Y% Z1 i
lefttime=setInterval("scrollmarquee()",20)7 q" O6 F# k6 Z6 d' @+ o- A2 F8 [- c
}/ j: D7 B1 \; z0 I( b
window.onload=populate. d! o: v% X2 B! y) M& L8 ~
; [, o: m+ \) q; q% i
function scrollmarquee(){% V. S( ^( S$ z7 k+ \
if (iedom){
; P5 W0 J7 ]- D/ z* \if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))  V5 \: ^$ `  ^
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
; v# U3 S) w' H+ Qelse9 a7 @. f2 L" l% S! q# ?1 \
cross_marquee.style.left=marqueewidth+80 a4 V1 X( q* i6 [& n
6 m! l9 w0 k; b1 E9 u! J$ p6 I
}
6 P1 h$ Q/ \8 kelse if (document.layers){
) y+ A, C* f4 L2 F  J' dif (ns_marquee.left>(actualwidth*(-1)+8))
; a$ j5 l4 _) y! C$ a$ J# y$ Fns_marquee.left-=copyspeed
  E% E+ D, H9 delse
4 S5 _% S: i* V" q$ Pns_marquee.left=marqueewidth+8/ L- b: f" F/ O& b/ z5 b& ?9 X: z. C
}
/ e* T3 L- _' I0 S" Y0 p( I3 s}4 B6 @; u+ B: z7 i8 x

$ c: O! F& v& s) C6 Yif (iedom||document.layers){0 c- E& @5 m  a& R7 z) r* e
with (document){7 c. E" F2 {) T" @6 M, C
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')) \9 T6 z# A. a1 w( U
if (iedom){
. v7 D: D9 {+ \& ?$ m# h9 Iwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')" O7 d9 c0 o; s: l
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')5 ^+ i% g3 Z! ~5 `
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* N. k9 {" E" V( ?* `write('</div>')3 h  A6 W6 H* N/ |
}
& w5 D3 b) a( z1 \else if (document.layers){
1 U4 J3 f  b! G. G- h, Q5 |write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>'); P4 s) b. y  o( ^4 _
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')9 W- t: K9 t5 c
write('</ilayer>')1 ], u' v4 O6 u
}
' N3 a. w) d) M, V' Idocument.write('</td></table>')( B6 d, v7 W6 u; |9 g
}+ a' x6 A+ a5 a3 H7 Y: |0 \
}( \3 _" ~& a2 y) A* X9 P4 F9 q
</script>




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