Board logo

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

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

//修改宽度
# [4 Y1 k. ~2 Cvar marqueewidth=3000 ?0 c1 q" S4 D! q) h
//高度6 Z8 Y2 ^* H( x6 e; t- @
var marqueeheight=255 M# S1 x5 D5 W, s3 c- J
//速度(1-10)
; q2 n( ]5 y9 t4 gvar marqueespeed=3( O3 i6 n5 G# Q! x) A" o8 F
//背景颜色
, S0 g, L0 a1 @var marqueebgcolor="#FFFFFF"9 Z* `3 ~4 A7 P; I8 }' I5 m
//是否能暂停 (0=no. 1=yes)?# u8 J) t+ _. l1 S, {, u
var pauseit=1- w' L1 W* L$ G7 z* T

/ \3 O7 l- a* C1 ~* f: U' |1 L//修改显示内容
3 p& _# n+ J4 x$ u" M/ W6 y6 Xvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'4 V% t/ t, G/ _# K

! c4 H! {) Y! V! G- l$ N4 S4 T* t- ?" R
////下面不需改变////////////
! R, N2 H* g" [; X& L; }
0 Y6 n7 K0 \5 |4 Wvar copyspeed=marqueespeed
6 M7 `; f) p: d$ F9 ~% K9 O/ mvar pausespeed=(pauseit==0)? copyspeed: 0
- e$ z* @$ y9 t) b" d, svar iedom=document.all||document.getElementById
( G; H! {+ |! q. z+ Qif (iedom)
) O$ c  n# @% j% H6 Ldocument.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')- N/ \- j% M1 ?' W# u) h
var actualwidth=''8 {) b4 d5 u4 Q. V$ h  P
var cross_marquee, ns_marquee8 T+ b0 q1 a  |
. R$ h' o' y0 L& h' N* T
function populate(){; d# J7 O9 L6 Y" t5 Q; g/ T
if (iedom){
% N9 }, K9 V8 C. B1 _/ w0 Wcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
( r) R0 E. M: D& a' o$ f5 Rcross_marquee.style.left=marqueewidth+88 U6 \6 c9 `2 K, j, N3 n
cross_marquee.innerHTML=marqueecontent$ ?# G2 G: K  r- {
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth0 A2 `2 b" H1 g" t& s9 r* h5 f4 a
}
0 w$ \! b: e& I7 }else if (document.layers){! y$ m; X5 L- d' B" p+ v" K
ns_marquee=document.ns_marquee.document.ns_marquee2+ d/ T$ ?; W7 a5 X3 A6 j; E0 @
ns_marquee.left=marqueewidth+8! j* r) q& g; D
ns_marquee.document.write(marqueecontent)
3 ?! `0 H3 v3 [; @. b1 c/ pns_marquee.document.close()/ s) l: X  T* v6 |/ ]2 E
actualwidth=ns_marquee.document.width
8 R9 Q; [6 z% l; d8 E  z}4 ^1 C& u. \% V5 z
lefttime=setInterval("scrollmarquee()",20)6 I% k* n- Y1 Q3 b
}
* X; R3 ?0 L9 v, W/ U7 W4 ewindow.onload=populate( k7 N/ w+ J1 Y
9 G) t( u% S  q+ x* h- c+ s" i3 j
function scrollmarquee(){
. b, `9 x. D9 O0 s* S6 Pif (iedom){
' m. z" Y: [; b0 C4 f' _if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
' i1 N& z2 O) ^! w' rcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
0 x6 W" t1 X7 r9 velse/ t0 }* X( r1 P1 h
cross_marquee.style.left=marqueewidth+8$ u! [  [. h+ M, |6 r+ ~

" D* q3 P0 V+ K0 F/ {- b  f1 ?}8 n6 C$ y9 K2 E6 G) j; N
else if (document.layers){: {% D8 r& z, G; g$ ^0 g  j
if (ns_marquee.left>(actualwidth*(-1)+8))$ V& _: T4 _, f& B+ n3 Q( `
ns_marquee.left-=copyspeed! M1 _" |0 [0 p6 `$ k9 J. i
else
+ p- Z+ p, l$ @( _3 Hns_marquee.left=marqueewidth+8
# P0 @1 h9 h% I. g+ I. n8 O}: N' R3 f, h8 z+ l
}" o4 A5 |3 }  X
. }# T* Y: N: b. J
if (iedom||document.layers){
+ I0 J7 s: j! N# |! H6 r4 _with (document){
8 e% @5 z) _, `( {) n9 edocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
9 ^4 ]7 s1 O; d3 s7 pif (iedom){: V0 x3 b) ~; q7 c% g9 E
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
- O/ C3 Q0 v! D" R' l$ Twrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">'): D/ E0 Q! L1 l- f; S) t
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
  j6 i3 m( s- D1 X0 s- i& gwrite('</div>')  }; X) Q6 L' n- F- }0 J9 P+ H+ U
}2 f: O2 D" b  f& ?  x5 n2 _
else if (document.layers){. H; c) Q" `+ d2 |$ \, O
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
6 [/ N( R  A9 z, Xwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')- v- I5 H9 }* `' `$ l2 ^1 @9 Z
write('</ilayer>')
3 F# c5 u  }7 y! X}
- B1 ?% C" p4 a$ W1 v4 z5 idocument.write('</td></table>')9 \, z! W( p6 U. n( J
}
% }# N3 [. a% l2 U6 k) T) G, W}
9 [5 e$ B( g% y- K7 Y- r# b</script>




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