标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
; ~6 k7 k7 |, U" q
var marqueewidth=300
7 R( U/ C/ \; m% d% J% n
//高度
: I, X3 ?( G9 i/ F$ n
var marqueeheight=25
7 `2 b& K5 S d( U6 |
//速度(1-10)
" T; }* y4 j' G, t! [
var marqueespeed=3
# m# b9 t9 t8 I: ?
//背景颜色
! h& {* Q5 v; e0 U: |2 j
var marqueebgcolor="#FFFFFF"
3 C! q: t$ L0 d- r& [$ \
//是否能暂停 (0=no. 1=yes)?
$ N. t) b' [1 p0 L+ d
var pauseit=1
$ z: w3 M: ?7 i$ A
' \1 ^# L6 A0 `' E- m/ R
//修改显示内容
$ f, A/ Y' i8 |2 N& ? \/ P6 P( A
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
5 M* h3 T# a0 [; S
: x+ q1 S" `2 \2 w0 U3 a3 V
7 K" B4 I9 h: _& [
////下面不需改变////////////
) Z0 ?/ B. Q8 b, f
) V. K) G! g7 n% {1 U" p
var copyspeed=marqueespeed
! `. C7 C( n2 G; b' y4 y5 ^
var pausespeed=(pauseit==0)? copyspeed: 0
: u; r0 ?2 V" O% Y
var iedom=document.all||document.getElementById
: V, `4 g% s& Y. f6 t: F2 n
if (iedom)
2 V3 [$ Y( x2 {, f- X
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
, g: Z! g6 V; |% s8 k7 m# Z% k: E
var actualwidth=''
7 [: U" k5 X* O1 B( j
var cross_marquee, ns_marquee
Q5 B6 ]# o b" F
7 { p- {: l, |8 G7 @
function populate(){
% ~3 a1 `" M# _
if (iedom){
: C A* s R8 N3 w4 v9 A, O, H* J
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 y( m0 t" c% O: G% z+ p, Z
cross_marquee.style.left=marqueewidth+8
) H3 r' L8 ?7 }" H
cross_marquee.innerHTML=marqueecontent
, y0 z% r) d4 L6 _1 n
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
+ M1 y j' ?( h2 t: j
}
/ C5 L: S: y2 X& L/ ]
else if (document.layers){
, Y I$ i, h. f3 s, t4 w! B
ns_marquee=document.ns_marquee.document.ns_marquee2
* Z+ ` K" y0 O4 D4 w1 w4 o
ns_marquee.left=marqueewidth+8
7 _" R( A7 u" A. |
ns_marquee.document.write(marqueecontent)
5 M$ W/ i4 \- Q, D7 o
ns_marquee.document.close()
6 P4 l/ J# I' F3 {' B0 Y9 A
actualwidth=ns_marquee.document.width
! N4 a5 Q7 p' u' S) Y! W
}
" S' z! i5 c- j d
lefttime=setInterval("scrollmarquee()",20)
& y& G# W6 O- I. @ c8 S
}
& P" u! w- P3 U/ A& G
window.onload=populate
{* T8 o7 A# k+ g: x
& G* `1 G: m: o: W
function scrollmarquee(){
$ {5 Y V& w! R0 d
if (iedom){
6 `' g; I3 |0 K* I
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 q* W9 Z, g5 g7 W. p- o
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
& |6 Q5 [! Z. y. z
else
5 c& d3 @7 y0 E2 ^5 f8 M! `
cross_marquee.style.left=marqueewidth+8
- G8 e4 n. S+ W
5 F; s$ i9 j+ p- V: N1 S8 ^! ~
}
0 l$ S0 P# M9 Q
else if (document.layers){
! J1 M( S% O( |, T1 I$ b/ m! p
if (ns_marquee.left>(actualwidth*(-1)+8))
?) S: G; j$ ` O _! ?: _# g; Q
ns_marquee.left-=copyspeed
& d. x( \) m1 v6 a4 v! k
else
3 d) i6 b& r2 q5 R/ [$ m s |
ns_marquee.left=marqueewidth+8
5 _# Z0 q/ k1 G% t) e) Z% r% t$ O
}
|( A# l t1 t. D& P. l
}
) W" c' w/ _) G) l
# C5 z8 D( Q& b k; t! B9 U% w
if (iedom||document.layers){
9 G: S" X9 b2 h2 b T
with (document){
2 a! v6 A9 b$ o
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
2 w0 g% m4 V! Z
if (iedom){
?, a c7 g) M
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
. E; z$ e4 p4 |" Y' q
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
+ M0 c- l h; Z( k4 G
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
& F2 V' a0 B7 D* }1 P8 E1 h$ `' g
write('</div>')
; f( H+ B- I4 _' W/ w, I) [! s
}
0 u, ~; U0 C5 _- x8 n7 j4 z
else if (document.layers){
, q: } B! G+ T% a$ v/ B
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
& {8 x: _: G4 _- E7 U
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
' ^: r' B) e) o' b- P
write('</ilayer>')
8 F0 g/ n% _$ K. d1 l6 b5 o
}
4 a8 ^: t8 r# _' @/ c# m
document.write('</td></table>')
/ s( `; F- o& |# h/ |
}
. Q( P& _1 h; f3 |
}
) c; o N8 I$ O0 t+ [2 w
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2