Board logo

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

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

//修改宽度
7 P: F+ p' U5 b( `var marqueewidth=300
5 K% @6 J0 t6 h3 u7 e' f0 q//高度5 B  x- K8 P- L* }; w
var marqueeheight=251 v# b0 e' W2 r1 l; R0 b
//速度(1-10)
0 K3 f) H/ z3 A4 C* @var marqueespeed=3
7 C) O7 b4 e" D//背景颜色: Q+ P) e0 G- J: M- n& O; L2 r4 l
var marqueebgcolor="#FFFFFF"
6 K4 X# t' A- K# J1 q* o" L//是否能暂停 (0=no. 1=yes)?0 t5 \& ?% n) E7 E$ w4 _8 i
var pauseit=1
# b9 L# c5 H6 x' y6 K) s# F$ h1 H" O  A1 F1 o% G9 s9 t
//修改显示内容
7 Z9 S  ~, b3 M+ Z# ]var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>', I3 Z9 M( l* k# R

0 Q) {) ]# p2 X2 u+ x5 W( k8 K( P1 z& ?8 b$ c
////下面不需改变////////////3 ~. R+ n8 h' j8 t9 L
3 |) [2 g0 H3 w; U
var copyspeed=marqueespeed. y6 _7 ^3 O$ s* Y
var pausespeed=(pauseit==0)? copyspeed: 0
! Y1 F1 u+ p* s2 t& \var iedom=document.all||document.getElementById
4 E8 ?, d- ]0 f  d4 k* B' K' P: ?if (iedom)- j# j4 S3 Y! [1 [" |$ j
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')* O" A. D7 S  u! x6 s2 X
var actualwidth=''/ ~9 F, ~, Y% _3 C
var cross_marquee, ns_marquee
: |: Y1 N3 @9 {* l5 v) O
5 }' q( Z) O7 O5 E8 V+ Z) Mfunction populate(){: G! m7 S1 l' G! T4 I# z- n5 G
if (iedom){- i& i  o; H; V1 N7 N! ~
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee% \  X% c; r2 H1 f' i$ l
cross_marquee.style.left=marqueewidth+8* @  }4 \$ p3 l0 S( t
cross_marquee.innerHTML=marqueecontent% m: Q! N1 h% B- ^& m
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth7 X0 I4 n& J  B: [
}
8 T* M+ ^# ]& m% J9 ~; Felse if (document.layers){1 [/ X1 [$ {0 @6 m8 U4 s3 u
ns_marquee=document.ns_marquee.document.ns_marquee2+ E- y; l0 O+ u6 m/ {" [
ns_marquee.left=marqueewidth+8
' V, P: T; |& i. j5 d8 Pns_marquee.document.write(marqueecontent). y# z" z# G# ~% b. T7 W
ns_marquee.document.close()1 |* d. }5 I: h) F$ i, E, N- o
actualwidth=ns_marquee.document.width# n! k: L' I* ?
}0 B1 e7 I# P1 s/ `0 G9 ^
lefttime=setInterval("scrollmarquee()",20)% V6 z+ E( W) t1 h) B
}
( c6 U- q+ l9 N/ R* _window.onload=populate
" [( G- ?0 q! S$ }! ?- R$ J: J. _6 Z
function scrollmarquee(){
* g9 b% C+ i5 g6 D" o& }1 D+ ~if (iedom){
  K8 w1 {7 B8 t, U3 D! Hif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
6 C" D& N/ Z; W2 z. ^2 X' N. V9 k1 {cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed0 c1 |  E7 e& N. ~* a
else) ]: E- M1 [( `2 w9 F6 u  Q; Y! ~- k
cross_marquee.style.left=marqueewidth+8! m3 o* Q3 g& V; j7 f

+ S" M+ u) t: \$ S}
# B) q4 w' Z9 Zelse if (document.layers){
4 I! m' G6 z, A, f1 b" |if (ns_marquee.left>(actualwidth*(-1)+8))
, w) G+ s& H; Jns_marquee.left-=copyspeed. _& s. M; x' r" b2 ]* W% c+ o
else/ m3 [2 s3 o7 h
ns_marquee.left=marqueewidth+8, D- \" F& U% e
}( G5 E1 `2 a& p* @/ ]) }& x3 @. y' p
}9 R- ^# P0 }6 \4 l+ S8 S

7 y4 O" m% A, S7 w# A& c& ?& Pif (iedom||document.layers){: ]* }! A  e' k
with (document){# _$ A$ x/ c$ @; m% e+ ?
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
" j& B$ G: b( r0 Qif (iedom){! [: h+ o) T; q9 l/ B' \
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')9 d4 i. W1 A# y9 s1 j3 k/ z
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
4 \+ a4 a- D% l6 O* Nwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>'): @8 i- O" ~; J: _  [
write('</div>')
) r; D  ~  _2 P  Q5 p}& b2 T- _( {4 b4 d$ e
else if (document.layers){
0 X0 J1 H' V" \7 g$ n& i+ W! _. kwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 u8 Z/ B5 ^0 d$ [5 ]write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
" Z5 k6 a6 n  e- ^. e9 Pwrite('</ilayer>')
6 x- @$ E. u' O# w6 W}
. A: O& \  n, Z/ h  N& Ydocument.write('</td></table>')
& N2 v' `* [" W7 s8 }}: n1 D# B3 P6 ]0 ]
}
8 i3 _4 r; F& ?3 H</script>




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