Board logo

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

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

//修改宽度
& @- l3 @& O/ _; y0 _% c, K9 g: F0 hvar marqueewidth=300
' Y+ X3 Y- E4 c& E3 \//高度
) b2 Z  Z9 E9 P, y: xvar marqueeheight=25
: u: p7 g/ K2 r4 s//速度(1-10)1 K9 H$ h  O8 K; Y  X, w- z
var marqueespeed=3
7 R3 r1 Y; [( F" N  ]//背景颜色" m2 |. R' K7 c3 ]! O0 g' C
var marqueebgcolor="#FFFFFF"
: t, p5 T$ Z* b1 _0 c  [, l4 t4 O5 I0 o//是否能暂停 (0=no. 1=yes)?0 s- @$ l$ Q% W+ E% L; C0 o
var pauseit=16 x8 h, ]8 ?4 O4 [, x3 y8 @

! n% t* |3 c! b# D6 U//修改显示内容
  F$ `; n8 e1 v* |* @var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'$ w% Z/ O1 c2 f) d  r& M2 g2 B: y/ L3 \
1 U& w& D$ A6 x
7 _* }& e* l1 g. k- F  p1 u
////下面不需改变////////////" e' I6 P6 |. q# `; |

$ i; `4 ?( T9 L" C1 k& h- tvar copyspeed=marqueespeed
' u0 Z& P1 n- E- L3 svar pausespeed=(pauseit==0)? copyspeed: 0
$ y. z. o8 U$ \2 Q( r/ @# m4 T5 avar iedom=document.all||document.getElementById% H3 o' N1 N2 v* R' x" H: c& m  i: i
if (iedom)2 d, i# N9 S( C1 J
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')4 K5 `4 K6 m% T9 y5 @! l4 s3 Y
var actualwidth=''; V& w. [4 E! S) k
var cross_marquee, ns_marquee3 ~6 Y0 Z8 A' ?  p
2 c5 H( e, _) ]8 i1 ]: Q: [/ c
function populate(){
3 S4 ?2 _: n- N0 @; S- fif (iedom){
* f4 Q2 `* k' h& Ecross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee! E, T( X. b; w, M4 `5 ^0 E. W
cross_marquee.style.left=marqueewidth+8' f5 @; \! [1 d
cross_marquee.innerHTML=marqueecontent, M; Q/ r; f+ C5 f
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth" ?8 m' j4 n) F
}- M% N  {+ ?8 o* T& j+ x
else if (document.layers){" q' V& h: r; b+ d3 r- d1 e
ns_marquee=document.ns_marquee.document.ns_marquee2+ L, r+ r# P8 W0 N; T
ns_marquee.left=marqueewidth+8
1 }9 C6 q# s- W. s' z& {0 Jns_marquee.document.write(marqueecontent)
5 M8 @& R+ q* L2 rns_marquee.document.close()
: n) E* ]- Q' O3 O# k. Z- ~2 ]actualwidth=ns_marquee.document.width9 C5 L- F4 H; A% i% G9 W/ U. G. |7 U' N
}
( x+ q) u0 ?1 f) K0 a+ ?1 {lefttime=setInterval("scrollmarquee()",20)
# H9 D5 L; u. w5 V}
; [6 v8 t7 k5 P3 z' A2 {window.onload=populate
; |5 P4 x: ^/ e/ n% X$ n& {8 M2 ^; c. ~
function scrollmarquee(){. U/ E  P$ y8 ^1 I1 U" N# ]. z
if (iedom){
  x1 v2 F6 {. K$ Mif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))" ?  R4 }" @9 j. m7 L* J: x
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
: l7 K& W9 ^2 ]" U* helse- s) r# ~+ F+ n! c+ g  I
cross_marquee.style.left=marqueewidth+8& p' Z2 C/ t8 {. r

/ r& i9 h; h) d# l3 z}1 r/ ?3 J2 d; [' z0 ~
else if (document.layers){
) }( A/ b8 _7 R- \- h+ a: w! Nif (ns_marquee.left>(actualwidth*(-1)+8))
- n0 p6 W9 n! E* z& V+ k; y+ Y$ Vns_marquee.left-=copyspeed; f" s) {+ t4 N2 Z3 g; E: T2 c- L
else
: R9 d% B" t! b6 ]* @5 x0 }ns_marquee.left=marqueewidth+82 B! i8 Y" G" d) n
}' N+ g$ X9 A) F7 S
}. r6 J4 C2 l9 ~5 B" O9 g9 N

4 F" M/ P0 Q' c3 c% hif (iedom||document.layers){
+ V1 q: A+ H' |% ]( gwith (document){0 n/ F- W3 i& V  j; P9 V2 w+ Y
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ K4 x+ |9 C2 |9 `0 Iif (iedom){
/ H- ~% f$ T$ v0 v) F) E  n6 pwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')7 X+ c/ i9 g" b- d' R
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; @6 c) S9 {% J6 X4 X7 \write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')+ b4 Y4 C! ]% V& l
write('</div>')1 \/ P1 W1 t0 A4 L- k
}/ J! e! n' W+ N6 X) C, w8 Y  J
else if (document.layers){# o% J7 A! Z. `# T8 N
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')7 P+ ~4 [3 Q+ t9 ~4 ?) X/ I
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
; J1 Z' B1 r! I* k5 x( ^  G6 Fwrite('</ilayer>')
! Y) k+ e( w& G  p}
" R0 {! _3 S; b) G- \5 D7 Idocument.write('</td></table>')2 x: l! ~$ }  F7 e
}
7 ~" c) F( `; j}6 D4 O$ ?$ s+ a7 ~
</script>




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