标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
1 u* ~ r5 B# e s% _
var marqueewidth=300
+ {& C# I ?; q- R( M( {/ x
//高度
( `0 K/ ^8 T$ Z6 a. \) E
var marqueeheight=25
/ ]# Z+ p9 @4 N; y. T/ }+ u
//速度(1-10)
) \) D6 g$ n- g2 s) X8 _, u
var marqueespeed=3
7 G, r. F0 h- L# e% E$ h
//背景颜色
, `5 v: ~$ k, l C" t g
var marqueebgcolor="#FFFFFF"
; V$ j$ Q# A, h
//是否能暂停 (0=no. 1=yes)?
; k4 ]1 Q- R4 R* k z& H) j: \8 v
var pauseit=1
A8 U$ a6 i2 N0 Y
7 L( i9 x2 U. ]+ I w# U3 @ J4 n6 W
//修改显示内容
- }3 j* D2 i, t& t- [8 S
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
! [3 t- w Y) z5 S; N, F
2 o0 t) I V. U, j4 T! |" J
5 ? X9 Z5 {: W3 B* y* l
////下面不需改变////////////
6 o% J. p! s7 A |6 N5 w# \
8 T. {5 b4 J) T
var copyspeed=marqueespeed
* B& _/ J3 F! Z
var pausespeed=(pauseit==0)? copyspeed: 0
! [. H- @' d# m8 `
var iedom=document.all||document.getElementById
8 T- n4 |. q Q
if (iedom)
) u" {( b8 U6 _! [; Z: M( n3 F
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
+ w! r, k h8 V5 a
var actualwidth=''
9 x- H4 L7 T) s
var cross_marquee, ns_marquee
6 g+ f4 {* K' ]' E' C& t$ I
5 q. @4 M, h* ` N- ?, g
function populate(){
" D$ D' Z+ Y3 w/ Z6 d
if (iedom){
! i3 r0 \; ^3 U6 a
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
8 g' {- M+ O' E: ]* i
cross_marquee.style.left=marqueewidth+8
9 o( u$ E6 b" A' D" t: Z
cross_marquee.innerHTML=marqueecontent
; V8 j# m4 J5 f
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. i* J8 \3 o0 x. ?4 A; Z
}
+ y; m, G, e3 e4 \9 K
else if (document.layers){
6 J4 L6 I: H U, Y, A5 o. L6 t
ns_marquee=document.ns_marquee.document.ns_marquee2
8 S( y) J2 |( e9 e0 z# y2 p
ns_marquee.left=marqueewidth+8
3 f( P% N+ [4 l% h
ns_marquee.document.write(marqueecontent)
; d. G. Y8 t6 u* ^
ns_marquee.document.close()
( I2 R+ g3 t% A" D
actualwidth=ns_marquee.document.width
8 {- p+ ~; d, |- |" [
}
& s/ a7 x+ T# \. ]
lefttime=setInterval("scrollmarquee()",20)
( {$ r+ g2 j. o: F0 {8 p1 N
}
' h1 ~9 M1 ?" o1 w; Q
window.onload=populate
- t; v6 q. J7 s9 v( N
3 L) y6 t* u# v5 d2 H) E3 g
function scrollmarquee(){
% ^9 z( T' S: {7 ]
if (iedom){
4 W; m7 r( ^8 [- }
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
$ U* Z7 m% q1 [" W3 m D1 e
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
1 B. z7 m* w' w ]% Z
else
2 ]; M7 I, E2 k6 c+ x6 B1 H
cross_marquee.style.left=marqueewidth+8
' R3 h. P7 g& m* R9 r8 m
8 }( U. M4 d& S4 _
}
S* O5 {4 I* F" [- p$ l2 R
else if (document.layers){
& _; e2 Q% s) S) q
if (ns_marquee.left>(actualwidth*(-1)+8))
`2 z& v; |& x8 l% f
ns_marquee.left-=copyspeed
5 `- T" p4 g {2 \
else
& O: L7 N1 k! h. R' C9 T L
ns_marquee.left=marqueewidth+8
9 ^/ {( I% [8 A
}
- K5 ~& f7 I4 K: ^+ B) d4 E' s& w
}
% v; S' }; Y" R5 a |) i8 j/ L
$ [) @. V# p& O5 v6 W$ V) m
if (iedom||document.layers){
/ F% m% K$ T" _# z/ v3 f4 W
with (document){
( W. a0 e; T& ^
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
( w2 V% A4 k ]
if (iedom){
/ ^7 K. l' k( T# u7 |" E) d
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 U# h) c1 e, `, P8 H5 }) n. r# A( O# t
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
, E( E7 u) Q1 u. I* G- Y4 @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
; }; ^! w4 \ D N" l
write('</div>')
, N8 \' D: ^5 e' R
}
+ F1 r7 b/ _& B* `
else if (document.layers){
" n m1 }& Q% U' S
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
1 _( c# ?& q2 ~5 x' B/ @( q5 n
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
+ R! h$ v5 \2 k. @+ ]( C3 n
write('</ilayer>')
; H0 x; O% K. W5 B$ F# U* J
}
$ f9 r0 Z0 t/ S4 ?( P2 J$ b: o* l
document.write('</td></table>')
. R) r8 G7 P# B- w. f9 T
}
. s8 b6 v! ?' |4 M& }8 M5 B( B5 e
}
9 f9 w) \/ m2 K) J& `1 ~5 ^% i
</script>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2