Board logo

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

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

//修改宽度. e) R" n4 d4 Y* G+ b7 E
var marqueewidth=300- I8 l( ]! D7 Q- I: Q6 D" B
//高度) t$ X  H% `% I7 A
var marqueeheight=25  z. K( e0 A, G) I0 b
//速度(1-10)
2 j) K* i! {; f9 o5 Yvar marqueespeed=38 |5 ^* L9 v) \7 H! y# \  d7 ?
//背景颜色+ E9 ]2 X7 C+ D6 s
var marqueebgcolor="#FFFFFF"
5 r% y- p  B/ g2 O//是否能暂停 (0=no. 1=yes)?
- Z! q$ [! @$ n+ Lvar pauseit=12 U( {8 y8 }, I8 }1 @
, D. H  T* E8 p! ?; b0 Y  J3 q
//修改显示内容: @0 b& W9 l! o' y
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
% E( d6 c: T3 U, w2 `5 J2 U" s! Q# R/ [
" e* b! c% m/ G- \1 H* \5 n
////下面不需改变////////////) k# `3 u1 O! ~% `

9 i0 `3 Y% [2 f" l: r: d$ B3 }var copyspeed=marqueespeed
. S+ c- P% h& K- N" K; Avar pausespeed=(pauseit==0)? copyspeed: 0
! t4 a6 G' T0 |2 z' v* Dvar iedom=document.all||document.getElementById
( r, d/ y. X$ G' |2 X* s6 \if (iedom)& F7 G5 R7 F6 ^8 k
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')  s4 b0 I0 L3 O. m0 k- c
var actualwidth=''/ S6 C' _1 e- t" V9 f6 x3 @; S, P( z3 `
var cross_marquee, ns_marquee
6 e& n' q' p6 E& Q6 p
1 x9 c  W- R& k( j/ K7 v: Afunction populate(){
' n( @1 ^  ?# e3 Oif (iedom){
+ e! [/ [- C8 {- ~cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee; c, H) t) ]- a! n4 O, L- B2 R
cross_marquee.style.left=marqueewidth+8+ J/ S" J; W5 a" a. q
cross_marquee.innerHTML=marqueecontent
+ @/ ?0 a  X; g% g$ Z$ D* ]) Wactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
/ H6 F& o. J! |$ {- z5 n}: t! C* P. R% e* E" Q9 }9 W
else if (document.layers){
; M* ~4 Z7 N1 U  R8 nns_marquee=document.ns_marquee.document.ns_marquee2+ Y3 k6 n2 R: Q' a! r2 Y8 i1 L! g! X' U0 R
ns_marquee.left=marqueewidth+8' I: a( ?8 C+ l  Y0 t9 o' {! C
ns_marquee.document.write(marqueecontent)% U5 P1 W3 {1 X* V5 o
ns_marquee.document.close()
* ^4 E8 t. Q# ?actualwidth=ns_marquee.document.width
7 ?4 U2 c( O3 F, @}
* W1 A# o4 e& w' Mlefttime=setInterval("scrollmarquee()",20)$ A0 Y  T7 }% [/ N. o8 X0 |
}; T- }2 C8 L, u7 y4 T
window.onload=populate
/ f( G7 x  Y) a* K# |( ^" P
/ _" V1 ?8 ]; Xfunction scrollmarquee(){7 J$ d" T  `6 _3 h3 n; y
if (iedom){5 D& F1 M" N; K% ]4 J" W+ {# b
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))) S& [7 q5 E* K5 `. w
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed) A  g, S  w4 M6 q! [' z- P
else
& E* u% a4 c' vcross_marquee.style.left=marqueewidth+83 P# z- v, S: G& p  J
4 E7 \8 x3 m5 u9 `3 O( ~" u# B" Q
}5 g0 E' e( J0 L8 G5 j3 o- }
else if (document.layers){- A' v( g/ t  N% C
if (ns_marquee.left>(actualwidth*(-1)+8))
$ W( K- r; S# L  u# v) v( r& mns_marquee.left-=copyspeed
) ^" i- g6 [1 _' L( U9 ~3 H/ Delse
4 }  `' d0 i: o. n0 K% t, yns_marquee.left=marqueewidth+88 N2 a! B3 R: R$ {1 z2 h/ ?
}
$ O" c6 C& ^9 i: X" K}/ t1 c1 W2 x* {# v

6 C# a$ R* c& M; ]if (iedom||document.layers){2 X, V& ?  V, [- s2 a( z) Y
with (document){* |6 p  Q4 b6 C2 V# e" K
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 l+ p5 n+ u; q) Y9 O. h: |if (iedom){- m6 x9 Y4 M: e/ D
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
5 u% X: B5 l% b9 f" \! zwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
: V) z3 x5 v1 j1 }! O/ F# Fwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')( P' @1 m5 J! O3 L/ b- Q5 h1 T" i! ?
write('</div>')) Z- |7 n" Z) H% I  [. q* |3 S
}
3 [8 O  K- d: `# T6 telse if (document.layers){7 T  |7 K7 ^- ]3 b! U4 [/ O* V
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')) o: ^- g' M' S0 A2 |
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')- o1 ~' U; l1 g, w* A5 j3 {% Y: [
write('</ilayer>')
0 R9 X9 [+ F$ z3 n1 r% l( D}
0 d" K" o! R. j1 r* r. Hdocument.write('</td></table>')& Y# d4 g: W+ P" h
}
: J" y; ^2 p4 f' _# w5 C}: E8 q2 j$ Q1 w
</script>




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