标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% p! _2 E0 _! y+ l
var marqueewidth=300
/ d% r* M+ u7 Z2 d; @4 D! O( s9 h% |
//高度
' C M! B/ l1 [. j4 y- k
var marqueeheight=25
5 M& d$ ^6 q& i( W" G4 ]
//速度(1-10)
4 `1 `1 J0 T, d* U! i
var marqueespeed=3
8 n$ p& U- \+ q T2 ~
//背景颜色
9 T* H4 ^- B3 {0 P
var marqueebgcolor="#FFFFFF"
: ^8 X" c* e, J) a- [
//是否能暂停 (0=no. 1=yes)?
W8 J s! ?- D# U. t, ~% p
var pauseit=1
' L! T% I3 j* C, I2 V+ I4 L
$ ?4 l* f: Y1 {$ W0 b. k/ A0 O! y
//修改显示内容
% M- O5 D8 B! L; C; i
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
8 H( W5 \- ~/ Q" V
. F9 d) }% b' i
- C, E& }. U8 w, v+ D+ c* T+ [/ n
////下面不需改变////////////
1 l9 ~8 o8 I, e- q) \7 q% Y4 J& a2 Y
: N0 ^, e3 {6 O8 o: R( i6 m
var copyspeed=marqueespeed
# n; L$ N; b+ }8 p4 @4 u" d
var pausespeed=(pauseit==0)? copyspeed: 0
" O. Q4 |1 p9 p6 P& ^
var iedom=document.all||document.getElementById
3 g* v0 a0 x0 E; ?, u
if (iedom)
6 `& n$ w5 a0 [7 j& G4 o$ [
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
9 p' E6 F( D2 ~+ Q* d7 h0 a# D& W8 \
var actualwidth=''
/ m* p3 _" Y4 O+ Q$ A' R& h
var cross_marquee, ns_marquee
' R( |# \; ]$ Z4 a4 j+ a
# k9 K( t3 ]3 c
function populate(){
+ Y7 l: g2 `' X/ c6 }2 Z3 b' M7 t
if (iedom){
+ M/ T7 l: G$ S" y* G
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& d: {2 X0 `4 c
cross_marquee.style.left=marqueewidth+8
3 d5 i' w' q( U9 z: ?' k# O
cross_marquee.innerHTML=marqueecontent
/ Q8 h/ m$ _! l, D" x
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
$ i1 U9 j) k( J, L9 \( J% U$ [
}
! R% n" s/ x8 u0 L' D# P+ m5 [( b
else if (document.layers){
8 z5 V) i0 Q/ p+ B0 [3 L6 J: \" @
ns_marquee=document.ns_marquee.document.ns_marquee2
+ V8 z2 D; J1 `2 Y! V! I
ns_marquee.left=marqueewidth+8
4 T9 J5 [. s# X* l2 h h0 O
ns_marquee.document.write(marqueecontent)
8 j. a. [1 b# f
ns_marquee.document.close()
1 j: B2 t t5 F( u1 X
actualwidth=ns_marquee.document.width
' M+ O" ]' m4 g5 I- g t4 G/ Z
}
( r- a* t9 C3 E! s, A. h
lefttime=setInterval("scrollmarquee()",20)
- E/ \4 S: s0 L4 X- a) T( V
}
2 @; `5 d# ?% i$ J# Q
window.onload=populate
- u @: ~9 E9 b3 o' V
% v) D' [6 j7 h/ f
function scrollmarquee(){
: N1 ?7 _ ]2 F" s3 L# Z! H
if (iedom){
: g$ ]: l: ]! n9 ~- n' V* Q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
, t; s- Y8 y. G, ?
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
# s# {6 n! p1 Y6 i( ? o4 n
else
; n: i/ ?% s2 I
cross_marquee.style.left=marqueewidth+8
$ U, D' C3 i4 z, C! n J" {2 l# m
$ ~+ g8 h2 b$ k3 p0 A9 L
}
7 ]# ]$ z% Z9 i/ D
else if (document.layers){
; {: z: [) j" h5 i2 q8 N
if (ns_marquee.left>(actualwidth*(-1)+8))
5 ~& p3 K( y& \
ns_marquee.left-=copyspeed
# C+ L; b* N$ X5 L. ?: ^3 [. ~ |
else
7 w2 I# y: a: G3 @" o! J+ Y8 C
ns_marquee.left=marqueewidth+8
5 b6 v; H t9 J+ ^0 \9 ?0 R5 j# F
}
. H; ]/ Y. I1 i
}
$ Y; e% @' D& [7 @# {
: N1 b9 {% h( I: p1 K" ?3 S7 @, \7 X
if (iedom||document.layers){
* t+ w: u$ o; Y
with (document){
( p2 ~+ ^; g8 G1 x" _5 Y4 Q
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- u( V( t2 H' b" w" U
if (iedom){
" H, w1 T ?" k1 ? O4 I8 U3 m
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 U% y3 U4 F4 s( A
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
g w7 S N' |4 _) b/ J
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
9 ]1 S* q& ^+ b$ ~$ Y+ E
write('</div>')
' t* g" F6 X9 ?/ x
}
$ y# c, W7 n* v3 F8 t
else if (document.layers){
4 X8 r; _4 D( |& B: ~ t6 W% Y* U
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
1 V% ?2 h) p8 Z3 ~* x
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. _& ~& S( `) m* Z. e$ y# v
write('</ilayer>')
" w B# f5 K8 b4 y# w- S& l# o
}
7 v+ Q3 A1 f1 g& C) F
document.write('</td></table>')
& E3 x0 O6 i5 J( ^/ o5 L3 y- p
}
2 F$ ]3 C* a0 s0 z! v T3 N. S0 v
}
' E% _( z6 n8 b: }1 c4 H
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2