标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
0 g" `+ ~, J5 R: `9 K9 W1 r9 y. {- E
var marqueewidth=300
2 [1 _9 V, s/ D G9 O& z1 L
//高度
, V: j. H0 _6 {% z% o! M( p' q
var marqueeheight=25
- v" ~5 w- ?* {/ J6 m! A
//速度(1-10)
* W4 |/ j6 @6 @
var marqueespeed=3
6 [5 C+ {$ ?# i
//背景颜色
& v3 x& Z! F! L# o
var marqueebgcolor="#FFFFFF"
0 T7 P A0 S: T0 U/ P" e
//是否能暂停 (0=no. 1=yes)?
8 e1 z1 e2 g4 r% H. J# B: }3 X
var pauseit=1
0 A* T8 l: S$ v+ X$ V0 Q, B
/ x) {+ Z, V/ T8 [. f! q- m0 w6 W$ a& r
//修改显示内容
8 P% C! @/ ]4 U. k
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
0 h1 P" b m7 `5 d& L, e
+ l' f* y2 q9 \) M9 R( O) B2 Y
" [ Q, h8 G& ^, T! r
////下面不需改变////////////
4 \+ h% p: ^; e$ h+ C% u8 u' B
% r/ }- V/ `' F3 ^( X% K
var copyspeed=marqueespeed
: X8 ]" o/ J. @7 v- L8 |; y+ x
var pausespeed=(pauseit==0)? copyspeed: 0
* S" F# A# h( @
var iedom=document.all||document.getElementById
* o& T8 k H& z$ E
if (iedom)
" q, H, I% K2 X4 e6 H& k) \+ z
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ Z7 l6 a# K% C- a/ C- H% [
var actualwidth=''
* p; q4 ?2 I9 ~" u. j; X8 h
var cross_marquee, ns_marquee
! g- n# X( Z; z6 |$ }# E
* ~+ z& x' f, p. \5 Z# Q5 c b
function populate(){
+ F! K. ~+ A0 t' e9 h% \% D" E6 t
if (iedom){
+ V! r" `8 ~- l5 p' F
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
; _4 e2 p; {) _( h
cross_marquee.style.left=marqueewidth+8
0 Z. Y2 z5 L+ e F6 @
cross_marquee.innerHTML=marqueecontent
+ @0 Y- u' h, [: K1 k; a
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. ], f1 e; f" m# F" l7 `! z- i
}
4 O0 l! [/ G" O% [
else if (document.layers){
$ j5 e O. P9 x" w# t( B
ns_marquee=document.ns_marquee.document.ns_marquee2
9 \6 o1 Q' \5 X; B A
ns_marquee.left=marqueewidth+8
% n9 j* f8 o2 I0 p7 N
ns_marquee.document.write(marqueecontent)
% {7 ^& \, g* w E
ns_marquee.document.close()
* f+ z$ o* }6 _3 u. b- w/ F+ v7 N
actualwidth=ns_marquee.document.width
$ X v( d6 A) U
}
% V& F H+ d) C: J6 x
lefttime=setInterval("scrollmarquee()",20)
4 B9 I) m# b5 k
}
0 h8 K0 ]6 e2 x
window.onload=populate
& Q1 Y9 ~7 q! R8 ~- A6 I
' N: T: _# m2 y& I, d: |/ N- {9 V
function scrollmarquee(){
5 ~8 u' Q$ J2 C
if (iedom){
) K( x7 t# ^$ Q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& n3 A! ^6 C1 L5 w+ p
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
* p* h4 U6 _: N: ` C9 V2 e
else
4 @% g4 F; z) X3 Z
cross_marquee.style.left=marqueewidth+8
) ?0 @1 g$ |$ Z( A7 \
8 U( a8 p' l2 w9 ~: z8 H2 G. }
}
v( _3 {# E* b7 ?: D5 t6 {# X# m
else if (document.layers){
/ T7 _5 Z3 L# r4 I
if (ns_marquee.left>(actualwidth*(-1)+8))
" i% h+ b$ s7 j8 I. F, y
ns_marquee.left-=copyspeed
* \- |/ Q/ G% k: }
else
6 R6 j- s: X3 C2 o. [) W
ns_marquee.left=marqueewidth+8
% }! k/ B- E# r& D
}
, R2 Y# F; W! e
}
! Y# V3 U+ t T. q; g3 g
5 [1 l( e; ~# V8 [
if (iedom||document.layers){
0 Z/ E# H9 q' W) c0 c \. ~) f' p4 m
with (document){
. V. ~1 ?' L% V6 w5 s
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ K h C' e: O$ r$ y# J3 T
if (iedom){
" d! r6 u q; y' M3 G* i
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. ?! [9 X, `! o5 q3 h+ K9 d- N
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
" f+ n6 w# l8 y! ~
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
1 e5 g4 C+ m8 s. c/ J
write('</div>')
+ x' @. ^8 y0 ^3 Q% z- d
}
- [6 H) V: v& P7 d
else if (document.layers){
8 I! {8 I, Y4 Y4 O4 ` L6 E
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
/ K4 U+ p9 n# B) x6 Z+ m3 U A
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
* b& H6 m0 D7 t8 M
write('</ilayer>')
8 y9 ~! w7 }+ B% I' w
}
2 I9 N5 }- o4 K4 P1 X+ G
document.write('</td></table>')
$ Q8 u3 w* W: C- n$ _3 A2 T
}
5 t3 l% b9 D9 i+ I7 j
}
- _( b6 S W! r+ ?
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2