标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
' {% A$ e+ J0 \$ B/ b0 ^
var marqueewidth=300
5 i. Q8 D- z/ f& G
//高度
* P& d5 l4 v8 U2 o
var marqueeheight=25
, l- ]2 G" ` \1 S+ [2 n, n. ^
//速度(1-10)
, l! X8 m5 s- ?+ D! Z" G
var marqueespeed=3
6 ]% e0 C% @" x/ z
//背景颜色
: Q( t1 c' I! m+ c! P
var marqueebgcolor="#FFFFFF"
* y- b+ U+ U& x; g
//是否能暂停 (0=no. 1=yes)?
4 q1 x: s6 |, R# o) U( }# \/ i7 \% [
var pauseit=1
/ L0 s" q: Y2 i
" p7 M* a1 G* O! I* d
//修改显示内容
z R9 ^9 A7 j
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
; c. x! j8 L9 f' b2 x% X6 z
8 M0 {5 ~& w$ X. D7 s, Q% V+ r
4 T* X! P& y$ v% ^: H
////下面不需改变////////////
/ f+ O5 _: V1 P. V6 Q" L- M
' d3 t1 H/ h) p k6 K5 x$ U- A, x
var copyspeed=marqueespeed
+ H. A, }2 _1 |; ^* C b
var pausespeed=(pauseit==0)? copyspeed: 0
9 r$ x1 }! S6 ]5 O
var iedom=document.all||document.getElementById
+ e0 t P6 g" M, ]. z, d( N
if (iedom)
! s3 L, ]0 n* w6 T
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ t$ @# m9 Q! v$ n+ p* n/ S
var actualwidth=''
8 ~! h1 `9 J) H" v
var cross_marquee, ns_marquee
7 ]2 {( p0 y3 g& [1 [
2 U' U7 U6 ?1 \5 y
function populate(){
9 K! ~& a; \- @+ }1 H I1 y
if (iedom){
) \) |8 C. Y& \) X9 Z$ l5 u
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
7 ]% Q6 c( [0 r0 |) Z9 Z
cross_marquee.style.left=marqueewidth+8
7 X7 u9 |" H& O {
cross_marquee.innerHTML=marqueecontent
3 ~( J) V" |) o, V
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
5 x& E3 t9 Q1 D" q: y
}
% e) l4 p$ A' A% q, [3 @2 Y0 P
else if (document.layers){
! @) ?3 G7 b7 j7 C3 [% f
ns_marquee=document.ns_marquee.document.ns_marquee2
" M# G# N7 Y6 X
ns_marquee.left=marqueewidth+8
: }! I4 F0 Q1 f+ _, Q! n
ns_marquee.document.write(marqueecontent)
* P: G* V' j1 O
ns_marquee.document.close()
% E0 s. K- h! t# l
actualwidth=ns_marquee.document.width
v Y! @' `& i
}
" J% v3 y g0 w
lefttime=setInterval("scrollmarquee()",20)
9 C4 ?4 f2 r3 m+ m
}
$ p( [7 m0 H8 X# J3 {$ c" k+ }$ K5 u
window.onload=populate
" o: T( t; w; w" G9 |+ k" ~; H+ U
/ d/ B3 I2 R( k& Z$ q% H3 @, U2 m0 K9 ^
function scrollmarquee(){
1 ?5 p Y' |' M4 J
if (iedom){
0 N$ | P+ w* x8 S9 s. Z
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 n9 I; v2 ?* |8 Z8 T
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
5 d* K; P; @3 o+ _- q$ Y9 j1 M
else
7 M0 Q6 a, P" ]: F, j, N
cross_marquee.style.left=marqueewidth+8
7 W3 b; L: A% Z/ {9 o) i2 r1 Z( u
& ]* f' u% M; M$ T/ m
}
) f1 P- _- x% K" E* ]$ y: V7 f" x# w
else if (document.layers){
u' J# q9 P7 f% H" _- E
if (ns_marquee.left>(actualwidth*(-1)+8))
3 Y/ ?8 |! \: f( x5 J1 {
ns_marquee.left-=copyspeed
o; X; v3 y4 p- k2 Q5 I" D9 W
else
}: ~7 e: Z. l
ns_marquee.left=marqueewidth+8
$ p o& E2 y" l3 S2 Z/ ^
}
2 a' x) T' [/ I& e$ k6 A% Y2 D
}
& e, D, k: M2 {
! X% W8 P3 g+ m+ ?# C0 S
if (iedom||document.layers){
6 P1 \) x& U/ T
with (document){
7 Y8 a" X! i+ n- K6 z1 ?
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
) t, Z' O" Z7 ^5 N6 {% S
if (iedom){
7 n+ r) r) n1 w$ \
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 B' M" x. |" m
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- Z# ~" e1 ]6 O: B. I6 l6 S# V0 o G
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
- W4 B" M- e0 k d
write('</div>')
9 w8 g2 c2 |* U9 P6 [
}
9 ~( j' [& `' {" J
else if (document.layers){
9 u0 h) F6 W+ r$ f- m5 Z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
# }1 z2 [' o9 Q2 \# ]4 P
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
! {% E) X7 L& ]6 \5 S
write('</ilayer>')
( y( Y/ t. ?+ y, b" }
}
9 n, i: w" F0 @, H2 s
document.write('</td></table>')
$ s2 ?* h6 ]5 j/ B
}
# _ C# [% }3 B9 x! _) j, W# `
}
7 x( h. s) K2 b
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2