标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
( R: T8 w0 \: U x* |
var marqueewidth=300
9 T0 f4 x$ s. d' I
//高度
9 ^: Y# b: j4 F) Y
var marqueeheight=25
4 g/ {" _8 y5 I. @0 ^0 P1 Q
//速度(1-10)
) [2 v2 L: s2 l/ m' i( L0 C3 D
var marqueespeed=3
3 \4 o2 E6 D/ h/ ?, U
//背景颜色
2 b* P: {) Z/ O8 e6 E0 M- M: R! f
var marqueebgcolor="#FFFFFF"
+ a5 }6 y1 c) b7 D' Q0 ]) P2 b
//是否能暂停 (0=no. 1=yes)?
+ _8 B. z7 ]* z$ ^0 p' \+ @3 E$ I D6 B
var pauseit=1
2 [6 y, o0 m5 m1 _) e. O$ u$ D
" E1 O9 L. O) n( w
//修改显示内容
: U/ k4 k- e" G. w% ^
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ l; O% @1 v F
0 B7 s0 M' `! ~& T* h3 B
" t' b4 x5 d& e' ?
////下面不需改变////////////
7 \. U; C* @' ?) w
/ G- Q0 O) l5 g2 e
var copyspeed=marqueespeed
" j1 T9 X" y8 }+ p* u# g6 P Z4 ~0 i# `
var pausespeed=(pauseit==0)? copyspeed: 0
2 k A0 a( q6 X! J6 w9 J' w8 e
var iedom=document.all||document.getElementById
+ f* _+ s g; {* h7 Z/ T) p
if (iedom)
' A: O" m' O2 w r7 S1 w$ o
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& w/ }0 L" t: {) N5 s
var actualwidth=''
X3 I+ v/ \ |- ^8 z3 ^! ?* O
var cross_marquee, ns_marquee
+ H9 S9 e$ E0 u# I# p
/ k% J1 ^, n3 ]5 I( u- A. f
function populate(){
& a6 E3 @! {5 o9 u0 w+ \$ g* Y. @
if (iedom){
' W8 n" r7 H/ V" o; C/ e
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ [ l6 C$ O' `6 F& Y. ]6 y7 M5 _- d" b6 A
cross_marquee.style.left=marqueewidth+8
7 H* h* f: P3 m: y. h1 \5 `; @
cross_marquee.innerHTML=marqueecontent
( K, N6 ]" V* d) y4 F
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
, S0 j- i$ K) p, V8 T' @6 b; g
}
8 Z/ ]8 \! H3 e
else if (document.layers){
+ p" Q8 \8 l. Q9 Z* h
ns_marquee=document.ns_marquee.document.ns_marquee2
/ K* h4 @' R, n8 _ h
ns_marquee.left=marqueewidth+8
( \2 T3 [6 V9 Y
ns_marquee.document.write(marqueecontent)
/ J1 I L" L6 @* @
ns_marquee.document.close()
% n1 t e/ h$ {4 W( K' a F
actualwidth=ns_marquee.document.width
) j- X2 l! M* n9 O
}
" s0 ^4 X; y4 w0 Q; k: I# N& v2 s
lefttime=setInterval("scrollmarquee()",20)
5 \9 F S9 z: z; x9 ?" M4 E
}
1 Z& }3 D9 e5 H/ Z$ R
window.onload=populate
" M- o. n9 I# M; Q5 [
& R+ t2 ]$ E {& |
function scrollmarquee(){
7 j6 P. e7 b3 ~) [* {2 B7 K4 h) [
if (iedom){
3 o1 b) h; }8 B, w# Y, J, c7 N
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
; N' J) S) [% G3 T! w: i, |
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
7 H0 C; F( D. ?7 Q0 ~. s
else
9 u$ j9 \ m0 e( m/ e4 r, j
cross_marquee.style.left=marqueewidth+8
1 R& p/ T2 h' c$ J# V! r% Q
, C5 n" l; r4 y; J- t {
}
7 J) |' v' D9 V/ U! k
else if (document.layers){
7 z! I0 o( _+ f' m Q. A" }
if (ns_marquee.left>(actualwidth*(-1)+8))
; Q7 T4 G0 O" J& \( ?" \3 C
ns_marquee.left-=copyspeed
) }# r) m% _, t: z7 z
else
! l/ E0 x$ O- t/ S- o
ns_marquee.left=marqueewidth+8
0 Z3 O7 T, U: v& [* k
}
6 _3 J3 W, c# h
}
5 z+ L/ }1 g' }# f4 \
( p Z+ k( V8 W1 z3 A. m
if (iedom||document.layers){
9 p% U! Z3 w5 P1 ^+ x8 w
with (document){
1 V& d1 V4 j9 _) V
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
. m! Q: w6 I' {& q) K/ y P/ w
if (iedom){
* b- {: ^2 |% n; P* ~4 ?3 V
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* k5 @& _7 G& E. u1 r' _& E7 h
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
1 D# J- W) A" C% a5 k
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 b% A. l- ?; p: G
write('</div>')
' c4 @- ~ z h# S/ E
}
: f! u) K. F5 s% @' b
else if (document.layers){
/ z% l5 u, p K+ E
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; I/ M* Y' T$ P% N
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
" ?5 l" {! d8 V+ k
write('</ilayer>')
* V3 D: g- ` d% _
}
- a4 ~- y& I0 O! X7 A' ~: j: B/ G
document.write('</td></table>')
' n9 N0 l9 g, ]$ E! H( l+ g5 `
}
/ ?1 {1 |% |# ]) n+ t# }
}
7 g4 w G$ w6 B: U0 L3 C+ q. a
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2