标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
/ z0 T3 P8 b8 ^4 l
var marqueewidth=300
n: K. B4 u% s; u
//高度
& Q; j. [+ C, H0 Q4 I+ x( Y) K5 J
var marqueeheight=25
4 ]& b' X z5 ?/ I' |% o; J4 S) M
//速度(1-10)
+ z0 L+ ~; _9 o5 L8 c
var marqueespeed=3
y) N4 Z% ?1 N
//背景颜色
- @* ~0 l1 K% [* J* x2 h
var marqueebgcolor="#FFFFFF"
5 A; e: v0 Q* |! { u5 w( v
//是否能暂停 (0=no. 1=yes)?
% c1 J0 |& O* H2 @
var pauseit=1
% O" o, s4 N8 x* U6 \
4 e* X$ k& w s
//修改显示内容
/ X. Q- J* o1 h! L& x# o
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 J; B5 B! x' [
8 } }4 d" ^4 X# |+ b& o+ }5 s
3 K- F; @9 O9 h4 T( h' d
////下面不需改变////////////
8 O" U6 i1 Y' i/ Y: A
% o$ Q; a' g* ~. y
var copyspeed=marqueespeed
, w- j. n. U1 m" ^ c3 t
var pausespeed=(pauseit==0)? copyspeed: 0
, G% ^5 a4 N3 L2 U0 X' j
var iedom=document.all||document.getElementById
6 Q- c: I' N( |# Y8 Z
if (iedom)
# m, J7 q: ~9 m# }; L7 z
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
2 q/ T7 z! R: q* E7 M) V' k" H
var actualwidth=''
, H% r" F( | m W, K
var cross_marquee, ns_marquee
$ i# N- g' u) Y6 ?6 m$ F
# K- z' D; A' p$ j+ n2 a
function populate(){
) ?! b( y+ A. J4 B
if (iedom){
* K. A- m4 C# Y+ k) m* d9 {
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
1 l, z1 b6 L$ m3 _- L3 I ^
cross_marquee.style.left=marqueewidth+8
# u: m/ k t6 H8 ]/ U4 ^$ @; \( D
cross_marquee.innerHTML=marqueecontent
7 g" B( ^2 ~& d9 U6 f$ k
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
$ g+ q1 v6 r L. A
}
$ y& J' g h6 c2 U( y% ?) t
else if (document.layers){
7 f* Z* ?* I4 Q. J
ns_marquee=document.ns_marquee.document.ns_marquee2
9 G" y8 y7 ~# v; d5 m8 d( ~/ x; i
ns_marquee.left=marqueewidth+8
& Q8 H. W" U! P ?/ J) A6 O
ns_marquee.document.write(marqueecontent)
; M/ ~( O& b/ h! Z C3 Z5 f. W
ns_marquee.document.close()
% `7 V1 f: y2 f( u( O1 f1 k% a
actualwidth=ns_marquee.document.width
6 d2 _6 @; j# D% N1 M9 `) d. j
}
: a4 s& I- ?5 x9 w* c6 y/ e! @
lefttime=setInterval("scrollmarquee()",20)
+ W% x2 I4 O: v
}
/ E z4 x$ Y' N! \
window.onload=populate
6 n! y) g5 \ [
& a2 K- @& F+ ~" j5 w {
function scrollmarquee(){
4 Z, J2 a& G' r6 a
if (iedom){
4 y8 N9 `& [ f
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
- P- x7 K* j0 U4 o, |2 ] D- a: {
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
. H$ y, I5 E) X, F# t* @; [' ?
else
2 b# q8 a+ k' E1 V, R: x- r$ l
cross_marquee.style.left=marqueewidth+8
( J! d3 Z/ n! d. |8 e
7 V6 B+ r6 s7 a- D+ D# [
}
; v* }/ J0 J% U, E" l2 u
else if (document.layers){
4 O6 B4 Q# ~& Y. m
if (ns_marquee.left>(actualwidth*(-1)+8))
: n! y# {0 O! t* [, F. s5 i$ n' c
ns_marquee.left-=copyspeed
' Z9 Z4 g* @! k. v# a* q
else
' V! V E# X! m3 _
ns_marquee.left=marqueewidth+8
! s! Y: z2 C1 q" X
}
% O0 y9 x8 Y! F# S1 B
}
+ p$ C0 N2 U# T2 X# N
" Y" w$ x: t* f/ f( u1 q; Q
if (iedom||document.layers){
- e1 M5 O1 R& d } t7 [
with (document){
$ y/ Z7 K/ i1 I, x( |
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
# m: g+ ^) D/ h- x; b1 D& h" A9 L
if (iedom){
3 W1 H a* Z Q
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
; N: w# ~8 M5 C' u6 @( B/ v- J
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ A; F# q! m' A# D! M
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
$ ?; \- M% ]" }) C* \* j2 |
write('</div>')
' |7 k& R* ?" Y( m
}
: ^+ S1 ^3 W$ b8 S; S( M- }; t
else if (document.layers){
: t: Q" j" W3 v8 s* g
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
5 `2 z3 Z! f7 h/ y; d
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
* Q# Y+ i7 r* D0 O; H# ?& v
write('</ilayer>')
* V$ h( B! e$ t$ H
}
0 |2 o* v0 {' ~, `: C
document.write('</td></table>')
, _% I6 X2 G! F
}
) G2 \, o# ?/ ]% `) y/ i% g" _
}
% q" @! z1 x6 m& n
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2