标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
+ t& a# n# ~: J' L5 G9 `
var marqueewidth=300
* I' X, j1 | p* z9 W3 ~/ M
//高度
* Z3 ~; `. u8 I+ G
var marqueeheight=25
& A5 M0 j/ k3 _
//速度(1-10)
7 m+ O0 L1 L2 S, q, ]' s
var marqueespeed=3
5 H, J4 U4 U% S. I1 g; S
//背景颜色
3 x. T( a0 z$ D! ?( k# q5 g# e: O! m
var marqueebgcolor="#FFFFFF"
$ w+ C1 F$ c2 t
//是否能暂停 (0=no. 1=yes)?
- `9 j4 D& P: E% o' i
var pauseit=1
: s0 E! J: U) t$ M$ u" |& f6 |
3 f% @8 R G0 m% {% I) V4 l
//修改显示内容
( j3 v' S/ @4 Z; x8 o
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 ?3 u; i4 @( a4 R2 _) ]
! I4 c0 F# K& W8 ?* F' p
3 a0 A. Q6 y" v8 H0 V K2 g* W
////下面不需改变////////////
- ~) K8 _ f0 R4 w
' k/ c) N* |: W4 T1 W: P1 P' Y
var copyspeed=marqueespeed
# h' ]# L# _, ^: y6 v; j! W
var pausespeed=(pauseit==0)? copyspeed: 0
7 H& r* N6 ^% j" W3 o: @) Z
var iedom=document.all||document.getElementById
. o; h4 ~# v: s
if (iedom)
/ ?" @" a* E% b9 ^; l) `
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
8 M3 z, a, [- m/ F F' n
var actualwidth=''
' U+ l. X8 [2 d/ R6 k9 c
var cross_marquee, ns_marquee
6 y1 r4 {! }) c# }
5 s) W! S) R+ W; s8 Z2 O6 T' f6 B
function populate(){
- L! x6 U- \6 P( c0 }
if (iedom){
, X9 W5 V, e9 \& {2 ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
9 C* ]: P e9 r- P: B+ Z+ F, `- X
cross_marquee.style.left=marqueewidth+8
s/ J% d" v2 Q1 r2 ?
cross_marquee.innerHTML=marqueecontent
1 N' o' ?! R8 V: @
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 I! K7 P" H% b9 [. w
}
' o% s7 _+ @ D4 ^4 q* I
else if (document.layers){
! H$ Q5 U$ Z* [) }( S {
ns_marquee=document.ns_marquee.document.ns_marquee2
! D. J- K" q& F7 I
ns_marquee.left=marqueewidth+8
, I5 `( Q- X: S4 \; [0 b6 s# @
ns_marquee.document.write(marqueecontent)
* O- H! c* C0 v# ^- z! _! t
ns_marquee.document.close()
( g5 ~: M- U' \6 u# x
actualwidth=ns_marquee.document.width
* J( G: R+ z% ?1 f6 ^, |
}
" E% S( J7 g* a" _( w' M0 T
lefttime=setInterval("scrollmarquee()",20)
9 }; [1 H1 \4 K& E0 u
}
; Y( y8 v4 @" f, v/ k
window.onload=populate
+ @+ g) k1 B, c7 z9 ~
$ z7 }/ U& \% o1 [, M }6 p4 V
function scrollmarquee(){
( r8 s" k- ]/ z$ t
if (iedom){
; d3 r5 J1 _# g0 h9 [: h
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
. D* J" j: E) z; y
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
, r; p8 c/ H4 z q7 R5 {; L+ R
else
/ X. b$ n; a$ ~# {) f$ y
cross_marquee.style.left=marqueewidth+8
& o5 ?4 c" D1 P. E% e
; i7 T, `5 _* M
}
( Z! b+ k F& P$ {& S
else if (document.layers){
7 V7 }: e0 [* p, c+ @
if (ns_marquee.left>(actualwidth*(-1)+8))
l: `( ]0 ~1 j `. m
ns_marquee.left-=copyspeed
. p; K$ L* i$ y! b8 R- d7 S$ [
else
0 p( Z: n5 z# m
ns_marquee.left=marqueewidth+8
2 E, U6 ~5 W- ~! \6 e: ?
}
; S4 r+ u8 z- d0 W L' O! J9 B& g
}
8 J ^, A1 I- u6 L& C3 G* B& ~
/ k, E- a( E k7 ~* t5 t
if (iedom||document.layers){
: @! t. p* y" a; R
with (document){
" { ~5 D8 L0 q, N0 z5 O+ s! I
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ R: s% V) T8 O! s
if (iedom){
; {- c r, W0 } P: n
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
7 _7 v( `. T+ u: H
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% G" @$ t/ z- ^( K
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 Z2 }# X1 L, x }/ b% P; d) f
write('</div>')
5 C2 N, R# n8 C
}
* \) S+ U6 K5 x5 s, r Z7 J
else if (document.layers){
! |" P" a, M4 Q7 P$ u/ H N
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
( U' u5 A0 F& z5 B
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
# G0 P! z0 s8 b z) f
write('</ilayer>')
/ u4 Z" _0 C3 V" @4 V# g/ q& r' y
}
, ^1 E7 c* J* G+ j5 B' L7 L7 h
document.write('</td></table>')
5 ]! K9 S ~1 ?5 Z" y$ W! y j8 d
}
) R% r* i6 B/ z# p# C) G& h: ?- w
}
' Y6 r* Q; E. |% s
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2