标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
1 O9 v9 m: R7 X9 O& {; [0 U
var marqueewidth=300
# o8 f- M0 [4 j1 a8 }$ y' T
//高度
2 J4 n, q7 U6 K
var marqueeheight=25
* {" I' c4 x9 Q1 }) Z% O9 T4 ~
//速度(1-10)
# F/ W% g& q/ c6 X3 u0 V8 _: X
var marqueespeed=3
$ m( P D# U" u& Q# M2 V' ]% R" W
//背景颜色
/ R0 c4 @8 H9 J& O& l' K! b( _
var marqueebgcolor="#FFFFFF"
{; Y9 @; L) m# B, m6 x+ B
//是否能暂停 (0=no. 1=yes)?
: y- Q* a% x, F0 d- p
var pauseit=1
+ W' n5 p }/ {' |
2 r' `. T" d& W2 @
//修改显示内容
0 `/ w: z1 T& O6 j, n1 @0 E
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 c+ F! t7 ~# X3 U- b9 I6 e8 c
& ^8 ^6 x8 a- b
7 d/ t: E, J6 B; [
////下面不需改变////////////
- |! x; o: h7 f4 l7 j& G0 t
2 N; V' \0 ?, b" f) T* S1 i- t" U
var copyspeed=marqueespeed
; c* Y7 U' K% y$ Z& g+ d
var pausespeed=(pauseit==0)? copyspeed: 0
& P. L( _ H+ o% _6 [5 @- C
var iedom=document.all||document.getElementById
2 r/ C6 d/ f: h9 r) ]/ t
if (iedom)
( C( r" `" S6 _) B+ X4 q7 [
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
3 a& m0 c: W. c1 X
var actualwidth=''
* f2 v! i! d/ C
var cross_marquee, ns_marquee
, O2 y, u" d* O$ R% S% O% r
2 U+ f$ l9 V8 K2 U! r6 d
function populate(){
! F. L2 e. v# U* b8 j# {
if (iedom){
- H( ]; N1 P( P( d: k
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
B* T1 ^0 W) E
cross_marquee.style.left=marqueewidth+8
# Z7 F; T# c+ ^0 x8 c8 ^+ o
cross_marquee.innerHTML=marqueecontent
1 C# y% v4 Z4 r# v: Z
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 z. d1 G; u% S( R
}
0 D' g* l# s+ p) y8 i
else if (document.layers){
\: I4 ~& T( H& v% I
ns_marquee=document.ns_marquee.document.ns_marquee2
/ F7 H" n' `# a$ A6 G% A
ns_marquee.left=marqueewidth+8
# l+ T8 v. p; B" m9 B
ns_marquee.document.write(marqueecontent)
0 _& c" Y3 F: ~$ j
ns_marquee.document.close()
; Z1 |$ n5 a4 V) Q3 D! p1 `0 R
actualwidth=ns_marquee.document.width
& X. J" y9 [' m; B
}
$ X& {9 q% S' C
lefttime=setInterval("scrollmarquee()",20)
g" d# X: O; X' D2 M! a
}
) C+ d: K: J: `2 u2 M$ E0 k. T
window.onload=populate
) Y% t, L- ]8 H( d
2 f6 J! [# h6 ^6 b& A
function scrollmarquee(){
! v% x, V/ ?: c" N+ {6 p
if (iedom){
) j8 `0 w1 Q* ^# y
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 ?/ j* @$ K$ A8 g0 [5 t
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
W1 o0 Z5 l) P1 T* I
else
2 Y6 y/ f4 H' q' L' W9 n4 s9 k( @/ M8 O
cross_marquee.style.left=marqueewidth+8
; j$ Z# f+ g2 b, R8 e
3 Y* k' _ `- \
}
" z% `/ s3 [- H% K
else if (document.layers){
* C _! U: X" P* ?9 o$ z* w Z
if (ns_marquee.left>(actualwidth*(-1)+8))
% |) L3 R" J; {$ m1 B* d
ns_marquee.left-=copyspeed
# U6 y2 M5 B- U' @6 }
else
: w# }3 b8 z l# P% k3 e
ns_marquee.left=marqueewidth+8
: t. Z- g1 Q( C1 w8 q
}
7 j9 J3 p* b3 A9 J* _6 n: E
}
3 K6 R$ F8 f6 ]; N6 ~% h( X' C; q5 X
& m0 D* f; y6 r$ ]; v2 c4 J6 a
if (iedom||document.layers){
+ \; ` d6 h7 i( R
with (document){
3 m9 _8 G& y6 }; u" E6 ]' ?" M
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
0 q$ D4 e2 ^8 c" ?
if (iedom){
: l8 \9 T8 V0 t6 V
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
1 Z* r9 H: x; n& Y5 Q1 V
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% a& j- j- I7 n2 F; I. @9 k3 g
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
/ m; `2 S L; v! X0 [. c
write('</div>')
" D" l: A4 W$ `" b
}
( Y6 s5 ~0 w4 I
else if (document.layers){
: i* `' A' s P) U: i' n% @& h d
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
~! f! S2 q6 p" U2 n
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
+ D! c+ [$ W2 V8 K: \. Z' b
write('</ilayer>')
U3 Z2 l: G$ N) D/ I$ C2 f
}
( x; H& M$ n8 b. k7 g" Z
document.write('</td></table>')
) f* b+ a8 T Z6 P" z% q0 m! N
}
1 [. q. T; ^5 A' A" m
}
" k+ B. D$ v3 p- |5 e
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2