标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
3 A2 O. a/ j! \1 y+ ~- h8 D
var marqueewidth=300
" i/ n3 Q J8 U* ]8 o; i8 O* ~7 h
//高度
) F) {$ ~$ g. f/ ~, d
var marqueeheight=25
1 I" w) z& x% ~+ {0 M+ s
//速度(1-10)
; y5 p( L5 F6 v* n7 Y. j- _4 H. ?1 @; v
var marqueespeed=3
2 ]- ~0 t* p1 y
//背景颜色
! _/ H$ X ?9 ` j: k& M1 K7 b
var marqueebgcolor="#FFFFFF"
6 u, ?/ a4 j. Q( m: x
//是否能暂停 (0=no. 1=yes)?
4 P* E: }" e7 p0 L
var pauseit=1
3 }! r% x( Z# Q6 S$ Z. T: E/ f
/ W# N6 ~6 z/ t8 K* T
//修改显示内容
4 a/ a# B- _3 r- l* @) H
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ b/ T. g9 M: H6 K. A; w+ n& b
# V% @* w* y# O- P7 f5 n4 Q
4 z' [+ X; N, j/ {7 w6 [5 p+ {
////下面不需改变////////////
; e3 `4 j. {! w9 w' j
7 T: u# O! G/ X
var copyspeed=marqueespeed
. Z0 o$ a+ C' \( i5 [
var pausespeed=(pauseit==0)? copyspeed: 0
) U# ^; v; Y9 }: j o" p
var iedom=document.all||document.getElementById
& L0 O) Z2 ]9 N) t, |8 b
if (iedom)
; @; |- z/ P+ ?7 b
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
0 d2 q+ X' K! L8 D* Z( z. T
var actualwidth=''
( K" P) x0 |5 O5 H
var cross_marquee, ns_marquee
4 |: m( ]1 z% w
! H" @; D6 e% q" u1 Y) a' m
function populate(){
6 D' {+ G* N+ @# ^
if (iedom){
8 _& V: A! W6 {; ^
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
) B- ]3 O% n4 u Q) Q; ?1 w+ I: X
cross_marquee.style.left=marqueewidth+8
. L! u% y# @+ G: j
cross_marquee.innerHTML=marqueecontent
+ }* e& C Z3 R8 ^
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 F8 T8 d! f* P, F+ ?. Y9 R
}
" w _" l! j+ A) v" d( y3 N% ]
else if (document.layers){
" _* U0 M% b. s% @
ns_marquee=document.ns_marquee.document.ns_marquee2
+ e; U: h# \- L9 d B$ y
ns_marquee.left=marqueewidth+8
! [6 _$ _2 f) }3 S8 r
ns_marquee.document.write(marqueecontent)
/ M. D. B$ d4 q- r
ns_marquee.document.close()
" x3 z9 }) U; K; }6 `" q3 T
actualwidth=ns_marquee.document.width
0 P/ W+ B" E/ g% d# ~. c
}
# B$ ~2 s) A( L' N" m K9 |
lefttime=setInterval("scrollmarquee()",20)
* m. k; G2 V+ z6 @0 C
}
% j' Z# _ o7 n! m
window.onload=populate
8 y% x3 n0 ~; I( q- J7 D) x
5 o; U) ]2 q0 `/ o: @4 I
function scrollmarquee(){
2 Q; X; y3 e/ W. R J& W
if (iedom){
% e. R8 V; J: M: e* Q
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 a7 i1 E2 f/ q; W3 z9 S& ^
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
1 y" b7 w0 H% u7 f3 y% H
else
, S8 K, S- g3 ^" X A! A/ q: K2 c1 n
cross_marquee.style.left=marqueewidth+8
5 |( s3 X: [1 L8 e9 Y
+ O. Q" z; Q6 ^- H9 s* ~
}
4 o* M1 j- O" n* y
else if (document.layers){
7 `. J1 b9 G& i1 m9 Y; v& m
if (ns_marquee.left>(actualwidth*(-1)+8))
; {9 |/ {- E+ r: l8 ?
ns_marquee.left-=copyspeed
8 t* ?! S( o; r& [5 a
else
9 U. I/ J: w+ }8 _# u( O
ns_marquee.left=marqueewidth+8
8 M- K& x% z ^2 B! G2 Z5 _) o4 J
}
) N4 z' e; B, C
}
0 k C- G' W- K- g2 H* P& L4 ^7 X
/ B8 `6 j1 q5 }- R
if (iedom||document.layers){
/ J$ ^% J) A8 e# d# O) j* Z8 [
with (document){
' `, [( e2 f' f6 Z5 z- }2 ^
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
* O9 V/ d! _2 v" ^5 ^
if (iedom){
* D2 O' u2 v* g+ O) y
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
3 |$ f0 l& N7 ?6 _
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
6 N. d4 X) A4 x. E) ?. Z {
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
: I8 I4 J" [/ @. A: s6 L! d8 O
write('</div>')
t8 e% `/ L9 h( m+ I
}
" E3 t2 \& `; E4 \5 @! |0 Q; ]
else if (document.layers){
5 o* u8 k% o B. ?: T; u. z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ S+ T7 R2 @ x9 i5 F" {' T
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
; n6 V6 z* h: ^$ n8 }
write('</ilayer>')
6 T7 R, g! ` }6 L0 B# A
}
: P L) B* Z, f7 u/ y- L
document.write('</td></table>')
6 c1 I* ^" ~4 Q8 {, C
}
2 r7 d. C' e4 }$ ?. j+ K
}
! K! w# L7 N( e8 |$ @. m" `+ a8 p
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2