Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度
  ~( o7 L% T: T5 Z; b! Qvar marqueewidth=300" a: [# G. J; V. D. r# K5 ]6 R
//高度
6 o& H  x; K& k5 d8 }var marqueeheight=25
' D5 _# I2 i9 Z( L7 s) O//速度(1-10), s1 R0 L, q9 Q- ~0 {' u7 ?; P
var marqueespeed=3
& T; D# I. p# R1 w5 z. h! I. c9 `//背景颜色
  X3 U5 i' s- ~- F3 d1 u* z# ?var marqueebgcolor="#FFFFFF"
3 V" Q3 A6 j$ ?# l//是否能暂停 (0=no. 1=yes)?
4 T7 [5 T1 R; p1 h5 r2 H2 K) Lvar pauseit=1# G6 P7 ^$ M1 X* G
2 ~+ x# d/ |8 y2 d. w
//修改显示内容0 y5 b3 k. ~& ?( O; Q; i0 k
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'( v9 W' M4 V: d; h# y

- G- U, |0 J) U6 O# o; X; ~% s
( t6 [8 Y5 l( [////下面不需改变////////////, |! o, k" F. ~$ Y6 Y) S

! H% J  R' M6 {- Qvar copyspeed=marqueespeed
! K( o5 s. `, N7 h4 Z5 y& Y$ fvar pausespeed=(pauseit==0)? copyspeed: 0% R* k0 b) w8 z1 t6 |
var iedom=document.all||document.getElementById
8 d# T, M1 {' B9 N9 @# sif (iedom)- \8 |* B8 {" x$ x7 n+ L4 ~
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')9 a) D; B& g4 a: ~
var actualwidth=''
4 G# E, [6 R( F  }var cross_marquee, ns_marquee
: S9 ?1 c2 k3 ~+ R8 D- f  ]- K
7 J( v  s, L! Nfunction populate(){
% k9 E& @8 L( X5 |/ K% Mif (iedom){
0 K6 [! g9 M; R, Vcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee0 Z7 n: p+ K3 J- n3 O: e
cross_marquee.style.left=marqueewidth+8
7 `  D3 ]) t) f" b8 Hcross_marquee.innerHTML=marqueecontent0 Q" `* n- k1 n% `. X
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
. x' M, X) X! k" \% [2 L}8 F5 }# c, T9 _( r/ }( t
else if (document.layers){! S& U0 [3 V8 l5 ^+ O$ R  n. P* h' ?
ns_marquee=document.ns_marquee.document.ns_marquee2
1 j* p0 H. n1 T$ fns_marquee.left=marqueewidth+8
4 q3 F6 }; k8 X' S( S  Yns_marquee.document.write(marqueecontent)8 ^" `. `6 y8 `4 a! b! R
ns_marquee.document.close()$ h, Z1 o8 o( z
actualwidth=ns_marquee.document.width
7 o% C6 B' d( Z9 Y' g, w6 o}, V1 f" @& H( I  _# @
lefttime=setInterval("scrollmarquee()",20)
8 h' g( Q+ F) X- R}) F& u- q3 u. B; y+ x
window.onload=populate# i1 O  z0 {' s! F
' {5 p( F( a# V5 p! j
function scrollmarquee(){( l" {9 T# R+ C5 M1 }3 n
if (iedom){* M% v; t* j2 Y/ a
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
8 d" D: {! U, a2 W; Mcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed4 M, O7 B& V. n8 d  \- A& W; F
else
: x$ j! W) O: A4 d% t: H8 H% o+ zcross_marquee.style.left=marqueewidth+8
2 p% X4 k! [' u2 G, @2 G" J6 w& i& L7 o
}5 t3 K8 ?: }* _0 C
else if (document.layers){
) Q- [- y" `( ^1 Yif (ns_marquee.left>(actualwidth*(-1)+8))
+ p9 g- R, L# k/ d: Uns_marquee.left-=copyspeed+ E% Y8 {( k/ s6 R0 v
else: g% R$ I/ i2 D" `4 S2 M
ns_marquee.left=marqueewidth+8
$ s/ [; X' ^  Y& X}8 Z  x* Y" ?9 M' L+ F9 P
}. C* {# [! w; Q0 b+ J6 E" P
. D6 w% C; t; ^% \; @
if (iedom||document.layers){
6 \9 W' n6 B3 J! n' gwith (document){; l  A. z/ H/ ^( m
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')1 |( }0 d4 Q$ M- o! `
if (iedom){+ p; N5 y7 m# [$ P1 |: m' l1 o) k
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
& C5 C8 M: ]8 J7 Vwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')( l) E1 r! T( B# C; K' f
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
1 \- Z, }" c4 e" e9 q# pwrite('</div>')
5 ]7 O2 A2 v* A}
+ L# b$ y! R3 |else if (document.layers){/ @9 D" M1 S; {
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
2 y3 i. L4 E+ ]3 f' }2 owrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
5 c! b( `( ~9 a" y$ X2 E. Kwrite('</ilayer>')
3 J3 Y, e0 M* p  R+ n* o' D2 D}
8 O( W9 Q; B' Q6 o  e% _document.write('</td></table>')4 \8 e# a1 W- s+ I3 e( C
}5 ?1 T4 w: D2 Z
}
5 i& ]6 D2 K' ?* P</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2