标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
, T$ ] r- N* K$ Q7 p& q
var marqueewidth=300
$ V& B F: S+ Q# X& g4 d4 B& T1 p0 ^
//高度
7 w0 _( @3 U, D# R
var marqueeheight=25
3 t8 P1 N$ g$ n0 V" z' N
//速度(1-10)
' s% {* e W0 d' P
var marqueespeed=3
0 \& u. Z, @2 y& L/ m8 x% W3 \2 j
//背景颜色
! g3 o7 i+ q5 p9 \6 Y
var marqueebgcolor="#FFFFFF"
! @7 f" y/ S* t' T- k) F* A
//是否能暂停 (0=no. 1=yes)?
, \8 \( W' ]& C2 P* L7 p$ R- k
var pauseit=1
) v4 k! N% j/ U E" z9 D; I
# ^' a3 Z7 K+ X) E0 C
//修改显示内容
( N# ]2 }5 z0 ?: k. s1 I
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
6 f {' n) [1 L5 K
9 X; A b R- i7 P/ ^& w: s
6 ^0 A( H% U9 R$ f6 L" L
////下面不需改变////////////
: J& t$ l' Q# V2 O( k# |1 h& W
/ r) B) w1 t1 |9 q) p& Q- M' U0 m
var copyspeed=marqueespeed
; x/ _8 z3 X5 u
var pausespeed=(pauseit==0)? copyspeed: 0
# u4 G" h7 ]' {: L7 H5 A- B
var iedom=document.all||document.getElementById
. b5 S, g1 K4 M4 _' ]' t! `; Z
if (iedom)
+ \' l; K3 T& D) |* ]
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ A8 S4 a* X2 }
var actualwidth=''
+ }9 F& [; m1 M! w8 C; v! c
var cross_marquee, ns_marquee
6 @/ A# a2 c7 X3 w
; a/ x# E6 \+ J( ~* f L
function populate(){
z( o0 ]9 H" E
if (iedom){
1 ?4 ^& \3 T, i/ o$ ~
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
: F- x2 A' H2 ?# I! J
cross_marquee.style.left=marqueewidth+8
R/ ^8 n3 r2 q+ g3 s" K8 x7 m
cross_marquee.innerHTML=marqueecontent
. T. H0 ^( T5 q1 Z I" w
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 Q$ S0 f1 E/ B
}
; Q1 A- [& }0 l/ J( S! N
else if (document.layers){
+ C/ @& B6 R2 Y, M/ E, U; u2 Q
ns_marquee=document.ns_marquee.document.ns_marquee2
1 Z) b& \0 N0 ^! u: e( Z3 G% K6 h
ns_marquee.left=marqueewidth+8
; J% r, S5 M! R0 r& d7 p. r+ D
ns_marquee.document.write(marqueecontent)
1 F+ O4 T# r' J i7 `0 `: J
ns_marquee.document.close()
3 b, V: f7 O Q
actualwidth=ns_marquee.document.width
# W {. x6 j, h& h
}
6 e0 B# X0 W6 e5 z
lefttime=setInterval("scrollmarquee()",20)
; j/ l" v7 J9 s9 m, e8 c
}
: L. J+ M6 h) ?
window.onload=populate
& N& y3 |' I; s" U, [! o, G$ R
+ \9 K! n/ r7 N1 X( M
function scrollmarquee(){
2 T3 S6 M; h$ E4 N
if (iedom){
$ E" [2 x" p5 O; G( h/ h
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& g3 r% G) [4 Q- l
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
$ |2 W2 y6 V/ H, j, S) L% Q
else
, `& q9 c9 V0 R
cross_marquee.style.left=marqueewidth+8
! @! a# o. _: {1 r
$ q$ y6 q" z8 q6 [
}
0 j" `% A# G" u, y! W
else if (document.layers){
. X0 y% c2 r* U$ Z( F# d, M5 @
if (ns_marquee.left>(actualwidth*(-1)+8))
1 R/ D: _) ^ K; m' |
ns_marquee.left-=copyspeed
/ F% \" n- @; r7 O1 w( F6 l! a
else
5 U& h$ | T) e# U5 r
ns_marquee.left=marqueewidth+8
$ P. o: N' e5 @ }/ q0 e" q/ G
}
. G1 {9 o" x; U* ]
}
$ W0 A' r- u5 @5 Y9 X+ N; ~0 o3 Y
% C8 G1 ^ |+ U& o. v R! J" G0 Z0 H
if (iedom||document.layers){
$ y. \7 X2 ~. }0 x' l j% H5 }
with (document){
' I2 O; G/ q5 K$ F" `+ q
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ V6 \$ T8 @& p( u' p8 Y6 O
if (iedom){
7 J O8 V/ X( _! K4 C! g
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( a t% Z O7 @. W" W. b5 h3 }
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
0 p0 M% b' L4 V. {7 Q! q+ D
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 u$ l7 w3 ]. D( c( x
write('</div>')
; T5 k+ L3 T+ E6 t0 K1 Z; P
}
% D2 c- L; o- _
else if (document.layers){
' d1 a# t( L1 a+ A
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 ?3 @8 S) m1 ~$ I' k
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
+ W$ n0 G3 R. Y1 V! d0 k7 U% Y
write('</ilayer>')
. L; w0 o1 b7 M& E
}
2 L- t' K3 x) i E6 T
document.write('</td></table>')
1 d% F& `4 T9 n$ H9 n
}
- n ?. M0 ~7 [* H+ T1 s
}
7 O q; d( O' u4 j1 }5 n2 A w
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2