标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% t9 _ O& K, J
var marqueewidth=300
, u* `& z4 E! n! ?
//高度
$ I/ B2 V% e5 }0 e$ l
var marqueeheight=25
+ V* o% |6 Z- y# z; Q+ z! q
//速度(1-10)
% X& a1 m5 M; x; e
var marqueespeed=3
3 {( M' R" r8 a5 Q- [
//背景颜色
V! J0 ?* m' T5 \+ Q, q O' P
var marqueebgcolor="#FFFFFF"
, L$ t$ ?' v4 m) J; {6 ~8 _
//是否能暂停 (0=no. 1=yes)?
1 S! F9 x5 z6 Z
var pauseit=1
1 A4 N' o6 U2 U8 E2 I: s1 S, y! H
0 t' [1 ]+ k$ Q
//修改显示内容
z8 l1 |5 `4 q2 p6 ^/ H+ e7 s
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
0 J0 p: s- N p: n' }5 E& [* s7 h
W: m7 `4 z$ v# P8 Q
, \4 I( e1 V/ d2 o/ B, ~/ a V
////下面不需改变////////////
d' o- R* m$ X5 q# N. _4 |
9 z( q o9 R! A3 p- d, |7 c
var copyspeed=marqueespeed
6 f2 i* d( \* Q4 T6 ?, \
var pausespeed=(pauseit==0)? copyspeed: 0
8 Z' r; s X' @5 j
var iedom=document.all||document.getElementById
- F/ z! p1 p' c% G4 p
if (iedom)
8 J. s5 o* f# _1 h, o3 K
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
8 G/ x+ Q) \, v2 I
var actualwidth=''
0 P+ A+ V7 P" Z8 d" R' a
var cross_marquee, ns_marquee
* T6 V5 R4 i& N7 p! y- ?0 V$ T
, p, W5 _/ e. H
function populate(){
3 T& G V) d+ o, r! r; z
if (iedom){
7 q5 {- I+ V/ q" k" i1 E
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ p# f' [4 ~" j2 w9 D/ P) U
cross_marquee.style.left=marqueewidth+8
$ H6 J4 F* k5 K8 m2 K( N, [
cross_marquee.innerHTML=marqueecontent
5 ]! L$ J' T. P0 L6 T8 u
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" f/ t) D ~9 L) g5 j. `/ n
}
7 o7 c! ]* s+ v3 c. R/ O0 \
else if (document.layers){
# @4 j- N6 o8 ?$ H9 |$ Z/ R
ns_marquee=document.ns_marquee.document.ns_marquee2
; a- Q% S5 z* v- j0 D! f
ns_marquee.left=marqueewidth+8
! P* y+ F5 T4 V5 a. q9 t
ns_marquee.document.write(marqueecontent)
/ Q. _* @0 p! {+ s
ns_marquee.document.close()
3 g' Y( S& C' \# {8 ?% ?' w
actualwidth=ns_marquee.document.width
# \+ R i4 R5 t
}
# X/ e1 T% ~3 }) A% B5 u9 W
lefttime=setInterval("scrollmarquee()",20)
, Q" M( ^0 ~5 u! W% z# D3 C
}
) I% a3 Q6 j3 B2 X9 I
window.onload=populate
/ x( Z4 N3 m% p3 g4 c" T# R
/ ~- z0 l# n @ [
function scrollmarquee(){
: u: o# Q8 S+ d; U d) i/ ?2 o
if (iedom){
0 [* u/ x% d5 U: L
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
( J7 f8 p7 Z) g6 t8 N; [/ K
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
" _" B8 ^- H5 ^, Z
else
- m$ c& i- i& R( y5 Y* Q' A: W
cross_marquee.style.left=marqueewidth+8
% u y3 H9 \5 ^) v& ]4 ~
" A9 E. B7 ~2 Z6 B+ e7 g& G
}
$ v4 g, [5 {' R5 s# m
else if (document.layers){
& K) _* e2 Q6 Z! y* ~) l Z
if (ns_marquee.left>(actualwidth*(-1)+8))
9 `# R0 f' `4 o# L* J
ns_marquee.left-=copyspeed
) | i7 p$ b/ W; k' H
else
# C1 _! ]" s" q5 M3 x
ns_marquee.left=marqueewidth+8
2 \9 b: [8 g; V
}
- D1 n( _; ^+ U- q( H* @7 A
}
* T0 k1 {. q0 ~; v4 J( D
4 [4 T; {0 @$ t8 r4 |2 e
if (iedom||document.layers){
1 R9 `3 i( k( I1 |
with (document){
) e7 k9 s) V6 ^( I' n
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
) y: B7 `4 W7 {- ~! f" z1 D/ N% Z
if (iedom){
7 T( o! i+ z4 M H
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
( \$ y, @& z' f% A! c2 i
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
4 [8 a* R8 ~1 d0 s2 R+ W
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
7 N( G& f0 T! l! P; R# V
write('</div>')
8 m- k% w1 o2 v5 I
}
8 K( k; g" A+ y P
else if (document.layers){
; U* k r; {% o
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
! ~2 |) e, |/ {% B, H3 K. n6 g
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
4 ?5 Q5 C m/ ~
write('</ilayer>')
% z1 s. r$ u. q6 l2 _) Y9 ^7 b
}
( C5 s% z: g3 g. R' r
document.write('</td></table>')
. \# C5 x& w c5 _) `0 k) {+ K
}
/ s; Z5 u; ]9 {# i
}
2 S; k6 k' m/ [9 S) ]6 [+ [
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2