标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
# l5 a( `' i2 R5 q
var marqueewidth=300
: S5 ]' J: K- y2 d, w
//高度
8 F8 [; G* P0 s0 d8 l
var marqueeheight=25
4 y$ C* d2 H# F5 @" i! \4 r( r
//速度(1-10)
/ C9 Y( ~8 Y0 W ~! z4 w$ f1 \: w
var marqueespeed=3
3 U' N' S6 t; P2 w3 a
//背景颜色
" C, D5 C* e& U+ }$ ~7 r! ?
var marqueebgcolor="#FFFFFF"
, `! {7 |* \1 r( w5 j% m
//是否能暂停 (0=no. 1=yes)?
1 r8 Q, L% x$ @% G9 h- B
var pauseit=1
3 h! Y# A+ B# _
' J Y9 U* M, ?3 i2 H! H$ O
//修改显示内容
) n6 o" d9 y# T: c! R
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
" x1 r" ^% A) L- Y, a
* G! W' u" w( g6 H, b
5 w& r! Q8 j; }; ^
////下面不需改变////////////
9 Z* U( e7 s" N$ F/ u
+ X& V7 X1 O1 o( y- h3 P2 P6 L: P
var copyspeed=marqueespeed
/ w# m M1 o2 n% f1 y: t, [* S
var pausespeed=(pauseit==0)? copyspeed: 0
4 G# E* D9 y* X B( {! L
var iedom=document.all||document.getElementById
+ _0 T1 s- |7 ~! }( u
if (iedom)
0 O6 t9 v; ]4 `. `8 H& T! \3 u' A
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
. y; O' ]% f* m6 N
var actualwidth=''
8 d, q2 I2 m, ~/ u
var cross_marquee, ns_marquee
) l& i/ w* t' ]3 c
& {, y4 e+ }7 n+ [8 k- m# u9 \
function populate(){
; t( F% W7 J) h" P
if (iedom){
" `( t& i. v1 ~5 J
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
9 w9 Z B7 a1 q1 [, B% t. F
cross_marquee.style.left=marqueewidth+8
/ F6 N" ]% c% l: t9 g9 ^9 w
cross_marquee.innerHTML=marqueecontent
/ J' d6 l/ V( U- A( _, H* _% I
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" X4 ^; v5 c. f7 ]$ ]
}
6 ]: \: p1 j1 H: C4 X" o
else if (document.layers){
' p" \4 {: W% }3 v
ns_marquee=document.ns_marquee.document.ns_marquee2
2 Y: Z5 L1 W; b0 ^( Z) g9 B' N
ns_marquee.left=marqueewidth+8
3 m4 n* Z! W* X( I2 y7 q
ns_marquee.document.write(marqueecontent)
4 E& @2 U5 W' J# P' M- g |2 f. M
ns_marquee.document.close()
8 ^9 G7 V: D; P4 F7 @+ c
actualwidth=ns_marquee.document.width
! i9 {% |$ h' u, B r
}
0 z" m: h$ ?# {( G
lefttime=setInterval("scrollmarquee()",20)
$ G) f5 K- ^3 p) `; Q
}
. E5 d% M8 e* o8 F1 X% x6 y) }+ I
window.onload=populate
2 n$ V; S! X/ }( |7 a
' M* k- x# V* f' e) m0 p( W1 Z
function scrollmarquee(){
3 D& N d( V* H
if (iedom){
: `! Y; Q$ z/ H+ q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
/ |/ v2 Y& ?( l( Y+ a
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
( o% I, N& l q5 y% U. v
else
; _; }, J _" a; \
cross_marquee.style.left=marqueewidth+8
) I$ |6 ]+ V) L3 m1 t2 [! I
4 F, c: w/ u5 R, _6 R
}
$ Y# @) [, R8 e+ |3 q; Z
else if (document.layers){
: E& e+ z' q$ b) y" i% |/ k; l
if (ns_marquee.left>(actualwidth*(-1)+8))
; [9 s% }8 H; v! U1 h/ I
ns_marquee.left-=copyspeed
9 Y( {5 J; k0 M1 J
else
$ K6 h7 ^. V7 v' V: }$ n/ R8 n2 M
ns_marquee.left=marqueewidth+8
& q7 R4 |+ m: @2 e7 I: i; s& b
}
4 p1 \" y, |; t7 T0 F/ F
}
( a) n6 P' c$ H. q! W
3 z) \/ h2 R0 n4 g* j5 n/ K3 X
if (iedom||document.layers){
) K4 l$ w- T4 G
with (document){
4 D. i0 R9 U. i2 B s E; O9 R- N
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
6 g+ V3 ]1 f+ k( l {) b( F
if (iedom){
# [( T# i$ C3 i' B6 U* H
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
) V* x, W, [8 v; j3 t0 s; b
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
! U5 _. O# x7 _4 K0 R5 n
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
) {2 t0 K* F$ u# M4 \; v2 j
write('</div>')
0 A/ y8 b1 w' N
}
- t1 {) h7 u0 y2 J, R4 X- h+ j% f
else if (document.layers){
s6 T1 z, x. F' [1 O
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
. D$ m D/ G2 n0 O4 n+ d% k
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 {; e+ d' m0 V3 U
write('</ilayer>')
7 ]6 s7 F2 c7 x( n
}
; n# D: k% w2 ?' h
document.write('</td></table>')
& u% z" K6 A2 y- m. z1 X' h0 n
}
2 T+ H$ Z8 }' V' Q( B2 P8 M( M3 Y
}
, b5 O, ]3 b% M: s& Z
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2