标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
+ d2 Y2 ^4 Y& P" K+ M9 V
var marqueewidth=300
1 e. {) b/ t; J2 X- h$ G
//高度
" _4 L9 T, b: p! g7 W% z; `" z
var marqueeheight=25
! F0 N( z+ H$ h7 {. }! Q& x
//速度(1-10)
& \( H" ^9 K5 j( p' R! b5 |8 f
var marqueespeed=3
2 t) n2 ^ Z! P2 S; M j
//背景颜色
: A; |! I6 C' F4 v1 S5 U
var marqueebgcolor="#FFFFFF"
Y; }+ Y. y, E! h- S8 V5 G" Q1 P
//是否能暂停 (0=no. 1=yes)?
; \- e6 n( g$ N9 ?- w; V" q
var pauseit=1
8 a M: `+ E5 ^1 L) a. b
$ P4 ~/ c/ @8 t, X' ^+ z
//修改显示内容
! g* J1 }& Y, I' ` u' G5 v R" F4 k
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
& u6 ~7 ]+ ^, L
' ~/ w7 f4 ~5 }% c8 @
) G& V T6 g6 [' |. x" M
////下面不需改变////////////
" W% J, s" Z2 y$ D5 N( M
) ?8 c5 t# h$ R1 e4 o
var copyspeed=marqueespeed
1 K# p& r" b9 q. J" O" C3 n
var pausespeed=(pauseit==0)? copyspeed: 0
4 c* g- [- p6 V1 C( ^0 V: M
var iedom=document.all||document.getElementById
& Y+ Q, x2 O( m
if (iedom)
- f' j6 l; m# [/ R/ H
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
% y4 {$ H$ Y" C+ z7 d9 T4 ~) R
var actualwidth=''
7 h3 k- L0 q7 H6 A, P
var cross_marquee, ns_marquee
! F& m& }- j6 A/ B5 _ d
* f" P, S9 S- b+ {, S
function populate(){
: x; b$ z3 B8 Q* @' k
if (iedom){
/ I2 L4 \' h) W1 n1 h2 J! f$ B2 @
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 ~ Z9 ~; H/ {* k+ b, g- a5 t
cross_marquee.style.left=marqueewidth+8
+ [) \% G3 E4 q5 `) K. q
cross_marquee.innerHTML=marqueecontent
+ b8 J/ o) _3 z
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
- `5 w3 \6 @5 U! N, |
}
/ R3 t/ q2 u- Q; q( p$ z
else if (document.layers){
. Y h8 c; @/ \! v" z( X) l2 g
ns_marquee=document.ns_marquee.document.ns_marquee2
T/ U! I6 F9 v# t2 y: L
ns_marquee.left=marqueewidth+8
Y) b1 X- h" Z8 P2 M8 G+ Y* A
ns_marquee.document.write(marqueecontent)
~. l4 t% G3 M: U
ns_marquee.document.close()
/ j, x) h3 d2 y- ?6 n1 W
actualwidth=ns_marquee.document.width
) v% P6 S2 t2 [; J, B
}
; w3 z7 p9 q/ t$ A, ?( N
lefttime=setInterval("scrollmarquee()",20)
( ^. P$ n: I3 Z
}
: A! ]! r3 l3 c% |6 L3 `6 X
window.onload=populate
6 n J8 o- c9 i9 v
0 q* ?* W5 F" n/ k$ W( t' J7 p
function scrollmarquee(){
4 E7 p6 @* F* P7 l
if (iedom){
0 W) ]/ E$ O3 _# H; q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
8 ~; k- t" |8 T* J5 I* v% Y9 c1 H$ t
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
6 d" Y2 `% W3 g9 @0 P1 Y5 b
else
N8 q6 V1 K2 s
cross_marquee.style.left=marqueewidth+8
! \4 v. W0 C" ^$ |
# R2 d! |& G6 P+ x- M
}
& u3 U$ w: R+ P, T$ a. m6 Y8 y
else if (document.layers){
; n3 s" Y$ _+ @( }
if (ns_marquee.left>(actualwidth*(-1)+8))
. I* A. e' n3 C8 n
ns_marquee.left-=copyspeed
6 U1 I6 C* ? Q+ T
else
+ v/ V2 m6 F- p7 P1 N
ns_marquee.left=marqueewidth+8
- b0 b) J5 c% C. ?3 w7 J( a
}
6 y2 G2 c# t0 v' p j& v' Y
}
: R9 C3 c7 q, r
, w- K( H3 J4 ?" d) N. f
if (iedom||document.layers){
6 E$ m5 c+ Q9 z8 D
with (document){
: i# r6 U1 w j1 c8 d
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
% L3 i. v4 D4 ^( {
if (iedom){
: O( |% C6 Z: F5 v2 G2 q, C
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
+ A6 V. s' S5 w- K$ j9 M, N
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. ?) }$ p4 R# t% c0 O9 h% p5 T& H
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" t9 `2 {$ I, K# c0 t9 `5 y, X
write('</div>')
" i( m* I a, ^5 T
}
5 T: \$ g1 @0 \* t6 L! V
else if (document.layers){
- G' g. z- |/ ^7 i4 H* Y5 ^6 w- O3 o
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 E" C" N7 P' }
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
! d4 b3 [1 E% {
write('</ilayer>')
9 |- b% X+ S" d% q
}
& t% e$ g. g. y/ x% t: r# n' Z
document.write('</td></table>')
7 Q0 `: v9 T" g5 U: f
}
+ T9 q- L/ O5 C- r- ]
}
" S! A% y: `1 I( ?% `2 C( N/ B; y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2