标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
. H; r, R- h# ~, ]& v y) k" q
var marqueewidth=300
0 A, N8 @3 v' r6 @ y) @
//高度
* H0 [) e7 f: I! N9 z
var marqueeheight=25
& Y! L$ X, y9 q, O( _4 |
//速度(1-10)
3 a, N9 d! M1 ~3 s. I5 `) ?5 e& c
var marqueespeed=3
% R. W! e; a& o' L
//背景颜色
2 X }; s' m, n' x, V
var marqueebgcolor="#FFFFFF"
: F- Y/ n( g+ \* _. i9 W! M
//是否能暂停 (0=no. 1=yes)?
e$ Z- }8 O- B& J+ Q
var pauseit=1
" p% R/ m5 m, e
! q7 a9 H8 _! z/ J; }4 W* w0 Q3 l
//修改显示内容
4 X4 z7 v$ v8 T+ L0 l7 q2 N
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ p4 b0 H j, A* e; E- H5 S' x; Z. z- M
' g, N+ l$ K' |& g+ e, L( q$ t9 ]
4 Y1 j0 q* U" I6 \
////下面不需改变////////////
" V! b' M7 K/ D
+ n X7 J) o7 H5 g) q" y' @3 s
var copyspeed=marqueespeed
/ A, o0 R& U! e. J
var pausespeed=(pauseit==0)? copyspeed: 0
( z0 C+ ?8 }0 W) {7 H- b
var iedom=document.all||document.getElementById
) x$ u, f& p0 P, {& Q& a% _2 [
if (iedom)
' ]" ^ _9 @ p
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' X- ~* r0 B9 A; D% b9 I r& [( S
var actualwidth=''
3 L' W% L; f/ B% h- H/ v y
var cross_marquee, ns_marquee
* l1 \' A1 Q' _, b% P2 c9 [' g2 W
! G" ~/ e. [" J# Y- Y
function populate(){
' i! ~' R" ]" \, x% A
if (iedom){
0 b# F3 S) G- u
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
7 o0 D3 H: W) \9 E6 v/ _! l
cross_marquee.style.left=marqueewidth+8
{) Z* W- [1 K! |8 U
cross_marquee.innerHTML=marqueecontent
7 t" u+ M" Y/ E0 W$ o# q R8 X7 H; y( |
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
$ u/ N) d( \6 E) V' \; t* P( N, W
}
# I$ U4 _6 Q; b* `
else if (document.layers){
# I; Q8 r& n/ E- r% ~$ P( `' n
ns_marquee=document.ns_marquee.document.ns_marquee2
) Z5 ~/ A7 G6 M" q2 o% z, d
ns_marquee.left=marqueewidth+8
& j' w5 N) Y+ E1 ]% P
ns_marquee.document.write(marqueecontent)
6 f2 f$ S( s% x1 I! @& C
ns_marquee.document.close()
" _4 x* j( w# G( f ]! G: r4 M {
actualwidth=ns_marquee.document.width
7 d$ F2 k3 J4 u
}
0 k! K( _4 y3 t8 C2 R2 D
lefttime=setInterval("scrollmarquee()",20)
: g+ r( ~$ h1 k& u3 a0 I$ p
}
% M2 f/ K6 p0 V
window.onload=populate
6 R: E! v. \3 e3 o" i' T
2 I; {, D1 w) `5 y. `% V5 q
function scrollmarquee(){
3 Q$ n: N/ v) e. r% M6 G2 @
if (iedom){
/ X- G' g& A, }+ |2 \
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
5 D3 w9 \4 o7 y6 t0 i
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
) o" Q7 W9 m {7 c w- l
else
& P5 z7 K% n( I. \. P2 U9 R* z6 i9 h
cross_marquee.style.left=marqueewidth+8
c: ~ S- [* v" Y7 J8 A' ?) w7 ?
* f$ l3 R) [, w- s5 d3 H1 ]
}
. x4 f; C( x" {/ w5 I( K
else if (document.layers){
% y# y( `. Q9 @7 s% |5 T
if (ns_marquee.left>(actualwidth*(-1)+8))
/ }2 m& G5 R% w
ns_marquee.left-=copyspeed
( r1 g, Y$ R- v7 G, g
else
; Y2 |/ M! V5 x& D
ns_marquee.left=marqueewidth+8
) `) _/ }5 s8 h4 @: H0 w. s
}
1 v" n; V* q% N) y
}
; ~6 y7 g' q, T9 f$ S( i
7 m5 J, S; u0 ?* R) l% M# ^$ {
if (iedom||document.layers){
" p7 y* Z- S% E x8 K O; w$ _
with (document){
( H/ G0 ?% j- B2 f2 ?% F
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 Y0 D9 i; ^0 Z
if (iedom){
5 `* B1 S6 q1 r0 Y4 k
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
+ g; v; W+ \( v
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
' O) R6 D3 H7 r$ _4 g
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" u$ U; K. s" c" I& J- `$ p
write('</div>')
9 n9 ^+ V, N- M# {( s6 x6 g7 m
}
8 d8 l% a$ `+ f9 Z0 K
else if (document.layers){
+ z4 X9 ^4 i9 @, V9 l( v- M
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 ~3 u( u# I Z& v
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 l* D1 L+ Z0 V$ V" L, Q }
write('</ilayer>')
3 L' J$ A7 ?# c3 H$ d/ Y9 m
}
- A- E3 Z4 Q1 j( L
document.write('</td></table>')
$ e2 a: o1 V$ V: P) P
}
. n# g/ P' X# ?& H/ E
}
: F7 z% G' A" @' j$ H
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2