标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
4 \$ c: b# ?, _- r
var marqueewidth=300
: n! ]' J: r' m5 w8 v! \
//高度
6 ?3 B- _9 H& t; f2 E+ {( c2 z; H
var marqueeheight=25
* u/ g2 o( l+ u: L
//速度(1-10)
- V& Z+ Q0 d/ g O4 ]) u
var marqueespeed=3
9 [9 i" Z& @( C' M
//背景颜色
* j9 b$ Q6 \4 Z/ ]
var marqueebgcolor="#FFFFFF"
. O; x [* {& c# q
//是否能暂停 (0=no. 1=yes)?
) n6 Q! ]. g. y; L8 ~% C
var pauseit=1
- j3 K- H; ~/ \8 |( Y& |
! @8 W$ J( D1 Z- u2 Z8 }5 x
//修改显示内容
S5 f+ s/ P3 P3 r N# v2 V1 q
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ w1 d" ~1 C1 N) Y5 Z* X9 F# P
" O2 A* D2 \4 G' j# L
1 |" [. v3 d6 J7 H2 w: r% _ s7 D
////下面不需改变////////////
# T4 f0 B+ k0 s& Q5 \
3 V" G# b3 P* Z; n
var copyspeed=marqueespeed
1 j* _" O: c- S8 v+ t4 o- \
var pausespeed=(pauseit==0)? copyspeed: 0
3 u0 I! Q4 U. Y8 \/ c4 r _0 K! p
var iedom=document.all||document.getElementById
; v( B6 D7 a* t; A6 ?, [8 @
if (iedom)
! Q5 _7 ?! _% ^1 r
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
9 I. G& C& p- r) A
var actualwidth=''
' t ^$ F# U+ x6 N( y
var cross_marquee, ns_marquee
/ V/ h3 {% d. T5 M1 m- X" Q% U! w
8 u2 M& {- p, U+ |0 x; @
function populate(){
% ]4 ^9 ~! ~$ d' F4 ~, j
if (iedom){
5 A9 l+ Q# r5 q1 R2 `
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
a6 D: ?# t b+ p
cross_marquee.style.left=marqueewidth+8
6 U, w1 q8 F( t
cross_marquee.innerHTML=marqueecontent
' u, R' A9 C/ n) B( U1 Z
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
K s( c6 e: v) n& E" Y' f( Q
}
* P k; R2 l( L: h( l
else if (document.layers){
% R3 _* Z% I& Q0 L! G# D1 g
ns_marquee=document.ns_marquee.document.ns_marquee2
- v9 P2 }; B- X; T
ns_marquee.left=marqueewidth+8
% E" W% v7 o! G! o. F& c
ns_marquee.document.write(marqueecontent)
q4 Q s' X; b/ Z( q& D6 _
ns_marquee.document.close()
2 q- w8 m9 b1 E2 L
actualwidth=ns_marquee.document.width
% ?$ x& c. [1 h& p6 l9 ?2 S1 t
}
/ E+ t( O. X" {. p- U7 _$ ~
lefttime=setInterval("scrollmarquee()",20)
- @1 I8 b" E. W- S
}
, n' O- x" o) |/ a% a! u$ d3 e" s
window.onload=populate
" u, Q- A, Y7 C# @, O
+ P' A' F2 q4 X& y
function scrollmarquee(){
5 B% Y# t* R5 B! N
if (iedom){
( y1 L- M' O0 v$ Z, C
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
' H! F& W7 Q+ S$ v2 [
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
& e( S. n; N/ F5 V3 V5 E0 p
else
! x3 v7 `: b* j1 ~6 ^ L
cross_marquee.style.left=marqueewidth+8
! n/ ?( v+ U( m. J/ @- F2 B
* W" o1 Q" Q7 l, I+ v+ R! v0 }
}
$ o, k6 g8 ]# E8 W0 \
else if (document.layers){
! }/ r; N1 b) X1 a9 Y- n
if (ns_marquee.left>(actualwidth*(-1)+8))
- J# |4 ~* k+ ~: s3 _0 q, X, m
ns_marquee.left-=copyspeed
& N6 ~2 t% H) c0 O" ?6 v
else
# u' f" y6 X3 ]7 o
ns_marquee.left=marqueewidth+8
. j8 {% \+ x/ s7 p' X0 X
}
/ k4 F; y4 \: n6 ^1 s) o! B0 v3 j
}
6 C# X+ x' }0 {; o" \
& Y% L! z4 `( x5 s: e, n* a# _
if (iedom||document.layers){
# F8 e0 u& }5 d
with (document){
! C; `- e$ o; H" `
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- d$ z% ^; a2 i$ g. x5 B
if (iedom){
, h( ?4 J* d1 U( S3 A q+ b$ B( T% E
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( F6 h( g' _- `$ \ F, w) p: e
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
2 _1 k, G0 O/ y* [1 ~3 a
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 S. T4 C1 Z: X8 E1 s! }
write('</div>')
4 b) U% y) \; s2 P8 }
}
$ X- [, L% Q0 A( n
else if (document.layers){
0 @- u6 u8 R% l3 E
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
1 p1 R" W9 L/ u' S4 c& P
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 o6 {( x3 Z8 x9 v4 ~/ A! O5 M
write('</ilayer>')
/ o/ Q! B. J" L4 W
}
* Y9 o6 z( j. w# p. G; ]' \" J
document.write('</td></table>')
5 t+ `' o- |% r' u) U r3 o* ^9 n8 {
}
* s! M2 Q" ^8 n5 Y
}
0 J3 d' @* L2 P! { X5 \% a
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2