Board logo

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

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

//修改宽度, a3 r1 o  {3 P' S
var marqueewidth=300
$ i0 d9 j. x$ j: m7 X5 t. v//高度
& d& M+ E+ |4 L. x4 jvar marqueeheight=25
: s  t4 s! F! c/ c" G' H6 s1 A+ k//速度(1-10)
: R8 W; C1 ?4 b# j% L2 gvar marqueespeed=3
# h4 C) l  t1 t3 R& V2 o//背景颜色
: G- ^5 d4 Z9 z" B2 M  i5 l/ Evar marqueebgcolor="#FFFFFF"7 C3 b  j* i! [" x; Q0 {6 F9 D
//是否能暂停 (0=no. 1=yes)?
, D% }! J2 [+ [  y, u* Pvar pauseit=1" n' ^6 m4 S2 O
, {. }" o0 t& i
//修改显示内容
& Y1 s( h( ]  T8 T" ^, qvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'9 z& }+ F& B6 o/ k9 b
4 c2 Y: Q" y' d  @" H% W7 w

! H& f; i) M6 D0 Y: Q////下面不需改变////////////1 O% m* \, R8 P$ u
! h" q( [& Q3 S# {1 h2 c6 M. W9 V
var copyspeed=marqueespeed
9 p( X% a% {+ n& G9 h( b# qvar pausespeed=(pauseit==0)? copyspeed: 0
* z* V2 X7 `/ l9 gvar iedom=document.all||document.getElementById- R# L% y# ^7 }+ i0 D
if (iedom)5 N9 i6 M5 ^$ S8 j4 {4 y0 \
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')9 \& M( P# E+ X) I. [  ^% |
var actualwidth=''
' J  X6 k5 p8 Zvar cross_marquee, ns_marquee, ?/ T) c8 Y# f( F" H
% v; e. T0 W; @2 F  Y
function populate(){6 [: u# h7 v( X2 x9 ?; [
if (iedom){
3 Z0 Q: J) X6 A. b$ ^3 {cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 I! z- U; D# a# Ecross_marquee.style.left=marqueewidth+87 \' ~+ w- i0 t7 P+ t0 D, Q# @
cross_marquee.innerHTML=marqueecontent: [" G/ y: {" m* B
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
8 |" k6 w' g4 P# h& F6 Y9 Q}, ~: u1 q! Y# Y, o, M
else if (document.layers){
  ^  z9 R. p* `- Q: xns_marquee=document.ns_marquee.document.ns_marquee27 k5 _  M4 I+ L
ns_marquee.left=marqueewidth+8
' P( m% _9 L- B8 k: ~4 W4 |' s, {' l: ons_marquee.document.write(marqueecontent)
& Q3 Q" p  Y- l' t. uns_marquee.document.close()3 P" O, ?9 i! Q* ^; @
actualwidth=ns_marquee.document.width* |* k8 l- `2 Z  [3 R
}+ r* A6 f' X7 `/ N/ h& t, h9 f
lefttime=setInterval("scrollmarquee()",20)
0 {, A2 \1 F- M5 e7 P}2 R: O% J: N0 ^  l  {" O2 Q
window.onload=populate
/ [7 }2 }' _0 P% s5 i8 F+ r5 @0 L- F/ F) F
function scrollmarquee(){
" V) R" Y  t# e* i* L; bif (iedom){6 I6 z! T4 s  |4 b( F% a* v
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
5 |$ Q8 b! E' ~! N$ S# Scross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed6 j. \3 D9 _6 s0 D6 a
else9 V& c' e( A! d2 h+ P5 e! f/ f
cross_marquee.style.left=marqueewidth+8, p$ ?( t; w& ^0 C* {% v$ N

$ K, K' K; [5 {$ M* J. x}0 H% B: `. ^. c7 N& ]
else if (document.layers){
7 }. u  P1 ?1 y5 T/ H; x- ]% ]2 hif (ns_marquee.left>(actualwidth*(-1)+8))8 i; ]1 c0 a; n4 X3 }+ O% h
ns_marquee.left-=copyspeed: }% L7 m- ?$ C% S% W
else: r$ c' y6 }; e; w) a7 C
ns_marquee.left=marqueewidth+8. o, F% F9 d$ R
}
" x" |. S7 f) e0 A}' z5 w! Z- m; H2 P: U7 H$ r' E

3 O: J7 m8 {9 D  mif (iedom||document.layers){- k! q% H7 f' `7 ?+ w
with (document){
% [! P& k3 b+ G$ S1 qdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
7 Z% N% A8 M8 \+ x# fif (iedom){
( [9 O; l4 Y+ U8 h: Dwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')$ S3 \. c3 v! B6 K/ \% W) A0 h
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
& `( A! Q0 r9 n7 G2 [write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
; y/ Y7 E9 H  ?2 J. c% Nwrite('</div>'): w) d  {( l' N
}
# G0 _! v3 z2 N. Z! M  z+ Pelse if (document.layers){
- u. p4 f4 _9 q; j& W5 Nwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
: a. |! U* r7 e, H. lwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
3 y& {5 L; H/ Q8 y" ?write('</ilayer>')2 |: G# G+ V: H7 l. p
}
+ w" g& N0 q' tdocument.write('</td></table>')) n' P+ G2 t. m4 R' J) Z  f4 }
}
* X" f) i7 T3 C& e3 M}  s4 W$ J) C: y# K. x. P9 }3 N
</script>




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