Board logo

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

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

//修改宽度' |5 O9 @* h& A; p% P6 _% Q: ~) [
var marqueewidth=300
/ X* W7 ]4 T! D8 h//高度: z/ A6 h; E1 n
var marqueeheight=255 J2 |0 z) c4 P0 u
//速度(1-10)
7 ]0 k: r5 |, Zvar marqueespeed=30 X, r" @$ O9 u/ Z$ D" ]
//背景颜色9 u2 T9 u9 H, j  q  u) B- g
var marqueebgcolor="#FFFFFF"
  Q8 ~+ {* v6 g* d1 ?//是否能暂停 (0=no. 1=yes)?5 B! ?1 S* A- `8 s" q; v
var pauseit=1
# {* W  M( {9 j* j$ {" a, J  \4 Z0 z
//修改显示内容/ X$ k% f, i1 A4 z
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'- A3 `0 K4 x! K$ ~+ o, d5 `
2 Y8 o& L' _$ M. F5 T

4 I# E5 ^+ I  H1 L! f5 @////下面不需改变////////////
: ]6 C$ I! W6 l$ N" s: F: V( w& t& k, F
var copyspeed=marqueespeed7 c- w( A1 e/ s4 g9 f& i4 J: U2 g
var pausespeed=(pauseit==0)? copyspeed: 0# @+ O) V! h$ I4 ], n- \7 i2 I9 G
var iedom=document.all||document.getElementById
  f. M3 h0 j3 H+ kif (iedom)/ [0 u* d& J  p
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
+ [6 ]# ?. w7 ~# j" h' zvar actualwidth=''
6 {6 T! ?# M) b9 jvar cross_marquee, ns_marquee; l0 j3 |7 Z6 D
! E; C+ R  D. l
function populate(){  E- ?0 R& p# a! R& [7 [
if (iedom){( U) q: h) g+ d: V$ Y/ w+ T, D) t
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee0 E; S; v1 S% o- o) R' |
cross_marquee.style.left=marqueewidth+8
3 |9 n7 k; O/ {cross_marquee.innerHTML=marqueecontent
/ g9 Z  C0 f5 p, s3 x& bactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth- v5 G' b1 J# G* ^+ C
}
( h! q1 q3 G4 i+ S& uelse if (document.layers){
# C' K! ~! E% o# |ns_marquee=document.ns_marquee.document.ns_marquee2
& u; _' z; n- D( D9 }4 J; fns_marquee.left=marqueewidth+8! f+ q+ r  d( m
ns_marquee.document.write(marqueecontent). E( e- Q1 L- C4 O8 u( _# Z
ns_marquee.document.close()" V+ t7 w! _8 ~- L" r, D! j
actualwidth=ns_marquee.document.width
. Z' u7 \/ @3 v8 u; c}: Q: _' F- P7 [9 H+ [  l) L
lefttime=setInterval("scrollmarquee()",20)
1 j% Z& R# F9 \7 l1 p}
* U" n1 _! }$ \2 t4 s% _3 uwindow.onload=populate# O" d, l0 P: p- \7 Z  X

& c1 K. i# ]) Sfunction scrollmarquee(){
4 i2 T$ L+ n4 a8 O( pif (iedom){- ]4 H# i9 h1 q1 J
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))( i, ~$ r' f  Z( ?5 B; w7 c* Q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
4 L( R2 N$ g" W6 u  G3 ~7 Pelse( x( o( [% z, {- Q# T: u7 B& a/ q3 V
cross_marquee.style.left=marqueewidth+8
6 U" W  [7 `7 f8 A/ N
  _% J6 B7 y! J; d/ h}/ }2 F4 o/ Z3 ~) ]$ _& V
else if (document.layers){
& ~4 T- e/ I. r; }if (ns_marquee.left>(actualwidth*(-1)+8))
; Y/ V8 n; O. Q8 F! ^: {$ T  F# N( Ons_marquee.left-=copyspeed+ r. ?$ [2 L% a. w" i6 p
else
# `, B5 q/ _% v9 f9 Ons_marquee.left=marqueewidth+8  \. s2 d2 X+ n+ t8 l( q
}% e# |6 X& T; B7 Z! H5 S$ `  N1 q
}
; U  K2 N6 H2 U& @9 T0 I6 P
# _( y$ B1 f9 E3 n: V9 c# R( W1 Dif (iedom||document.layers){' _( E3 h2 L- g1 ~% n; H
with (document){
! q& l& P6 A; m1 l! ^document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
. L* K' I1 ]* w2 e9 a% Pif (iedom){
7 e, @8 I6 i; |8 C. G0 v! @0 ywrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
- e( l4 k/ s5 u4 Y0 Owrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
' C! R- c. u7 Q1 cwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
# \) ^3 ?; X( S  O! O6 dwrite('</div>'), W2 C. T8 ]4 L& y) y8 l) O
}6 Y& z4 O+ T. C) Q3 f& u9 T
else if (document.layers){
- c- Q  S: O& B* ewrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
5 L- G* y# F) z( B$ B* Y/ t$ Qwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
0 M5 @5 Z5 o$ Q8 K( h+ P$ {/ e* Cwrite('</ilayer>')  C/ T  v6 Q6 G+ O
}4 Z6 t. g$ r1 M# [
document.write('</td></table>')* @( [. N) I+ r  P
}
: c2 B- N6 s, _! [# h& Z}* f/ n# h7 }4 x3 P0 k$ y: R
</script>




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