标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
& ?- D1 [# d$ e1 s: P- Y
var marqueewidth=300
' c: a+ F% i) u. P5 ~8 K8 U
//高度
: b0 r. c" G: H: J( [2 e5 k. {
var marqueeheight=25
4 n' x& Y- L* z: h; K2 b7 t. G/ ~# I
//速度(1-10)
2 @7 v, I% q3 ?6 X& I! }
var marqueespeed=3
# Q( t% d% {* N. h
//背景颜色
Z! b z* [& Y' f9 j) A
var marqueebgcolor="#FFFFFF"
( K; V. t6 o. t
//是否能暂停 (0=no. 1=yes)?
# U% [! \6 _* g- i. Z1 \
var pauseit=1
% O% C U. G$ p. P# Q& [4 o8 Z
0 {; t8 g" d; w3 u% q2 R
//修改显示内容
+ M; D' _+ H! H1 f
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
e5 q: y4 H" F/ I
# H+ v3 v% @+ B5 s2 U
; D) m# ]: Z+ W3 F2 t
////下面不需改变////////////
5 ^7 b( w' N5 m" G9 W. B
8 f w4 p9 O8 |7 d
var copyspeed=marqueespeed
' F; {8 v0 \# G/ \% l% U
var pausespeed=(pauseit==0)? copyspeed: 0
/ F! j- }) E6 W: [ x. W' S* Z6 x
var iedom=document.all||document.getElementById
: I" p& G8 u; z; C0 m( }
if (iedom)
' [/ I( C5 L `. y# R6 i* g
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
1 v e2 b% i3 L9 ]$ x
var actualwidth=''
( s0 d: W2 A% ^' } z
var cross_marquee, ns_marquee
3 M& @0 n0 u- t
, F( V; Y2 D" x$ t% l! l7 q( o% P
function populate(){
' t8 S2 \, W4 k2 i. f
if (iedom){
. f: V+ X, }6 F( g5 w* P
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 `0 i* N8 t% h4 l* F
cross_marquee.style.left=marqueewidth+8
. x0 W# g5 c6 u/ o3 j6 s$ x0 K) N5 L5 o
cross_marquee.innerHTML=marqueecontent
% v. i) ^3 w' K1 Q- t1 g s& r* ]
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' Y; j ?( |! @
}
: g& T: c; L! I/ ?/ V& m2 X; N
else if (document.layers){
6 ~/ p, Z1 p: }8 \& j. t# g
ns_marquee=document.ns_marquee.document.ns_marquee2
6 b% T+ D- r9 i0 o% o- G' |
ns_marquee.left=marqueewidth+8
4 k0 S- `+ E+ v% t7 f; Z+ ~ ^
ns_marquee.document.write(marqueecontent)
: @1 R4 \9 C% b+ R X# ]* K% s2 ~9 y
ns_marquee.document.close()
! S$ \2 J) i1 k# T _7 \4 k
actualwidth=ns_marquee.document.width
4 K7 C3 d/ u0 V- K
}
# T n, b& [) P7 p, H
lefttime=setInterval("scrollmarquee()",20)
- A2 ?) {( U+ N7 U9 g% w& A; F& @
}
0 h. A' I! I+ a" f; e) r
window.onload=populate
/ F# _0 c8 R7 R8 D! O% D
$ y% |; l6 Z( T* G/ Z+ {
function scrollmarquee(){
* }. {- b3 b* m2 h. `- j
if (iedom){
8 }$ v2 @! ^; ^
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 [/ y" P V/ F/ h+ Y- z7 p7 e
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
2 ]8 r; }. v6 h' o
else
0 ?1 a# O: l; U, O
cross_marquee.style.left=marqueewidth+8
3 v2 L) {4 `& I* H \4 a) ^
8 C3 m Y5 \4 A: I9 z N
}
: H# o. H% j C# {8 w
else if (document.layers){
# T0 B1 L0 t6 q# T
if (ns_marquee.left>(actualwidth*(-1)+8))
- `. z, l9 G1 {
ns_marquee.left-=copyspeed
: B9 ?' y; n$ r1 E' r$ ]/ h& c
else
9 N7 b, ~4 c5 q# J0 F
ns_marquee.left=marqueewidth+8
+ u4 ^- t0 u# B
}
) ]' T: @. B# y$ d& a
}
' t4 v. C( w( X$ R/ Q( ]
; R0 @6 P3 S* T0 x8 z9 y
if (iedom||document.layers){
& Q6 O* u" p- N; j( O" [
with (document){
, C4 i! J, ^* L" G& r
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
" }, k( c3 O8 y. o/ \. U
if (iedom){
; Q) ] A8 B( y( v' m$ `) q
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
! @+ J% H& T3 A; ~) d; f3 c" u2 ]
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
4 G5 ~7 ]1 | Y- Y. j
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
- ~. |# r F( s# ^7 H' l2 n. Y
write('</div>')
" N J. {; H* \! [
}
: }/ O) q8 e: P# }. @) B
else if (document.layers){
% q/ T$ o. Q* ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
3 e( B# X6 ?6 D& D0 p1 Z! g
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 [4 L' d0 ~" _8 I
write('</ilayer>')
1 ~" Y* q" m5 b% C2 Q% V2 G
}
) P5 b8 x( h# f+ Z6 r6 O
document.write('</td></table>')
, M3 n3 \. @" Z5 w1 H, v
}
" H6 R9 g q* v8 Y8 }# O" }
}
, D) b# S' f/ c# Z- c4 h; T
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2