标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
! t4 {1 u% ]1 @4 V. I( l
var marqueewidth=300
$ s& E# \: Z! g% w' R5 |9 J
//高度
7 k3 M0 S$ e- J( L$ h! t* Z {
var marqueeheight=25
! ?' u) @( T$ |4 h
//速度(1-10)
# r- L8 J% ]1 [- m
var marqueespeed=3
2 R3 V h4 [8 z" s
//背景颜色
9 D% R" P4 y4 S
var marqueebgcolor="#FFFFFF"
9 o1 U6 P; O8 B
//是否能暂停 (0=no. 1=yes)?
( h. b O3 M* U2 g; X* h1 r. L+ H
var pauseit=1
: w, D- C9 b1 _6 c" s$ T
: S% w% T5 P t" y2 Q' ], J3 |
//修改显示内容
6 l) S! o- Q3 U
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
. M& H8 w! O) Y7 z) q. C
[# K I8 l3 K4 B m( g" p& M
0 L" H* B- c& ^* }* Q4 ?0 c
////下面不需改变////////////
1 K ~% i; `) c" h g) u
5 O/ K0 O7 y3 g, U4 o: F
var copyspeed=marqueespeed
' Z: [: J( t+ f0 q) u
var pausespeed=(pauseit==0)? copyspeed: 0
5 ^/ |( A" F t5 B- A0 |: Y
var iedom=document.all||document.getElementById
0 R8 ?4 Q: T+ j, C. ?* q7 O
if (iedom)
- C+ ?5 Y$ H8 G' Q
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
+ x9 F, ?7 E; P, q) V# Q
var actualwidth=''
3 k6 B3 [% k( Q4 q5 k
var cross_marquee, ns_marquee
* e2 Q0 y- A* ?, k# _5 o' q1 [( W
3 T# Y1 I$ j# o1 E, f
function populate(){
1 P) j$ ~& Z" N2 p
if (iedom){
7 @3 S ~' O' \4 O$ e8 _* B+ t, ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
' t3 k8 f% C( [! x5 ^3 y
cross_marquee.style.left=marqueewidth+8
3 W% o6 [9 D' z
cross_marquee.innerHTML=marqueecontent
5 v' F/ u8 X' w9 u, E) W
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
+ U5 O" y6 J6 Q( N
}
( A* l" ?$ I# q! b
else if (document.layers){
: A6 r, @6 |/ T9 r! @" U* m& D" R
ns_marquee=document.ns_marquee.document.ns_marquee2
; X$ x; u; X; ^, |9 x. D4 l
ns_marquee.left=marqueewidth+8
$ j; A' L$ H9 R2 u c' E' g( d5 Z
ns_marquee.document.write(marqueecontent)
1 u! M/ l$ ?1 C& e) a
ns_marquee.document.close()
/ c! O! @/ R- b+ _) G1 }
actualwidth=ns_marquee.document.width
& s' t L0 F& S
}
4 Y/ Z1 u' Z9 i$ A, z
lefttime=setInterval("scrollmarquee()",20)
( v4 N, G) w" p5 a$ C
}
9 k: r' \ F2 Y8 } S9 v
window.onload=populate
) u2 o0 K! M! ]5 D) S2 [ j
+ f1 _4 B% L4 l E7 v
function scrollmarquee(){
$ e4 n( Y/ ]* ^8 o7 V! ~
if (iedom){
9 c$ Q) s' Z$ f' a
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
& t, |/ [% c A& r
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ l( ]) h* y x2 L! O' r
else
3 m3 h7 w7 Y, ~7 G% P2 q4 c3 x# {1 k
cross_marquee.style.left=marqueewidth+8
" J+ m! G% y: N
! M8 r7 Y3 @* N4 A* w6 Z
}
0 Q# J+ F' u: x- t' c6 k& Y4 s! [
else if (document.layers){
4 t! L- o6 o `) J% J
if (ns_marquee.left>(actualwidth*(-1)+8))
: B4 h' h( g! N7 ~& ^
ns_marquee.left-=copyspeed
) h, A# x' P8 l7 s9 T/ x. _
else
# b' p" C$ r4 [9 j0 x$ `( S
ns_marquee.left=marqueewidth+8
% b5 w d; e% B
}
" a T T; s3 {3 |! n4 ]. h. I
}
4 R: u f5 \7 E
; `* j& Y. k* `: A+ z/ q/ I
if (iedom||document.layers){
3 J# [6 y/ U0 p1 z1 v- Y$ S! m
with (document){
4 m" M2 t2 m, j1 E4 Y
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
0 ?+ F( {: Z/ v3 Y
if (iedom){
; t0 H: E. F1 D. D# C' y
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ v6 L- V- l+ g ? F' J; v; G
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
# P8 l$ } @7 e& e$ d# ?
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
W& m) z: V" a# \5 k
write('</div>')
- e+ J2 E j( Y# ]" E Z Z
}
7 m( r) Z9 V) n6 v% O( H" R, e- k; z
else if (document.layers){
$ k# b; @& j9 o: K
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
, Z0 M3 s/ V- [
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
$ o) j. u( i' k+ i
write('</ilayer>')
1 s1 N" ?* r2 ?8 r. T5 _% E( E, X
}
+ K6 R) f1 @& C
document.write('</td></table>')
7 A; ~ i* K+ F4 v# f( G9 l
}
. b% a4 f2 r# s3 I8 K. O
}
7 _& Z8 x0 _/ |
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2