标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
2 N: c9 T; w# |* Q+ m2 A0 t/ {
var marqueewidth=300
4 A3 p3 r/ h5 J: p
//高度
7 W+ |. U! l9 c$ f+ q. W6 J
var marqueeheight=25
7 S7 ~% Y9 X# R4 e( F# X
//速度(1-10)
' m) }. ~( X( g2 W
var marqueespeed=3
! W7 `" N' Z- F
//背景颜色
: V7 w1 t- b5 P: C1 q0 `
var marqueebgcolor="#FFFFFF"
w9 A- ?) h+ c( ]$ J
//是否能暂停 (0=no. 1=yes)?
+ w# K. R1 V( L( D
var pauseit=1
# Z9 L7 I( @% c. u- J
5 f, Z( s4 x+ u* d
//修改显示内容
) N# S( C8 b6 ], b Y: I. R
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
* P% N' }5 s' X
: n6 W" x; g* Q* w6 a9 t
8 A" d6 ^1 a2 q" m0 i7 c
////下面不需改变////////////
& K( T) W/ x( H# _( u- I! x2 f
0 [5 f) B" o2 u" [
var copyspeed=marqueespeed
% |3 f1 D8 L6 S9 s/ O1 o7 t7 V ]
var pausespeed=(pauseit==0)? copyspeed: 0
( c2 t" [4 K; b
var iedom=document.all||document.getElementById
/ N9 Q4 K( ^- s: E
if (iedom)
' n- A1 _+ T) @' f8 c! n$ S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ H6 n* N8 Z# _7 k) ]3 g0 C5 {
var actualwidth=''
! Y. \2 D& i' z
var cross_marquee, ns_marquee
; y: C i% U# X5 t
( J* X* J3 o! }: S6 K$ @
function populate(){
, {2 ^- W* J+ }) h
if (iedom){
1 ?9 m: r0 L( |/ j& W& p: ^8 s( o
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& x" T `. s6 L& n2 S! S0 \/ \
cross_marquee.style.left=marqueewidth+8
6 p& r5 W2 B8 I; t; O+ }4 \
cross_marquee.innerHTML=marqueecontent
# f7 j0 f" t% @) B
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 o t3 y) b. i- y- E
}
& a' k% k: F" [9 S9 I
else if (document.layers){
; ^$ o6 _, {' H/ r- {$ |# S8 A
ns_marquee=document.ns_marquee.document.ns_marquee2
6 |( R9 h# t! ?
ns_marquee.left=marqueewidth+8
$ ?6 W* m% P0 [# m. T; Y9 x& j& \7 @
ns_marquee.document.write(marqueecontent)
' w. m F4 @1 M( _8 j
ns_marquee.document.close()
* Z- O3 g) H7 I- H) l
actualwidth=ns_marquee.document.width
$ T* A( o2 P: C5 i3 b }% I' J X
}
( {) @" H. a: m- f: R) n
lefttime=setInterval("scrollmarquee()",20)
, Y( n R: f+ v
}
$ h$ K) N- s# q+ \8 g: A& n
window.onload=populate
; ?6 A: `+ k/ P2 a1 N3 v8 d
; E$ f+ c3 j8 N, t" D x4 P
function scrollmarquee(){
" a; S1 ~4 t. h
if (iedom){
( [, J a( [( q( m# ]2 R
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
1 T% |3 u5 ?7 p+ a0 i. A m
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
3 c+ y T* Y7 P, }* K# }
else
' |/ s' M6 y4 }) }7 a
cross_marquee.style.left=marqueewidth+8
+ L1 B0 M* N$ L" R! N
+ C! ~/ z7 R9 x/ L6 ^$ h ]7 p8 j( ]
}
% U; S& ^& z2 S
else if (document.layers){
+ r; E5 U; }; Q/ G! f/ A1 f3 X
if (ns_marquee.left>(actualwidth*(-1)+8))
5 X5 U6 o5 d6 I# s. ?, F+ [( r
ns_marquee.left-=copyspeed
. w( b: `+ F! @. H; D/ A# G
else
+ Z4 \( M$ D4 q
ns_marquee.left=marqueewidth+8
. v' z" Z/ P& H; ^
}
$ C$ o2 {1 I* e+ W/ T
}
8 P3 h) ?; _+ E! R' {
5 {) A8 a3 t% j* i
if (iedom||document.layers){
5 O/ H4 ~& a3 x1 {. F/ B
with (document){
: \$ c C' h# w& x2 V* i
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
) b3 R, q2 e7 G: c# V' l
if (iedom){
8 W3 r" v, C* f$ `+ T' ~
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( M- G, o% Z% f5 w" ~
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
# J9 @' ?+ l% W1 r5 ~5 p
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
, \& e/ h' E4 K% l( u
write('</div>')
4 j0 c5 d: T( p# n3 J% F! W2 z
}
% W* t/ H; K" c" U8 @, F* J+ a6 I
else if (document.layers){
f6 a: e0 `# ?9 @0 J' t. C
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ y9 j x( Q l: C
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. { [2 m# _( k7 B: ]
write('</ilayer>')
% H }' ^ ]5 y! n0 ?0 Q
}
! e" K$ }1 |4 c9 K6 e4 g
document.write('</td></table>')
- C6 U: @4 t, S# D" S* i# _- {
}
( W1 [0 L( \8 H1 o; L" {. V$ ]
}
1 p( Z1 ]' X+ F/ Z
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2