标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% ^% v3 k2 A2 ~2 w8 j( o
var marqueewidth=300
- U6 {, B. l0 `
//高度
4 o4 [* q, P. P) J
var marqueeheight=25
- l# h i% e1 K# Z0 p% x4 ~
//速度(1-10)
1 P% [% f' o! v h9 p- ?* ~4 G
var marqueespeed=3
' a: K+ `0 m+ { t7 Z; d/ W! Y% o
//背景颜色
4 |7 i5 E0 q" { ?6 B0 b6 d) N) y
var marqueebgcolor="#FFFFFF"
8 c" J3 b! x7 E3 ]* Y) y2 W
//是否能暂停 (0=no. 1=yes)?
9 ~, ^1 Z/ R! n6 A4 T8 U" }
var pauseit=1
2 P+ b; _7 P) U! }- r, \) t7 V8 }6 ?+ k
& p8 R3 B- g7 P1 Y
//修改显示内容
) U, K; g6 B9 ]$ p" r, k: b
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
" l+ t3 Z1 A% \7 \& {
4 e& [4 |$ M, G9 D+ H" C/ E; a- x
. A2 M. `- M+ V4 P9 j) C+ D, x
////下面不需改变////////////
8 ]' u2 k+ ~" Z6 j0 H' b( k
) i% G/ ?( ^" C' d; H6 d4 f: y" G2 R
var copyspeed=marqueespeed
2 o# s* P# B, `
var pausespeed=(pauseit==0)? copyspeed: 0
3 P: t( J5 W! K, a1 N
var iedom=document.all||document.getElementById
- b# O8 @1 V5 e4 E( m1 n! y8 f; x
if (iedom)
3 X4 p0 I0 M+ t# K2 s6 [9 g$ c
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
) S3 d! }& f: ^* }7 w$ w0 ?* [
var actualwidth=''
! ^6 U- e# r' @& |7 x' k
var cross_marquee, ns_marquee
, h. f, K5 V, a. K2 i0 a
5 ^, S3 P& w ]- i; Q: T
function populate(){
# Z) W1 j' |6 u( I2 b" x' F
if (iedom){
) [4 x( r, }2 w1 ]. }6 ^0 O( U
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
5 }- N% i* m/ {+ p" Z
cross_marquee.style.left=marqueewidth+8
, b# V" Z [* e& ~
cross_marquee.innerHTML=marqueecontent
0 g$ k7 Q/ F, s/ @
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
9 W; n& [5 p6 U" H2 B$ m+ z
}
0 A3 y) v! k) Q( N1 `2 U* h
else if (document.layers){
F/ e* x4 I0 r# L7 R
ns_marquee=document.ns_marquee.document.ns_marquee2
2 l/ { t, \% Y# `8 E4 a7 _$ V
ns_marquee.left=marqueewidth+8
1 g7 {% B" _& |( E) O
ns_marquee.document.write(marqueecontent)
; z6 x( z# n/ w! Q5 e
ns_marquee.document.close()
3 p$ n* A, i! O2 g9 F# c3 R
actualwidth=ns_marquee.document.width
% D; k1 z; b9 T7 M6 Z
}
$ A. k4 X) d6 i/ A5 q
lefttime=setInterval("scrollmarquee()",20)
' G' y# s% F# M+ }: @ k
}
* j8 E6 m) ?" M" a% l; U0 Q7 T
window.onload=populate
6 \+ C! ^. o/ s8 m" q
' w. T2 {1 I; J+ c. k' C
function scrollmarquee(){
2 R7 v9 @4 C2 a* T6 [
if (iedom){
& @% J0 g1 }% W9 }6 \
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
- f! U! E: ^; |8 z5 ]! r
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
" k8 `( l' o f, @
else
: a: r1 u; ]( m
cross_marquee.style.left=marqueewidth+8
* V6 _' |) }; S0 @2 R9 D& E
$ x4 d Q, M" u6 i. j( ^
}
2 C$ w' u* v9 o3 e5 w
else if (document.layers){
, L- z8 N0 x' t5 t4 i
if (ns_marquee.left>(actualwidth*(-1)+8))
. Y% k& ^% k8 J. @
ns_marquee.left-=copyspeed
7 y7 b: ?8 D C8 w8 o
else
7 U; u8 ]! g, Y# R+ |( e
ns_marquee.left=marqueewidth+8
- R3 U% V, V, o3 O0 g i
}
. j" X3 f' P0 }
}
+ S& U" ^2 x/ f! U5 v+ Z: v# m: T
; V% ]/ p. V$ ]4 G) e
if (iedom||document.layers){
1 e0 l- L. `3 ]* @$ A" K
with (document){
: ^8 b+ e9 X, {! K
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
# I5 a6 o, ]) G' s% g
if (iedom){
, `" |0 b2 y/ X6 w- f: J
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( e& ~2 T" U3 j4 J
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 t' m- T b2 {. P$ d
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
! S/ F- B5 ^. Z2 E
write('</div>')
5 B0 }2 `* R$ t# }2 c8 G1 j
}
4 \; w2 ~6 f& K: T, s1 f
else if (document.layers){
/ C1 p$ O4 I* y! h& e/ l$ ^/ V
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; S+ n. ^' p8 {, g0 ]
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
6 P' l; I U# x8 h
write('</ilayer>')
& ~/ L$ t+ N. x3 n: S9 r
}
_/ H8 w; x4 A9 u$ G3 S0 l
document.write('</td></table>')
7 d) U+ ~2 n% w/ \& X, y
}
" K4 q. @2 ^# n5 _/ G$ a5 B6 Z% R
}
/ P8 G- p3 Y& u1 n \
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2