标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
( O. E. l" k$ ]& I* ^' p' D
var marqueewidth=300
2 y# v/ j4 n5 U$ u& M& F
//高度
8 Q3 b6 a% M6 Y4 T! v
var marqueeheight=25
- Y. K7 y. I3 i' q# S! x
//速度(1-10)
6 s# W) c+ {9 b' s& G: t% Z
var marqueespeed=3
8 g( Y8 {6 X6 V( n
//背景颜色
5 X! {1 z8 s* i1 U( D, \+ [
var marqueebgcolor="#FFFFFF"
& I" m) w( S/ G# `
//是否能暂停 (0=no. 1=yes)?
0 ?: |& {9 O0 [2 D- N# b
var pauseit=1
* P6 Z4 T. O. U7 [
+ D# n" F3 ]# R, S3 j6 Y
//修改显示内容
7 ~' v9 q% v5 c% }3 n6 ^
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
0 @7 ~( ?8 j- N
, E5 J7 d5 R2 M0 M% f% s) B
+ N( {' l4 q' O# U G. Q
////下面不需改变////////////
+ D+ z' @% r- E
: j8 {1 n2 ^ f3 {: G+ J: M; B
var copyspeed=marqueespeed
1 z9 y' u% M$ H! T3 c
var pausespeed=(pauseit==0)? copyspeed: 0
7 t- i. ? T9 b+ ~
var iedom=document.all||document.getElementById
) G% i' U( W4 x5 M
if (iedom)
# l6 G, ^ `! D& L1 B' S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
W, e2 e) D$ f1 ^/ }; S
var actualwidth=''
( G& N+ Z! u) g1 {- E8 [" z4 W
var cross_marquee, ns_marquee
0 @" s2 y+ e$ m$ z3 F
3 m& v* l( o! h* l
function populate(){
! p6 N9 N6 p, o$ q
if (iedom){
" z w) d w8 J8 I
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
% U& Q9 R7 s/ J' ^, N
cross_marquee.style.left=marqueewidth+8
( H7 y2 G0 E: U! ?' n8 f0 ^
cross_marquee.innerHTML=marqueecontent
' ~8 X' Z$ z' V3 e: V& p
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 _5 c; F( ?% \7 L9 e* ^2 y
}
" o9 E9 G( C! Y* E9 W
else if (document.layers){
8 `! U7 E4 F: {0 q" E- _/ @
ns_marquee=document.ns_marquee.document.ns_marquee2
: m. g2 u1 f1 o ^3 j/ w, r" Z# ]% Z
ns_marquee.left=marqueewidth+8
! k" C& ^8 U* \$ O+ Q3 e
ns_marquee.document.write(marqueecontent)
9 C3 ?) G- @: L S: o
ns_marquee.document.close()
8 {. {4 s8 K/ F" y! h' O @& @! t
actualwidth=ns_marquee.document.width
1 V0 g! U' U' R: g9 T
}
1 x! g5 ~7 |- P* B& S
lefttime=setInterval("scrollmarquee()",20)
5 I; m! {2 ]8 a6 C4 }
}
5 A! P1 ?8 ?; x9 j
window.onload=populate
' }0 H3 {& T0 Z8 A" R
$ e7 P* E8 x% m' p2 X
function scrollmarquee(){
3 \' x( W. t. G9 f, q
if (iedom){
6 p: i B$ d1 D0 a1 F |$ y
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
7 S3 C* A" C- v0 u$ d
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
# D+ W% O6 d( W& T- Z8 |
else
3 M4 M& v' |* d) [. p+ l3 q$ b! S# B
cross_marquee.style.left=marqueewidth+8
: S2 B# h/ i5 a+ S
( E- k K8 w, H: u0 P' m) k& B
}
6 v+ J+ D0 I5 P8 ]6 J/ s9 z
else if (document.layers){
! \* J3 K' D" E% |' F2 e& n$ a
if (ns_marquee.left>(actualwidth*(-1)+8))
6 M0 a$ v1 Q7 k* Y
ns_marquee.left-=copyspeed
6 N; i) l3 L8 X& P
else
, _ ?; H+ Z+ K1 y9 b, U
ns_marquee.left=marqueewidth+8
k! @; s* `" J% G% N) P" H
}
9 W9 H6 o/ U3 Q9 S% e9 Z# w9 t
}
( x* m0 K$ Y0 E: {
8 Z$ X H5 f7 c! x! N
if (iedom||document.layers){
h% g$ w/ p0 T. N
with (document){
$ y/ e* \( ^: X! D9 O
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
1 M) K) X9 O4 `7 {3 d1 y6 n
if (iedom){
& ?# w4 f2 L+ V: N" y _5 z( G
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* A" H( K/ V4 g" R; @$ ?* J; _/ f
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 c6 @- Z2 w, N3 W g2 l$ O* p5 i
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" T( c+ S$ J0 \, f4 V0 ]; i
write('</div>')
" p2 U% F6 ]7 |, M8 P) t1 _
}
8 r, |7 z/ R* m' t3 {
else if (document.layers){
0 Z3 k7 \) q. p A) | r5 t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
6 d3 Y" i- K4 V( W, u/ L
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 P2 a; j1 o: m! n3 d8 K! a
write('</ilayer>')
8 e" w( e8 l& N1 Y- J
}
+ R8 i7 U* @* X
document.write('</td></table>')
5 K( h1 J" K! R( ?( s/ P
}
' d( [) P9 G' ]) ~8 C* a' p7 X
}
% t0 V6 z$ N z# D6 P
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2