Board logo

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

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

//修改宽度
0 E, A$ }, y4 dvar marqueewidth=300$ s! w# \- O4 n2 s' G7 P  l" `% ?* Q
//高度# n! Y) [+ n* ]  b
var marqueeheight=25; G# d- ]5 }& o  k6 X1 A/ c& w+ j: h
//速度(1-10)4 Q! B7 O3 b1 ]  _* I1 q; y- s
var marqueespeed=3
5 I( w1 I& t3 v( k* {8 `//背景颜色& e$ P1 O) J3 l9 P3 ~* L
var marqueebgcolor="#FFFFFF"  R3 \9 j$ K. `% G
//是否能暂停 (0=no. 1=yes)?4 n) ?' |* ^  [0 y! `! H% O
var pauseit=1: @8 a/ b" I5 P

) K0 j5 s/ L0 w2 z! X  m//修改显示内容
! ^4 W; e( P& a. F- q+ bvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
) S+ z$ R% b3 H2 j$ f, q6 E, Z
$ Y& e8 z9 D" z5 M  i- {
  E( t$ z0 O! S+ M////下面不需改变////////////; {4 k$ |; m1 a

& J$ y9 L" t5 O3 cvar copyspeed=marqueespeed
5 ~. j! m1 J8 p5 M- wvar pausespeed=(pauseit==0)? copyspeed: 0
3 h2 t  d) [  R1 A4 Q: `* i0 g, nvar iedom=document.all||document.getElementById
& {1 V& w  p% M; |if (iedom)6 H6 Q+ K0 S  b5 b$ A
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')/ q; }. f0 A. f$ R  M1 B
var actualwidth=''% c! O2 K8 G9 Z; B/ n  z. n
var cross_marquee, ns_marquee7 i, C9 l; m' {) g

+ z" R8 R- K  `2 A) O1 Wfunction populate(){4 i! s" `% m$ D  F
if (iedom){
. ~. ~. y- L! g! Q) F  Gcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
8 v' x" I( T, j( u- Lcross_marquee.style.left=marqueewidth+8
) L  y) w1 L' w, b$ m) A: ?cross_marquee.innerHTML=marqueecontent; R; ~( l; N, g4 X
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth& J& ?" s, {- s
}
: U$ ~2 }; S: ?else if (document.layers){
0 m2 e1 ^- P- G+ ins_marquee=document.ns_marquee.document.ns_marquee2
: [8 X& `1 S! `9 gns_marquee.left=marqueewidth+8) k8 H" W2 n. P6 z
ns_marquee.document.write(marqueecontent)! ~. _, u+ K1 b$ L* ]
ns_marquee.document.close()
- n% Q2 q4 U0 k! R' gactualwidth=ns_marquee.document.width$ l3 K3 r% q! i$ d
}
0 J2 y; L8 b( k8 x# v) Flefttime=setInterval("scrollmarquee()",20)
( h% {8 _  D  X: ^0 \}
) U8 e1 v+ ^$ W1 d' M: Swindow.onload=populate3 E" T7 Z% C1 x' V/ x1 O" o# J# L- |9 N
$ U" O0 b) Z& ~/ C. `* ?
function scrollmarquee(){
2 t$ L2 @. O% A  Pif (iedom){
; z* F: u, F7 |# u  Eif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))3 f- n1 M4 Q; W3 c: K9 U( r2 i
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
+ z  }' s  Z$ ~2 t  s4 w3 Melse! ~3 f# g* {7 V* V
cross_marquee.style.left=marqueewidth+8) g& b, a9 ^6 Y, A5 H
6 q& _, L8 G5 |2 D- l& l
}) A8 }" s* ~; p6 i$ q
else if (document.layers){* d! b/ L" ?! |1 R8 y/ J# n
if (ns_marquee.left>(actualwidth*(-1)+8)); a1 n+ F; `* a, e" I7 K( [
ns_marquee.left-=copyspeed
; I: F' V) y7 @else
4 F2 n! v3 S( |/ nns_marquee.left=marqueewidth+8' `; R6 G& p7 r. x1 S
}
7 `' u, L$ H9 ?! @, |+ ^}- {) w+ R2 E# Y  b1 D

( j! L. t  c7 o& R8 @if (iedom||document.layers){. o. w! l( b' t9 T7 R4 l
with (document){' ?) N0 Q: B& x7 H1 M3 T  Z& q
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 P9 T: B& G2 A9 Oif (iedom){9 J0 V2 [2 s" U# G, V( s
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
' y* S# J  D5 Z$ ?  i* z0 vwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')8 G/ e* i1 S% M6 \  q4 Z5 V
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')  m) W# U& o/ e: u+ s8 f
write('</div>')
2 _/ o, e$ M5 ]: C3 p- J# K}
' G( I, C* `4 G( W  b1 h: Welse if (document.layers){
2 a- `3 [3 x/ C7 l  w+ U0 `write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>'), |2 B) h" d+ U' |0 o5 `0 j/ e* k
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')" M3 B7 z5 V4 n$ A
write('</ilayer>')/ J) @2 |, d8 ?, a
}
8 K. j( h9 \9 Q* q" Jdocument.write('</td></table>')
) V. q% Z" K% S& q1 i: a5 x/ ~}
& B7 U8 u* h, a% O}
8 T1 D; e" O2 Q; d</script>




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