标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
2 Q1 P% ]4 ~8 I% f: j, `" _6 u
var marqueewidth=300
- a" J8 k& z8 [1 p' T
//高度
! M1 _3 [- _3 |! @- [; G- n. o
var marqueeheight=25
9 q9 f" Z \" T* v0 ?7 X
//速度(1-10)
2 G8 W9 F5 S8 K8 l$ s
var marqueespeed=3
0 Q, j& h% v& x7 i' |2 F3 g
//背景颜色
1 W' V0 P* }; I8 N. w7 W# J! s2 f
var marqueebgcolor="#FFFFFF"
! { ?! @, i% z/ }$ o* n
//是否能暂停 (0=no. 1=yes)?
4 w0 u# z* i5 u
var pauseit=1
* Q# C7 p3 i, \' x1 w
5 M- n7 F+ w& ]: v& {8 b
//修改显示内容
/ p: A6 L- {, j" {
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
# ]( \2 G" Y& H8 [# C! Q" v, h
+ j# _0 }" W) w! h4 [2 _
- \8 e1 t9 M, `
////下面不需改变////////////
* p8 C7 s/ Q0 r- K- b7 f
5 I. T4 L6 I" g2 x7 f
var copyspeed=marqueespeed
% A/ v3 p5 C& B- i5 c$ d
var pausespeed=(pauseit==0)? copyspeed: 0
; R& @0 c! G7 X# i0 a2 F- U t
var iedom=document.all||document.getElementById
( A) j3 @7 J/ D
if (iedom)
+ N4 y8 l, F9 q5 `$ R4 l2 c
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
6 N2 O0 x5 z$ q6 ^+ f
var actualwidth=''
7 E- \/ a3 H# `( s
var cross_marquee, ns_marquee
0 F5 _+ M2 e6 c6 Q; y4 n- m
- `3 @4 o1 c/ c" A) A7 I' Z- d
function populate(){
- Q! U9 X" x) M1 ^) ], T) w0 }) y
if (iedom){
- K4 C. D6 _, J. D! [% m
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
) R* f8 o3 h& _. p. S. |
cross_marquee.style.left=marqueewidth+8
, {' `0 t/ {1 I/ A& j
cross_marquee.innerHTML=marqueecontent
, s2 C; X- {# }8 z/ b3 o% n; W
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
: t. U6 d/ T, U
}
, l/ N, q, v, c1 ?; V
else if (document.layers){
$ E2 }/ O% N4 O v" I
ns_marquee=document.ns_marquee.document.ns_marquee2
: b! Z# Q% {' @6 V
ns_marquee.left=marqueewidth+8
8 r0 h8 x, U( o
ns_marquee.document.write(marqueecontent)
0 P" r9 _$ S) l% g6 k
ns_marquee.document.close()
) u8 J, S: I$ |6 Y+ R) Q* P0 M$ ^2 F' S
actualwidth=ns_marquee.document.width
! w D \9 V6 T2 y% H& ]. u
}
+ E, }! l/ Y2 v. ~* @
lefttime=setInterval("scrollmarquee()",20)
5 T; f) V: s. Y- U+ T* c' G
}
% x1 o' o$ _# r: S; \
window.onload=populate
6 @3 t$ {# M, b' E! _" u4 J* T+ w
0 i" N7 N' d- L' S) Q4 z
function scrollmarquee(){
7 k8 I9 Q& u1 }) D* M4 |5 b
if (iedom){
3 P& ?% F6 D# \( T! a5 Q7 H8 h+ C8 e1 f
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
8 z- D8 Q# \4 p+ k
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
( Y9 z. V$ t9 i( Y0 I( ]8 z# s
else
0 j7 v* p# G9 W* V/ x
cross_marquee.style.left=marqueewidth+8
9 D' m! f: @5 i& n7 Y9 h
0 k( i6 V. k1 n ~6 M' V- q" D& E* P+ |
}
e% p7 E8 ~+ l
else if (document.layers){
8 X6 v! ` l7 e
if (ns_marquee.left>(actualwidth*(-1)+8))
0 z/ e2 T. T' D. y, h' ]
ns_marquee.left-=copyspeed
1 j' G- J' X8 S: f2 O
else
9 x# \& s% s, h1 I1 M8 k: k/ Z
ns_marquee.left=marqueewidth+8
8 e/ X, q) }6 _; n( B5 _" x
}
( u$ }! V1 r+ K) t- o; a3 j" j
}
' _0 q( C4 C) ^" y4 m+ _# E
# \7 L( q" [* l( |, u: Y1 A6 o8 j
if (iedom||document.layers){
" ~6 O2 \: J$ z7 b" A( Y
with (document){
* Q6 U6 j4 u& m+ p/ e `9 _2 J
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
Y- g( x; O) S* U# F% q" u. p L
if (iedom){
" t$ Z2 f, P6 E. L r8 y$ T
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
i. P; U4 ?4 e( [
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ N$ ~7 p6 K6 v: `! Y. B
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
: t( B' w9 ]& b( z
write('</div>')
, F% P5 {* Y. P! u |- n
}
9 |) H8 E& L+ [0 j. E
else if (document.layers){
1 L5 c* i+ ]+ u$ ?) q5 a! W
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 ?1 f- S! x _
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 o5 N& w% k* V. p: B H
write('</ilayer>')
6 q. b8 \" I7 f1 O8 g4 m
}
! ]6 H0 v- v4 h# Y1 v7 j! |
document.write('</td></table>')
! n2 i" Z; \0 A9 v5 K$ r& e
}
" q" E A0 a" @; I+ E; K5 ^# ]
}
! ]0 @1 ?7 ~) m
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2