Board logo

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

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

//修改宽度
$ \% A6 G1 p2 Y+ Fvar marqueewidth=300
, G$ ~# I( q( W( G. U//高度
: {0 F/ G; t- }: `( ?0 jvar marqueeheight=25$ C: ]# {" y, x/ e3 A* q
//速度(1-10)0 k" b/ W) C6 O7 ]8 Y. S
var marqueespeed=3; ]5 i+ `1 Z7 y( r% Z
//背景颜色
+ ]( R$ ^1 o9 Y/ _5 R$ avar marqueebgcolor="#FFFFFF"
2 p4 [' h2 C0 ~6 M) h# _//是否能暂停 (0=no. 1=yes)?
: k+ P' W" ?9 O) D% Fvar pauseit=1
9 r+ ?/ n0 c; ^$ K) N
4 n3 E* L) J0 N# t0 U& Z' I//修改显示内容  u+ D2 `" N8 y% G/ Q; |
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'0 I$ M! g5 U& c7 O, v4 L, _- W
' H. ~9 w: G6 S/ `/ P& p
! }; O2 W; `) G3 n0 l
////下面不需改变////////////2 Z/ a. |, \: I3 x! V  L

# ^2 e6 j6 r6 t. o, Cvar copyspeed=marqueespeed1 a  Q' |, H0 @; O$ `
var pausespeed=(pauseit==0)? copyspeed: 0" Y: v3 _: J0 _! B4 ^$ y
var iedom=document.all||document.getElementById
. F$ K3 ]! {* U% J( nif (iedom)
7 \& z1 M1 a& [/ M% `document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')# w2 b2 h0 }$ v" [
var actualwidth=''
- j# E6 m, C  ivar cross_marquee, ns_marquee
% F, U( Q" h4 Q  w; c% W7 K2 k1 Z. X/ y# z' I
function populate(){
& i- P# W; a8 w2 x0 F( ]if (iedom){5 K- d# E# u* t: ^' w/ l
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee# O2 M$ o% E1 s# m
cross_marquee.style.left=marqueewidth+8- f  F1 @3 I( x
cross_marquee.innerHTML=marqueecontent0 z1 @9 O/ b/ g) E( j8 t+ S
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
4 n- S) ]8 n' T9 L3 S}
) }* }2 g' y7 U4 V( Q2 Ielse if (document.layers){6 [  B' X1 ]2 L/ [5 X
ns_marquee=document.ns_marquee.document.ns_marquee2
( b4 w% R) X: e  G1 n) Mns_marquee.left=marqueewidth+8/ o- H+ C- [+ t' F5 B+ @
ns_marquee.document.write(marqueecontent)( X# _- h  a# s7 {- Q0 y3 m
ns_marquee.document.close()7 K% ]3 c5 J6 _4 \
actualwidth=ns_marquee.document.width6 h9 B' [+ @7 P- k$ N. n
}9 P0 E6 d1 m, Y2 N, K6 b% \! E
lefttime=setInterval("scrollmarquee()",20)
% j' B" w- d" X}
" p% t2 P7 ^  q3 K# w) \, u, ?window.onload=populate- n8 |4 i$ B1 O( p& K# ^7 {

5 {+ U) A2 C/ O5 O, k, Ofunction scrollmarquee(){9 G. _" f: r1 Z/ b
if (iedom){
2 l) o% W8 V6 u8 d1 X0 zif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* G* M2 @8 l6 G# w& H* W- P' J6 Icross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed, x. Q- w1 F( i  S  T0 u
else0 ~- `: k) b; C8 x7 G; G
cross_marquee.style.left=marqueewidth+80 _% q  z9 ]" @  \
" q  K" u  A( t3 M
}
  b" ?* H# q8 K0 u. u. F' welse if (document.layers){" \( h6 v) X7 D1 @: b
if (ns_marquee.left>(actualwidth*(-1)+8))
$ a+ G+ b( ?4 N% J5 bns_marquee.left-=copyspeed& q, C  p! j. b1 A2 {
else
$ a; T4 w- R" s' ins_marquee.left=marqueewidth+83 |5 {- K1 |$ \
}$ O- m: p% |3 M% \/ f% {( f
}- {0 o% |: }! E( b; A1 W# G. G
* a- F6 F, ^( ]
if (iedom||document.layers){8 X9 K- _) p4 h
with (document){. V0 n, f5 T2 ?# c% [, X
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
/ c& g' g3 B; Uif (iedom){
% l% N  J' P3 E* G2 i* a0 Twrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; t+ J2 {/ N' ]$ D2 a) Q6 ~write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">'): L, l7 [6 N, u% S3 _4 a3 L: P
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* n% S1 ?1 @! i8 k$ U9 B% jwrite('</div>')
; c# Z' I. y* y) x4 B}
5 s4 R# m* S7 J6 I  ielse if (document.layers){
6 w. ]; k4 Z7 g; s7 ?2 ]* U& [' {+ L* Fwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')) z1 e3 d$ E9 d9 h, O7 W' N9 h
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>'). e, J, x% \5 \0 _  ^( z
write('</ilayer>')' t0 u3 b, ^8 v% [
}7 B9 c) h2 }9 F  g* Q9 c2 b2 ~3 o
document.write('</td></table>')# l& i; `; o0 F7 Q0 o# d/ T; i" R$ ]
}/ G2 Q3 U% Q0 }: P4 k
}
# \5 J+ Z8 @( l0 f% k: ]7 ~</script>




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