Board logo

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

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

//修改宽度, T. C* T. X0 C+ W0 L
var marqueewidth=300) w. n- x% E& ~  N0 Q
//高度
& H- ]: n( f% G; G0 R# pvar marqueeheight=256 l5 @  b7 n0 h0 J' U) V
//速度(1-10)
" G+ o, |/ P/ e! S5 F& \, W/ r5 Tvar marqueespeed=3
' A4 T, o7 f/ \: v* \//背景颜色3 ?5 }+ d! t# u- b! w' B* V* j
var marqueebgcolor="#FFFFFF"
& k  L; N& p4 n" Q# `' Z- @//是否能暂停 (0=no. 1=yes)?
7 C0 }  u/ L# Z# @; G) tvar pauseit=19 F' T9 G) `6 k# I: N9 t
# Q5 s  u$ I- ]4 Y
//修改显示内容
: u7 `9 Z# `9 k1 ~0 ]var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ g$ b8 @% b0 _4 b6 B1 q7 y  [6 z* k: z. `" C
7 \/ f* y. ^5 X8 D' ?
////下面不需改变////////////1 M% Z$ @( C" \! k# _" `

  ~  M; P: d: S/ `0 ?" U- |2 Rvar copyspeed=marqueespeed
4 E7 H+ ]' {) y2 J- Z( E9 I, w: yvar pausespeed=(pauseit==0)? copyspeed: 0
5 A* c1 r; t( V' w$ hvar iedom=document.all||document.getElementById5 n, i  l0 E  I. F
if (iedom)
/ ~' z2 s/ b  @% U2 v& u: ldocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) C+ t" K; z) ovar actualwidth=''
& t5 a3 L8 L* H' G- x% Tvar cross_marquee, ns_marquee5 f2 `) o3 d/ \7 o8 [7 l
2 G2 i. Y$ G: D* ]
function populate(){
3 v6 L, J7 b/ n. Z: F) oif (iedom){
; i8 E% I+ |! J- i9 M& mcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee0 B& }4 a. E2 }4 D9 m' t
cross_marquee.style.left=marqueewidth+8
8 A$ E) ^, j: N! |' Bcross_marquee.innerHTML=marqueecontent8 o- n  t) n7 B8 i6 o) E6 i
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
1 H1 g# V5 a! J; e7 }5 M- b0 E}
$ P$ `4 ?- Y5 V  G- Y  \$ Y5 b, Oelse if (document.layers){
0 Q* p$ g( j4 r" sns_marquee=document.ns_marquee.document.ns_marquee2
9 H1 L) t$ ]% j& Q4 Y4 Dns_marquee.left=marqueewidth+8
- S5 L- Q* i) u; `ns_marquee.document.write(marqueecontent)& x+ g  a% }% V! w/ ?
ns_marquee.document.close()
# R9 R; R2 t+ B! v0 y. u* pactualwidth=ns_marquee.document.width" K4 W6 `: ~# [" }: z, f% F* |2 B
}7 N) E; a, O* n3 P1 J, A- ]% i
lefttime=setInterval("scrollmarquee()",20)8 S. b& c5 e: q$ h
}1 x* ?/ b1 E6 G' }6 _+ J! _- {
window.onload=populate
: I' _4 t* t" b; K1 ~' J8 h
; g/ D; K( a) W& Tfunction scrollmarquee(){
* Z% ]; x2 Y$ M: h) \if (iedom){) c7 @+ x0 _) M! |$ g7 Y+ k
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))+ x# g2 f7 u: q. m
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
' _; M! f2 j: A8 N& k: \! o$ q# Ielse
8 J, p1 P. H; ^4 O1 tcross_marquee.style.left=marqueewidth+8
( {: u, C# A, I; S0 u
/ i, @! ?0 k: o6 [' G3 F& R}
( ~) |1 G$ U& z( r2 R/ |. ?else if (document.layers){
1 }9 c* y/ V/ |6 I& t5 Oif (ns_marquee.left>(actualwidth*(-1)+8))
4 w* o2 e! m+ f' Nns_marquee.left-=copyspeed$ c6 }# Y# ?* u6 n+ D
else
1 O0 R% l# B2 T% ans_marquee.left=marqueewidth+8' B" f) q$ C9 W
}0 t. l  a: V/ ]) g  F  b' q* N
}5 F) L4 L0 b& `$ v6 C2 Q- O

+ W# n, y! a9 h) E, O4 Yif (iedom||document.layers){
2 D" `" q* Q2 Z3 G8 W' F. pwith (document){; i& }" z4 c, M# N
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')! O: i- m% r  f6 U; H3 Y8 c$ Y+ G
if (iedom){' L* e7 m3 P2 `& Y' t
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')! ?5 z# _( q7 i$ ~& q
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
4 J9 z, C2 k7 Zwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')5 m8 O- Q$ m& ^, U  h: L* F$ ]
write('</div>')" ~8 N$ W; ?. G$ {" V+ G+ a
}
* L; x1 e: ?0 ?else if (document.layers){
: a8 g5 [/ l* a9 R: ]write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')# \; Y: e- S4 ?/ E7 s
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. q8 ]" f1 E2 x9 e4 G; wwrite('</ilayer>')
* {5 T+ A2 I6 b; I7 O}
; {0 l( H9 _8 |4 B+ A, `document.write('</td></table>')1 }; Y2 U" Q+ [% i/ }8 K( o7 K
}
, Z  }" B4 |5 c/ {6 I5 C}
& ]. `7 j3 h! b9 O  w( A: z' U</script>




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