标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
3 @. f4 ^$ b! Q4 H
var marqueewidth=300
0 f; i0 E# C9 C# n' p6 H4 z
//高度
* \7 u- Q5 {& h8 T* w
var marqueeheight=25
+ H* C) I, h: g$ G
//速度(1-10)
4 `, C- c. S( w/ f6 v
var marqueespeed=3
) g! p! v1 c0 `$ a7 g2 B* T
//背景颜色
+ R$ \0 Y& J& ~0 A
var marqueebgcolor="#FFFFFF"
: O" |2 s8 Q I: W2 T) U" @
//是否能暂停 (0=no. 1=yes)?
. C8 ^ a' r/ e- h7 h; O- P% I
var pauseit=1
7 @8 V7 b9 O) m# Q+ X# B
# p5 T+ Q; j7 d" `/ T
//修改显示内容
$ U. N4 c* i7 _" P
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
e! [8 {* U2 S! R
5 V* l9 h5 q2 [6 N4 c
2 W; T# Z, c) v: k. ]6 T% K$ ~0 R
////下面不需改变////////////
7 X& y8 O# b" W; F9 K+ _) R, k/ S
' E: }2 _& h3 F$ k2 z
var copyspeed=marqueespeed
0 C1 _! F/ V; o
var pausespeed=(pauseit==0)? copyspeed: 0
+ q0 |9 `( P" P0 O3 f3 \ x
var iedom=document.all||document.getElementById
; w) A2 X, ^+ v" v4 ^
if (iedom)
* K5 B8 }- T8 k! h4 f1 S" H
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
8 D1 D# l4 U* T$ O- a
var actualwidth=''
2 Q" h% k; ~- l: W+ K4 `; p
var cross_marquee, ns_marquee
4 X& q$ n/ s- F. V6 v9 v
) I& W! d4 O3 u
function populate(){
# o. |7 ]5 [- Q/ b2 u) {" b
if (iedom){
5 A6 h3 n3 }6 C: s+ `* e
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
$ ]. q* Y1 m' F4 `
cross_marquee.style.left=marqueewidth+8
9 t+ u8 Q8 ^ r) m) Y
cross_marquee.innerHTML=marqueecontent
( Q% x) x z0 ^- }
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
) K; Y$ b, Z F% J& c: I
}
* K P% ?8 J3 Q- @
else if (document.layers){
% I8 u, {2 C, p
ns_marquee=document.ns_marquee.document.ns_marquee2
$ W: Z3 F4 R+ W1 E8 p3 i9 S% q& K
ns_marquee.left=marqueewidth+8
( w" s# T5 ]6 f [
ns_marquee.document.write(marqueecontent)
5 L. e Z* N9 c8 U* s
ns_marquee.document.close()
; c+ J6 l6 s2 Q
actualwidth=ns_marquee.document.width
( A1 ~( c1 d. W+ w! O8 a; S, ]
}
! X* M( Y5 m! `8 E9 k( Q. D
lefttime=setInterval("scrollmarquee()",20)
# j2 ^; l' w- v: y
}
3 m/ D l9 S! ^' }' k% p( [8 B" Z
window.onload=populate
( r, z- j, a% b; f" O' r8 n
# ^# I( [) v- B- c- p9 X
function scrollmarquee(){
( n1 u1 w# J6 W; S
if (iedom){
8 `! p& I0 @8 j
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
# ] r8 Q6 c0 h' B
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
. d4 T) g+ d2 ^
else
- h) r/ b$ b6 b9 }* L
cross_marquee.style.left=marqueewidth+8
3 ^( I6 ?5 x3 W
/ Y3 |4 S% c$ a
}
+ s( K* E6 F6 `* r. U
else if (document.layers){
3 T5 Q- n$ i2 t# D+ i
if (ns_marquee.left>(actualwidth*(-1)+8))
# V" _3 N/ s; Z3 [1 S
ns_marquee.left-=copyspeed
0 h# V2 X; q5 E
else
7 l1 i7 F* C, ^: e
ns_marquee.left=marqueewidth+8
) _0 B, J7 A$ u4 D/ W4 ^1 u
}
& A/ @: c7 \) ]+ Y4 s% S
}
' K% R0 l7 g) a
" g) I* H; P2 H$ T n$ O4 l9 U
if (iedom||document.layers){
% e2 H6 } A5 Y' ~6 ?
with (document){
+ C2 |* ?% v. y9 k$ _# j& y
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 c" J$ S9 r2 J# T
if (iedom){
. \) z3 A$ f, k8 m
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ h5 I! Y* j9 B# r" p5 f! D
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
2 V- v4 |1 G* Z" B% f8 m
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ k) `% l3 v( O) n+ H% W: J& X* a
write('</div>')
6 z% C7 m, c2 g2 z; {
}
/ t; _* P: v( J$ |1 Y5 U+ \5 y
else if (document.layers){
0 [( y }) Q0 W( e; J6 x
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 z1 B$ W5 }* z
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
* A; P* S; b: W1 h. l' B
write('</ilayer>')
, \, _1 V1 p, a: [
}
1 n9 B6 E% y$ b i' t' i2 X
document.write('</td></table>')
$ ?, w# P* g0 q5 P3 Y
}
0 s( o8 ^) V( {/ u( Y- @
}
* H) S; V2 _3 u/ q4 a' o
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2