标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
! B) b! x% A7 B5 ]* M
var marqueewidth=300
' P: b5 w1 ]9 t. O( k; F! n( z
//高度
5 m# }0 _2 o9 r- k$ a
var marqueeheight=25
+ m! H- O* y0 z! S
//速度(1-10)
( h. i; P9 u* b0 ?$ V; v7 U
var marqueespeed=3
& N+ M5 t, F0 u* \& D( s
//背景颜色
5 @6 r7 W2 ~ }7 h8 N3 ~
var marqueebgcolor="#FFFFFF"
1 J2 ^- n' @' b" x
//是否能暂停 (0=no. 1=yes)?
" r% a9 K4 M- G9 T2 C g* J
var pauseit=1
1 M. B% M3 E7 ~: N3 y* x, ]% `
7 e: p2 u9 @4 Q$ ]
//修改显示内容
+ H/ Z# s" |# c! ?' L, R
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
3 A2 r7 Q7 V7 ?
* m' {" Q2 z( b9 }$ ~; j# ` m
1 X+ s* U; Z$ P! s- g
////下面不需改变////////////
/ q3 v5 o0 i* u: E6 o
" f5 b9 a7 j6 J0 d; [- y$ {9 m# Z2 W
var copyspeed=marqueespeed
9 O: ]( }( a- Z, s. |( ]' {
var pausespeed=(pauseit==0)? copyspeed: 0
3 @+ V# ^6 G. \2 H# A
var iedom=document.all||document.getElementById
" t+ E$ ]/ H" d
if (iedom)
1 k/ u1 y! O* \ L; A4 V3 q
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
# U, G( m- C. b4 z
var actualwidth=''
; @; {7 c! Y4 _$ s0 V7 D
var cross_marquee, ns_marquee
6 Z$ U5 J6 y- E7 X
2 [4 N; `* `, s, Y& T; L
function populate(){
7 L5 A: U- S; f l* ~; h4 i
if (iedom){
; f, J {! c+ s T. z
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
6 O) _& ~- P9 ]6 _
cross_marquee.style.left=marqueewidth+8
' B4 o3 a r+ t
cross_marquee.innerHTML=marqueecontent
: G* C2 z) w9 _' ]1 T
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 ?/ q7 B, V& j
}
9 J9 F0 Y5 T1 P
else if (document.layers){
- N0 E5 D9 h: A- z* ^, |" g
ns_marquee=document.ns_marquee.document.ns_marquee2
$ \% m; s& j1 D' L3 p' S4 m! O
ns_marquee.left=marqueewidth+8
7 l& S; q! B, b8 d8 t* o3 u6 ?
ns_marquee.document.write(marqueecontent)
; m' e$ s% Z. ?* y5 x
ns_marquee.document.close()
- |' R4 `7 e+ J% P" V+ F
actualwidth=ns_marquee.document.width
2 Y/ c) K6 U C+ \% E+ _" N. Y
}
! a* s' @/ f/ T! k
lefttime=setInterval("scrollmarquee()",20)
' [& B+ p0 \9 m' h7 N4 B
}
, f+ J% T8 l) \& X4 K
window.onload=populate
& C3 a9 _1 ~# \ ` W! ?
; ]0 R* P: Z1 c$ b- v' l. ?& G
function scrollmarquee(){
/ ~# N) p; _1 @2 c* k
if (iedom){
+ b0 g- Z% n$ R+ N/ o" R
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
! X I" Y8 ^8 }
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
$ p- ]' ~( k& a! b, b
else
! l7 z' E: V; H/ _4 f$ Y0 o7 W4 L2 f
cross_marquee.style.left=marqueewidth+8
( U+ }) V$ [- c& L
, H; i9 l7 H( f7 s N' u
}
3 a( }$ ]3 h# N& ?& [
else if (document.layers){
5 q1 S6 [/ G( d, ~" D9 U8 ?, _
if (ns_marquee.left>(actualwidth*(-1)+8))
9 P, G, k6 j& Z% H/ [* {
ns_marquee.left-=copyspeed
+ p9 w, m: y& ?% d3 S
else
% B2 Z" S* Y7 e& s/ z
ns_marquee.left=marqueewidth+8
- v# S: s: Z7 \+ ~0 N% ~% e% B e8 B
}
$ t8 P W% N( p v: {
}
" D9 M9 }. e0 D7 M
0 R" `) O/ _) f
if (iedom||document.layers){
; P" i [' V8 J) {
with (document){
: N9 g* \3 p2 u- D2 n
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
2 g, L- l9 H( [0 I
if (iedom){
! Z% e" N. k, W7 J
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
, x) U( J! [% O! W9 `( d1 i
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
! W/ v* \" x3 t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 Z/ e7 e$ r" |
write('</div>')
7 w, m; u4 }8 H0 @8 r( l
}
* C! _* x5 D# t
else if (document.layers){
& o) x8 y! I! t' u% Z
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
8 ], F8 |. N. S" @) v
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
8 |% L* J% q, }
write('</ilayer>')
7 v9 Z, r8 S3 `( u8 x2 w
}
; i0 V0 Y8 H4 Z( ^; o; s) h. m
document.write('</td></table>')
; e; F; E* T6 y' n4 [: m
}
R2 Y% P, R Y5 M2 O7 h8 `
}
4 i6 g; {4 t; j9 m2 Z8 X& K
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2