标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
$ g8 v" ~3 r! n! D1 C
var marqueewidth=300
1 ]# x9 n: Y& E3 d* k: L- L
//高度
0 C$ u9 e4 R" p$ C0 v1 y- ~
var marqueeheight=25
9 |# I6 X; G- d7 @
//速度(1-10)
9 H9 A) u* o* h9 i& m
var marqueespeed=3
8 Z: G* w' J2 \4 j) S7 ^
//背景颜色
0 s, L4 k0 `( O! p K
var marqueebgcolor="#FFFFFF"
3 }+ U, e: U3 A- B3 G) P
//是否能暂停 (0=no. 1=yes)?
5 J6 Q* R( o6 c& g: P+ X. ?
var pauseit=1
u1 t0 l+ J( [, _, n! X
" U6 V8 e6 e i; C
//修改显示内容
6 U" O( r2 n$ G: H
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 B' f% t$ l( F
! [1 Y6 ^. s. s# | g) }
S4 J( a C$ h1 L3 P& T9 i" f
////下面不需改变////////////
C6 n0 Y3 y! F8 A3 i
, o9 N1 b# i: E2 l [
var copyspeed=marqueespeed
/ C9 ?% }6 g! `( a
var pausespeed=(pauseit==0)? copyspeed: 0
' k- O0 x# b7 y1 ^5 m9 m5 p' `
var iedom=document.all||document.getElementById
& h; B/ B5 N; y8 Y! w/ N! L8 Y {
if (iedom)
, f6 _/ K3 T1 [ i
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
7 [2 i2 _+ C( J1 @
var actualwidth=''
) F/ O- a- ?( N2 }) P/ C' E Z
var cross_marquee, ns_marquee
# l+ F* g- N' d
1 E5 b A( y, u3 d4 Z
function populate(){
% }( i# ]; u/ o7 K- H- Z. s) v
if (iedom){
' a. Q& d# X% W- M/ ^6 U4 l: |
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
: V; \* f$ ^* o3 }! _2 x
cross_marquee.style.left=marqueewidth+8
. u: X$ C4 o& F+ C
cross_marquee.innerHTML=marqueecontent
( n. e* z7 M( ~. J; H' J% q% r9 g4 `$ c
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
1 t, y; ~9 h' `, v: p" S8 ^
}
3 [3 z( B. y* z2 R0 B
else if (document.layers){
4 w9 U3 D! C2 l4 \1 E8 j0 G
ns_marquee=document.ns_marquee.document.ns_marquee2
- Y( _; N6 H; B5 T
ns_marquee.left=marqueewidth+8
3 m; i& V0 ~+ F; D6 o- |
ns_marquee.document.write(marqueecontent)
- e/ [) X: S7 T* |, s
ns_marquee.document.close()
$ _7 D ^2 O0 ` C
actualwidth=ns_marquee.document.width
, U+ d# D4 I8 w! k7 b
}
9 A/ w4 j0 V" z; k* i7 U, ~! H
lefttime=setInterval("scrollmarquee()",20)
6 g: E) L2 k4 l7 `# R
}
. `: z1 ]2 ^) L/ j" t0 S: X% w
window.onload=populate
" L" y/ ]1 ]1 k+ M6 V
~7 X! O7 M6 J1 \0 ]" ~
function scrollmarquee(){
+ w6 h9 I) @- f* c
if (iedom){
& I- j; z f M) J8 h, q6 Z
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
q* E3 b% j8 d0 J- X" r
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
( u+ y4 j' G% N& I2 ]
else
9 A1 S: ]( _6 ^- G8 ~4 p' \
cross_marquee.style.left=marqueewidth+8
0 ^4 M( v. L5 w8 V0 T/ r! w
- a# `: q; H* b$ I% G' r& b
}
! z4 N) c4 _. j9 v4 v/ L, U# c
else if (document.layers){
6 i; z7 x8 C( X2 K
if (ns_marquee.left>(actualwidth*(-1)+8))
' U2 Q# a5 L6 `$ z" W
ns_marquee.left-=copyspeed
; Y1 t K" a3 N: U
else
# Z! @! v6 J4 Q$ h: [: g8 l* P( b
ns_marquee.left=marqueewidth+8
; p) c2 W5 j2 P
}
- Y& _ R$ g. \& k
}
# g. V- p# P2 R5 N8 B
" s/ S0 c( b- J+ S# n! S8 A; ^' k6 G
if (iedom||document.layers){
% q8 x. y) d% T7 m9 f' M; }9 ~: C
with (document){
5 ]: c( s K/ D$ f D& R
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' b3 f. _* {5 a; g I0 f+ `6 @$ S, c
if (iedom){
8 ~8 n Z1 H6 U
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; X8 z. P. w6 r2 t9 o% p# I
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% w5 a* U) n# H2 T1 L
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' e; Q& O. {' v2 ~. d+ o# U/ S
write('</div>')
: D( n3 w7 n+ C% B) a) l+ t
}
. g. @- G" c) ?0 v; v" V3 F
else if (document.layers){
1 H4 X4 M4 G$ d
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 z/ X0 Q4 j9 P+ n! @ m) Z
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
/ z7 J# G6 {2 E' @
write('</ilayer>')
L9 @' i6 J' f' f0 F$ `' e& g
}
_0 Q5 p% Z* T1 w2 n
document.write('</td></table>')
* X& ` Y/ O1 M h, M1 V1 N- f
}
& |! \( i2 g1 U* S7 n
}
+ H) g4 d+ E1 ^2 [
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2