标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
/ }# w+ s/ o9 a9 Z6 k
var marqueewidth=300
& O; I+ t& k; S- b1 w
//高度
& n9 o( x& L, s; X6 E5 b3 e
var marqueeheight=25
) j- H! }5 n1 O5 g- h
//速度(1-10)
; r5 L3 s+ e$ w+ @. ?
var marqueespeed=3
/ ~7 T" N6 G% l" w1 W) P, v* o: v1 p
//背景颜色
* I+ U4 B" E; p! w
var marqueebgcolor="#FFFFFF"
% n6 }. m% N9 b2 N
//是否能暂停 (0=no. 1=yes)?
; B5 ~! n9 S! ~. N5 ]
var pauseit=1
: a( K% P. g2 F! k) j# b( k4 K. L
9 d1 S! D( g' o
//修改显示内容
1 X2 \& s$ N+ Q) {/ A
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
; d- r1 ~' h$ }" B9 M( G5 g+ V
7 q) s! y' N: f. Y1 ^6 u( _& c' l6 }' `
/ J8 t$ D4 G, K' L0 g2 {, _
////下面不需改变////////////
0 G2 \5 H( x! Z! Z( N$ a
- |4 E; `; V4 H- v' O d7 ]
var copyspeed=marqueespeed
) P# ]/ m. V! m h8 A# i
var pausespeed=(pauseit==0)? copyspeed: 0
5 J. j w$ P0 s! A
var iedom=document.all||document.getElementById
9 N7 ]# ~8 l, r E" A- m* @3 y
if (iedom)
e' u3 c( T, }% _. T7 A+ w7 X* d
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) B5 A! N5 [) Q# J- F* R! W
var actualwidth=''
* ?" z; w. F) ^5 i9 b* S
var cross_marquee, ns_marquee
) P ~2 d8 n' Z' c
8 c" n5 v, X# B7 F2 u N
function populate(){
: K/ w8 I- o, T1 c- C
if (iedom){
; e" ~& Z: ], O3 G
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 Y8 ]# {" }' T! [
cross_marquee.style.left=marqueewidth+8
T Z* ^ l6 R+ o1 k
cross_marquee.innerHTML=marqueecontent
) W+ l5 u; m# @4 _6 w( u8 U
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
8 l$ ^$ r0 l. d7 }$ J
}
- m% T( Y* l2 d$ g
else if (document.layers){
2 y; F1 N$ Q" o+ ~" ]
ns_marquee=document.ns_marquee.document.ns_marquee2
* a& r) [' a0 F+ E/ d6 Z
ns_marquee.left=marqueewidth+8
' C+ l: {. p) Y8 l; F
ns_marquee.document.write(marqueecontent)
+ x( d* G/ d' j2 w) F0 E
ns_marquee.document.close()
9 H: P+ \2 t* s) g7 K
actualwidth=ns_marquee.document.width
W* C5 i, c2 v7 D6 a1 C. W% a" d" f
}
$ L" D2 u% ?6 Y0 F( s
lefttime=setInterval("scrollmarquee()",20)
. V* w3 Y3 f5 i* R, L M0 `4 I
}
- P9 ~; v$ a. T) L- Y- R8 |
window.onload=populate
. G2 B+ q1 b& y3 z9 t, G
4 Y1 B7 T# R) Y {
function scrollmarquee(){
& m" V" I- ]! l9 C, g
if (iedom){
' q8 Q8 L* I. [0 L
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 \- B- w9 C. n$ U4 l* }; W+ ]/ `
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
- c' u; x3 n1 h
else
& z, _" p! c( F5 k& H
cross_marquee.style.left=marqueewidth+8
8 _5 J- z5 T7 B1 ]( c, T
6 o+ ^: B/ E: u& l: x5 \
}
6 Y# n/ [+ ?+ ]
else if (document.layers){
5 j; `0 i! F* c V2 }8 v
if (ns_marquee.left>(actualwidth*(-1)+8))
" Q* B; b7 O; k; Q4 d7 x
ns_marquee.left-=copyspeed
* {# \5 H7 j8 [* R
else
% Z4 R8 g# u8 V9 r
ns_marquee.left=marqueewidth+8
6 T' m; {2 e0 _# y% h" `9 [0 P
}
# w! k: |- m3 H, p; \* U8 n
}
( |! a1 P$ P( V' s$ ]5 ]. j
2 ~% W1 R! Q& O; l
if (iedom||document.layers){
- ?4 @8 I# M8 }2 q
with (document){
% {! y; J' b+ H( h. V' F1 }8 _
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
! x) N. w4 R' Y6 z0 X0 Y
if (iedom){
; X# u5 Q3 _% h& t
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
5 `6 T, r% i% q' z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
/ H0 n: P; A& a% K6 B) v+ a. C5 A) M
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
. C- _ q# n, i) s* u) a
write('</div>')
/ X3 D) X- I/ `* c
}
$ \% _! x" }/ p" K3 B0 e
else if (document.layers){
8 a9 a! j0 f! j* _# K! `+ m# b
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
* |8 {, | N& f+ `/ }
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 Z" B( u+ C+ w9 j) c6 V- L
write('</ilayer>')
' d9 f4 V' j' e, l% S
}
7 X! Z: A0 Y' p& E# F
document.write('</td></table>')
# o9 Z9 S# _, `
}
w. p: d; z c
}
- J: P4 I: B, t/ W- d
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2