Board logo

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

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

//修改宽度4 x1 q( j" ]1 o
var marqueewidth=300
/ }  y/ D; u" z. a//高度
0 H3 V) p* C) g" F& N% w0 c# @var marqueeheight=25
( I: Y4 k( j1 s* l5 ?# t+ o5 M//速度(1-10); I+ |4 x; Z5 R" e- O
var marqueespeed=3# G' B6 b/ D$ T" K+ Y. i6 q6 X
//背景颜色
# E9 E* \% [* t9 {0 q( d( F% b6 l7 @6 Avar marqueebgcolor="#FFFFFF"
! R/ l9 C1 b( d//是否能暂停 (0=no. 1=yes)?& u& H5 o9 i& U
var pauseit=1
0 a8 g/ O7 r, N! T# J
* C( j% I4 N: h+ [( q//修改显示内容
; [# @% x0 o9 T9 hvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'5 A- l# }! N+ [( l6 m/ l
- }$ l4 ~- m! r0 y2 Y3 F8 T4 Z  U$ U
. b6 }/ b* V" r' z* ^7 W
////下面不需改变////////////
1 o3 i2 |. n1 L
: X$ k9 s2 Q! C$ ^var copyspeed=marqueespeed
8 t" x. u9 \- H6 r' X  p9 m7 n# |var pausespeed=(pauseit==0)? copyspeed: 0
1 Y( J. [. f8 Y0 q; G+ k& Mvar iedom=document.all||document.getElementById
+ f+ g9 [  M5 G: K, X1 P. k1 Gif (iedom)
- n3 `+ L' B4 ?# Udocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
" ^( H/ U1 u8 cvar actualwidth=''
- L7 B* ]0 H" U0 Kvar cross_marquee, ns_marquee
, \/ i# F% r/ d1 H2 J  |) j# L* E( w  Y1 r# d
function populate(){
! j! S# \# g! L" K; Hif (iedom){6 S$ C; E) f% R& A
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
% e0 _1 K, v& p, Ycross_marquee.style.left=marqueewidth+85 e  ^; e! H- r4 ]- M
cross_marquee.innerHTML=marqueecontent, I2 j! P1 d+ n, M; W. j+ p
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
: c( F; \1 a1 d}
' {# V  p, u: x' velse if (document.layers){8 Q6 [# ?+ L1 S3 o( C
ns_marquee=document.ns_marquee.document.ns_marquee2" D& W6 [# V3 g+ m' U# t
ns_marquee.left=marqueewidth+8' g9 F/ F5 k1 a  p1 h3 P1 J
ns_marquee.document.write(marqueecontent)
  Y4 ~8 {  H8 h4 R+ X0 k! [ns_marquee.document.close()
* O3 s! [9 F6 t. E0 Q7 jactualwidth=ns_marquee.document.width
  T. G$ q3 z* Y# H}4 W% N1 F* B5 O* \" t
lefttime=setInterval("scrollmarquee()",20)
9 j) W5 n, C7 v9 K9 @3 v5 V}
) i& Y1 I- K& D6 ^/ |window.onload=populate
$ n9 x$ A1 B7 g% Z; _; P
. |0 M3 n7 n+ G  R: Yfunction scrollmarquee(){
* b2 B3 e4 s! T' sif (iedom){
5 V! @* ~, N7 A/ g# w: h! tif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))4 C: o7 ^! w' M' H: F
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed8 v; `, U% Q- C/ Z: s7 N* a% g
else
1 a$ }6 p1 n# t# _0 pcross_marquee.style.left=marqueewidth+8
& f; m! B# ^7 H, o( S0 s/ A1 I* D$ @. t0 ]* C5 R2 }+ H
}5 b0 r$ f5 ^- T/ N- D$ F1 r$ `
else if (document.layers){& U' }5 c2 l* [! Y
if (ns_marquee.left>(actualwidth*(-1)+8))
2 f$ n, X2 h% k% J& Y3 n+ {2 Z3 Kns_marquee.left-=copyspeed
/ O6 n4 C2 I5 W/ Aelse$ J. M3 d, Y/ o' Q& Z8 Q, G$ Y
ns_marquee.left=marqueewidth+8
, ]! Q$ ^/ @0 C6 m9 J9 Z}
; o* |5 O4 o5 \4 E4 \3 _6 T$ k6 w}
+ k( d. Q( c5 k! }5 v
0 o( V( D* P" |if (iedom||document.layers){" E; X& e/ m( j# \( v0 I4 W
with (document){/ Q  ^" \2 V: A$ p
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>'), p2 o1 n2 j* Z4 e% Z9 C* r
if (iedom){
4 u$ m, Q* n% e0 fwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
8 K. O' J! q! |6 Swrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; [, S" o4 ]: u8 Z- }+ y$ }7 B/ C3 @write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
* s. a! D, e$ B1 f$ e$ Hwrite('</div>')3 \: p2 u& |: P+ j/ H
}, A! i- p; v  N' x1 ^$ ~4 @# \
else if (document.layers){
" t* V$ K/ D* f/ d8 V' _) W) ^6 g3 {write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
! @* h6 {9 _  G* A( I/ hwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')3 q7 c, f9 Q, H  l& O. W
write('</ilayer>')
( p) A' G7 Z- g}) x* u* F  M2 U0 l. r& u
document.write('</td></table>')) l+ s$ C5 j3 Z0 t
}
8 S; X" `+ W' K  `  a2 C4 [/ ~  ^4 d}
# Z  K9 I% ^1 |9 |7 L</script>




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