标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
- s$ B3 h$ L$ M/ N9 Y: Z; D
var marqueewidth=300
" `+ ?7 [* z/ T _
//高度
7 d. O$ }9 `, R7 H7 o
var marqueeheight=25
2 [# V6 ]9 |1 R' ?4 x L! S/ b
//速度(1-10)
& W: Z0 D6 N' u: |& i Y
var marqueespeed=3
. g1 |, G0 q9 _3 P5 E4 H
//背景颜色
2 G( `" Q2 A4 H7 { B$ A
var marqueebgcolor="#FFFFFF"
7 h/ @0 _1 i: n1 N) R
//是否能暂停 (0=no. 1=yes)?
6 L+ x/ a% j9 E
var pauseit=1
$ H, F7 A4 `7 u3 |
+ |. v( y# G' N" Z7 d
//修改显示内容
6 {- H8 P! ~, a% b( P( _& f: B, V
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ { n" A3 Q! r" k1 u" u0 J" |
5 A" `2 o8 t5 V, F
) L2 f$ K5 `; t9 \
////下面不需改变////////////
5 A8 d1 X7 }' x* [$ M& X
! W; e2 [% _/ z& B" h
var copyspeed=marqueespeed
4 g7 [ \7 E2 u
var pausespeed=(pauseit==0)? copyspeed: 0
8 i# [/ h' n. b6 T5 W9 r6 q7 W
var iedom=document.all||document.getElementById
6 g7 W7 [3 A M) ]- ]/ l
if (iedom)
9 i( l, R1 T/ _8 |
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' w4 l) ]4 l+ F0 |& k% Z6 J
var actualwidth=''
) B/ L! b7 Q0 \7 ^! u8 v/ l
var cross_marquee, ns_marquee
: Q" `1 B) z( g# G; Z W8 O
5 Y( `- p# w Q0 {7 r1 `% ^- {* Z
function populate(){
: @5 u5 |) F2 b- p5 |, S# Q
if (iedom){
+ E7 a9 c' G- M& ]3 u% m$ {* O
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! M [& n$ }- e$ o
cross_marquee.style.left=marqueewidth+8
0 X* Y) v8 J" v
cross_marquee.innerHTML=marqueecontent
( S) k3 L' A! ~' {# S' W5 Q
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 G+ j2 _- N+ K4 v/ o
}
$ |5 I8 V0 z$ m* {
else if (document.layers){
- i2 R" _9 L; _
ns_marquee=document.ns_marquee.document.ns_marquee2
r3 `+ l. T8 ^% T1 D: j
ns_marquee.left=marqueewidth+8
. ?9 i4 N4 R; W5 B" `6 `% E
ns_marquee.document.write(marqueecontent)
* S* I1 G0 y- U. |& B
ns_marquee.document.close()
8 Z# C; L4 M- O% R) T; i
actualwidth=ns_marquee.document.width
! v" y3 o4 N% ^* c
}
* r$ J0 F: j7 H2 T$ Q
lefttime=setInterval("scrollmarquee()",20)
4 {* p; r3 M3 ], {& j
}
' b. v: m7 H! e5 @" A( H- I+ }
window.onload=populate
A L! G$ J. R8 Z4 l/ x2 L
+ u( f' P4 [! P& G5 _' s+ W
function scrollmarquee(){
6 L0 Y% Y! p- r9 m# r
if (iedom){
L* U2 b' s2 d m, Y/ }6 i
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
# l& [0 Q" z- b
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
- [# k' {4 a P1 N
else
5 C6 ]3 {' F1 q- b+ P/ d, g9 i/ r
cross_marquee.style.left=marqueewidth+8
1 M0 w% L1 e6 ~: S, P5 I7 b( Y
2 Q1 G5 w! y: f' c$ T5 y. I
}
+ `- n" _3 o$ E
else if (document.layers){
/ c$ S* w2 {4 G3 A7 x
if (ns_marquee.left>(actualwidth*(-1)+8))
+ }+ P8 J O/ M* L o/ B
ns_marquee.left-=copyspeed
( y- Q. L e" `0 E
else
. h7 M, w2 g2 x: E; e8 D# G
ns_marquee.left=marqueewidth+8
- E$ S, C0 w8 P' c
}
" k6 k" Q; c0 @# O3 C- v
}
- {* r4 r. i! h! ^3 C7 r& t
* i8 k5 L( P6 t' b: a; L( V/ F
if (iedom||document.layers){
9 o; ?4 Q; n# M4 }( S
with (document){
' T6 I5 }7 T1 A# N
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
- c ~) B) d+ K$ ?3 z* E
if (iedom){
3 A0 H1 K: o9 ^+ R3 ]& L! p8 [
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
" S. X# g+ q: H% @- N( l K
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
8 \. e/ V& E, C- i, A4 }7 e) `8 H9 b5 R4 \+ P
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ z: e" _' l5 K6 L% U9 F
write('</div>')
# S0 p, f/ \% X" E6 X
}
3 p% |* |3 C" w& J
else if (document.layers){
4 @7 p1 r1 g- i6 z: j
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
0 o" q, b- a. ^
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% N7 s7 O/ U6 t. M
write('</ilayer>')
: B; J$ `+ a; l) I! D" ?
}
3 q) U/ Q' i) p( y8 W) t
document.write('</td></table>')
0 }- ?4 A9 |; k& O0 Q' _
}
' [4 }5 b6 Y9 k. n
}
6 i2 s1 Y' v$ K5 U0 J
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2