标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
2 w9 u5 W. r# U% S6 C8 T
var marqueewidth=300
, f/ b$ `# `8 {( m5 J
//高度
0 f* q8 M" ? y5 q# V' J% C
var marqueeheight=25
! C" `# |: i& H% A' L# e
//速度(1-10)
5 }4 x. X Q c8 F* R8 ^
var marqueespeed=3
0 |3 c/ O8 K! H# V; s" F6 }
//背景颜色
0 K* D' J, u2 N$ r3 C: o* N
var marqueebgcolor="#FFFFFF"
: t! Z0 O+ c) J- L/ y% f( r6 x# }# `4 n; t
//是否能暂停 (0=no. 1=yes)?
/ b' K: d& g+ i f5 ~. p
var pauseit=1
; I) G5 n5 h8 n! v- D
}: |4 v" `. b0 H
//修改显示内容
2 e+ z4 p8 g A; \, [& n
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 ?7 r% z% K- d( I' d8 c
% P* r* F8 Q8 g% d9 W9 I% ^
( D# [: T1 r+ ?! ?
////下面不需改变////////////
" ^5 y9 @/ p+ ~9 Q( b' i
3 W0 m$ i4 m" t; |, M: ] x" d
var copyspeed=marqueespeed
1 }) X: E* z. j, f
var pausespeed=(pauseit==0)? copyspeed: 0
6 r7 z/ X( _! U$ d7 c) l
var iedom=document.all||document.getElementById
0 b- a6 n: A, Y+ E. W! R1 z
if (iedom)
- }4 ]. Y, K. [8 O
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
2 M1 V7 c7 `9 c* o
var actualwidth=''
/ S/ y" {, f0 k5 O, V) m+ K4 j
var cross_marquee, ns_marquee
9 K3 n* J5 Y/ ?" a: s
! {7 S$ I- @0 Q- n& R; f6 V5 w. t
function populate(){
# T) ~1 O4 y# ]) M( {% s' u+ S
if (iedom){
0 q$ m& M1 }7 K: `: w
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& p, O9 c7 L$ m6 h4 h# u: Z
cross_marquee.style.left=marqueewidth+8
+ P: x1 m9 p2 h% X% v9 f7 x
cross_marquee.innerHTML=marqueecontent
0 t* s* |& }2 V: k8 j
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 V j7 e4 w7 }, ~: f2 r9 t
}
$ y1 R9 u" L7 U, j. F
else if (document.layers){
, W+ T/ A2 |2 F$ k' X; ~
ns_marquee=document.ns_marquee.document.ns_marquee2
, U$ v& q7 ^3 V; @, v5 T/ V
ns_marquee.left=marqueewidth+8
* l8 G( E: V* l" h
ns_marquee.document.write(marqueecontent)
9 X" }0 h2 e' X% v; k1 p7 ^) ~
ns_marquee.document.close()
: t+ z* j! g9 H4 k) G
actualwidth=ns_marquee.document.width
1 S" v, X% Q3 W9 W7 t
}
9 p+ G. n; T$ [% P$ z9 V
lefttime=setInterval("scrollmarquee()",20)
% K' l9 ^9 k7 X) [6 W8 E
}
/ b/ w) C3 u# O6 l& `
window.onload=populate
) h4 b6 C0 F w
' z; y7 _) D {$ T6 i ^- ?' I
function scrollmarquee(){
w m9 x, B7 f* z
if (iedom){
* @% ?0 w, O8 h2 G5 |1 U# @8 [
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
- e" Y) X W K6 b
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ j; a8 z7 e X; W& r& n
else
6 U9 P4 z# _# X
cross_marquee.style.left=marqueewidth+8
7 _, F4 O1 C/ T. E! w& `$ y
, Z7 l& r. Z( o+ }1 _- W& i- \- _
}
0 ?* P5 y6 y- R- x& L: e! V
else if (document.layers){
" `: f% v0 w9 x& O$ y, g
if (ns_marquee.left>(actualwidth*(-1)+8))
' n, Y5 P# D# }) Z
ns_marquee.left-=copyspeed
: A5 I7 o1 i- H* V; V
else
& w$ H4 ?3 C) e! l
ns_marquee.left=marqueewidth+8
, S- A" V7 a2 r5 a
}
' @- K" d" W, q% u
}
* b1 F! _6 r m, S; L( n7 }' P
' d9 j( B: q- P5 `
if (iedom||document.layers){
- q$ v8 }! H* M4 s" B! _" M' T. I
with (document){
/ r$ I8 O) s+ G
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
% `7 J* m/ N; g; O8 B6 e+ b
if (iedom){
3 |. D# t6 J2 N
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
0 K& R, Q8 V" Y# B
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
) w; c% y Z# M
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# N8 }0 R$ Z6 b1 d3 Z# k+ ]
write('</div>')
) M0 |) C5 P/ e; p% k+ Q
}
& t9 {8 K' D I: l6 T6 i1 l
else if (document.layers){
+ R$ y& B3 _; Z9 A4 q+ ~! c2 U( l& X
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* m, z2 L! z- v$ A
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
0 b7 U% B( g% C# m
write('</ilayer>')
* ` S) U, r' Z( c* B
}
+ V/ Z! }* w/ ^: p2 E* ]
document.write('</td></table>')
( Y6 X$ O* i W6 b
}
& l# K* t8 t- ]4 Z$ K# R
}
' v7 A0 }8 t8 u$ W
</script>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2