Board logo

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

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

//修改宽度* M- G4 O& r2 x. c9 _- w: g, M0 h
var marqueewidth=300% J( n* R/ i5 j  e
//高度: w  X) ~$ g& x# ^, y0 E6 a6 _) q
var marqueeheight=25
. K2 V+ U+ d/ F* }1 X2 R//速度(1-10)
/ o! C7 i5 z5 ?0 A1 h/ {var marqueespeed=3( h% @9 t/ E' ~5 Z2 W8 F1 c3 \
//背景颜色
% x9 ?# h( G4 }var marqueebgcolor="#FFFFFF"2 e) a& t$ y. w+ x
//是否能暂停 (0=no. 1=yes)?
/ x" l9 L" J3 Y$ N8 {var pauseit=1
3 z4 R& ?3 T4 {- R, b( J# P
. x; i: m, E# ~" [( s2 m( l//修改显示内容% q5 ]6 U1 m7 w8 F
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
  u( b) }+ d6 p. N6 }- s! J+ G6 |0 P& C
: J% U9 d: }5 J) V8 ~8 H
////下面不需改变////////////1 r+ D) I. s4 D4 L

1 n& C7 b' B. V% Nvar copyspeed=marqueespeed0 e4 Q7 d+ I  n" y
var pausespeed=(pauseit==0)? copyspeed: 0
5 ?4 `/ w6 ]0 E0 H7 nvar iedom=document.all||document.getElementById
; h% w6 C+ l' H: Kif (iedom)2 l8 ?; T2 Q: \* Q
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')& v& c- K0 h( r2 x9 A8 `
var actualwidth=''- s/ D/ \0 W: W  J( ?
var cross_marquee, ns_marquee- @/ \# K6 m! o+ P; p/ ?6 X

% K0 i/ ]5 E7 F$ B# B) X9 t+ Xfunction populate(){. \2 |" u0 {1 C* b9 _9 G, T0 o# P
if (iedom){) W3 u0 D/ O3 [
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
$ x* {# e) u" [- ]$ c+ B6 f- Q0 Pcross_marquee.style.left=marqueewidth+8, f) u( z1 e: u8 r
cross_marquee.innerHTML=marqueecontent
7 {! E: r, [) Factualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' J6 m, N+ A5 Z* V! o}( u5 O. x; N1 O; O" s
else if (document.layers){
3 M, @: {2 j! {+ Bns_marquee=document.ns_marquee.document.ns_marquee2
% [" p+ p3 K7 B8 y, C* C  l8 [, |6 {ns_marquee.left=marqueewidth+8
0 S6 ]+ g& r' @8 yns_marquee.document.write(marqueecontent)
# c2 G, N/ W: k) ]8 t( }ns_marquee.document.close()4 }7 g7 V4 T3 u
actualwidth=ns_marquee.document.width& z# L' G7 o% ?$ F2 z/ o( a) p
}& c: E) F' z9 J. w: B0 {
lefttime=setInterval("scrollmarquee()",20), j& A8 x' p6 c" b# T* P) T
}
+ T, W9 q7 X9 T# h0 ^+ @0 }window.onload=populate
: }. P1 t6 _1 M
+ D) L8 K; P" {# `function scrollmarquee(){
- M) T: T4 a( nif (iedom){$ S0 G  ?/ p$ c3 a
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
4 g' G5 P% y; J0 F% R# Dcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed1 l" K/ r+ r$ I' Y& k
else- B1 S/ z# ]- j0 y! I0 }
cross_marquee.style.left=marqueewidth+8
4 B; Z7 G5 |+ P3 i* j
$ x3 s' }) a# A# N8 t# x}2 Z6 i2 o( y% t& j
else if (document.layers){' J, v+ t: L$ i
if (ns_marquee.left>(actualwidth*(-1)+8))( o5 H$ h* x1 i+ R  d& L* u
ns_marquee.left-=copyspeed
2 ~; n* f/ r- U+ pelse! y( u& e" t8 p" q& G+ P& Z2 A7 s/ E
ns_marquee.left=marqueewidth+89 ^/ m2 T( G, X6 d. `& Z
}
5 O$ Z; @) A$ o0 K}; j+ h8 h( k9 x5 p+ |3 U  ?5 X
! N4 R1 z3 L8 W% ~7 L, T
if (iedom||document.layers){6 t) N& [( J- Y
with (document){" K; ^- {$ p# O, B- l: w2 S
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')0 P" v3 v7 E, y  A4 Y3 x4 O
if (iedom){& S$ {( Z8 x# q+ Y' K
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">'): X4 f/ Z) H1 k& V4 F7 f0 n
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')1 i6 [+ X4 c( f* f% r4 _: ]. Y' G
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
/ x" y" g0 H1 }# J; x+ n/ u$ ~write('</div>'). O/ s# B3 ^% M; {& c4 t
}1 ]. G& E0 h7 |9 L( u
else if (document.layers){3 M( k  O7 R  f+ r
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')" Y5 W+ H6 {9 }4 r2 ^
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')- n- n, t8 P( T3 [
write('</ilayer>'). i! z: x5 {& `: y
}
" h& O6 W: C" j/ _! ddocument.write('</td></table>')1 g8 |0 a8 S- ^- r- S
}
5 o# d% C: R# ?5 R: Z}
* p5 [: f( Y9 S$ ~</script>




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