标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
. l; q/ w! x6 c G. R
var marqueewidth=300
* \ [# A/ y& U4 ~# \& `3 p' h" f; j
//高度
! G& L2 R7 o8 T. R3 I o4 ]& @
var marqueeheight=25
1 j) c7 |7 l2 W2 Q R
//速度(1-10)
% ?% W @# p2 u4 x0 r# T
var marqueespeed=3
! d/ ]# W g: S$ o& j. f
//背景颜色
9 @' E7 ^' A4 o/ U& u5 X
var marqueebgcolor="#FFFFFF"
- {7 Q, o2 G7 b3 n# ]/ a# l
//是否能暂停 (0=no. 1=yes)?
* Z- D# x* L3 h
var pauseit=1
2 V+ c$ R3 \. g9 n) q
- `3 I4 Y, F* ~7 ?4 e$ z
//修改显示内容
2 J/ g! {* S2 n- e
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
& E5 @' u0 h( ?& R; ^) m: J7 Q. q
! _5 V5 i7 z( A5 a6 W
* E# S, C1 h$ k
////下面不需改变////////////
/ @5 \+ H" p" j2 |7 O& B% L
6 c; L3 Z9 ?' C) h( X1 r
var copyspeed=marqueespeed
4 T- l+ E4 ^2 N* z5 ]. ~
var pausespeed=(pauseit==0)? copyspeed: 0
; @) b }) E' y
var iedom=document.all||document.getElementById
/ G& E5 L1 s% k: ^+ v' O$ q
if (iedom)
- N$ w, Z& `, f& Z
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
* e% P& ^- ^3 D4 u
var actualwidth=''
! O: x @: Y7 [! x. ]6 O
var cross_marquee, ns_marquee
- G" n9 K# S8 g- ?/ i
8 F4 O! p0 U/ L6 }( u
function populate(){
( ^& _. i7 N+ Y# B% L, p
if (iedom){
7 u9 D. d* o) d0 i+ U! O1 ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 k- C& g! j$ B0 `
cross_marquee.style.left=marqueewidth+8
: h7 D& ^; S3 n: ]9 L+ ]7 x
cross_marquee.innerHTML=marqueecontent
# G' c9 L- Z& Y! z- }. i0 y# t4 L
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. C! w; \) w# G
}
7 f6 S) C9 p- ]( q3 {
else if (document.layers){
6 `* P. F$ Z6 x; [6 Q9 ?
ns_marquee=document.ns_marquee.document.ns_marquee2
. I2 v; ^& E8 j4 r, R1 _- w
ns_marquee.left=marqueewidth+8
' i# I& p3 g' c) Z
ns_marquee.document.write(marqueecontent)
$ [ J/ H. g7 I) X H
ns_marquee.document.close()
9 F7 G% A" m3 ^* w6 P5 ~
actualwidth=ns_marquee.document.width
, [. b0 p- W" m" |+ x. S, C
}
. w; O% n' K7 n2 h1 P& F! H
lefttime=setInterval("scrollmarquee()",20)
1 |/ J$ U3 u; j3 V, C# Z! R
}
* a V1 V* D3 @5 d# o7 D6 u
window.onload=populate
9 z- U9 T/ J( P; i, ]/ Q( b
9 i" t2 p+ I0 v9 |- O8 A
function scrollmarquee(){
" p7 E7 p+ [. x& M
if (iedom){
/ X, w0 M; M4 z. r) [4 a k
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 C2 Y) ?, @: E0 y ]% _
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
* ?2 Q" X/ r, P' _3 [
else
( j8 G( f* X! {5 s/ B! O9 \$ S& h
cross_marquee.style.left=marqueewidth+8
! R9 b0 w: X8 f2 |6 s+ B8 F/ z
0 o# q9 m& V7 v$ }& Q
}
9 r8 D" d3 \* N4 P0 l& @2 H1 a s7 ^
else if (document.layers){
' g& [* P. G" P+ G8 E! z. _/ w
if (ns_marquee.left>(actualwidth*(-1)+8))
: x! B* g0 w6 {
ns_marquee.left-=copyspeed
& i$ d+ i+ W" c& X
else
. I! n) M+ o3 N% Q) ?
ns_marquee.left=marqueewidth+8
0 j1 B' Q* I+ ?8 ]
}
, _# x- n% X0 N! V
}
1 a6 G1 Q, t" }- ]! o; y `
, H- @$ ]1 K; y5 |5 g( s- j" W7 j
if (iedom||document.layers){
/ x; f9 \( i: U6 L9 e! _2 @
with (document){
% d2 ? F4 u7 Q i' u- O
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
+ h* D! b, J$ m8 V0 P& \7 R6 g: s; @7 I
if (iedom){
' \0 t- N0 V6 |4 v5 n# u
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
2 z, c5 c' c; A9 B2 {
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- F+ o: b( S2 H5 k- q' W( }/ y) |
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' f" \- H s8 |+ r5 D4 Z
write('</div>')
) j7 I" l; H* r2 n: k
}
& s1 S' D( c# v3 g) ^. w
else if (document.layers){
! ^8 m4 B6 m$ J1 z, ]) T
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 m$ G/ n8 W8 E/ C4 F
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
; V* }: S: _/ A: |
write('</ilayer>')
; |; D% D1 v: K# N
}
~1 ]6 J4 L" t- n% t. d9 E- x
document.write('</td></table>')
4 F. ]% I" D7 d: x
}
8 X ?% K% \! Q1 g$ y8 e
}
* `- v' S; V' @) C& |
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2