Board logo

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

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

//修改宽度" ~0 F$ m* j' B( w; H! U
var marqueewidth=300
# s5 R# _! U: d& M//高度% s* O3 t1 `: j& S5 @
var marqueeheight=25! s1 q; G9 E; ?# W& }, }7 [" ]
//速度(1-10)2 V, Y) y3 s* q* y6 v- W# \0 F6 l
var marqueespeed=31 Q+ |: R6 Q0 F: G
//背景颜色
9 u9 D+ t9 V+ J" ]var marqueebgcolor="#FFFFFF"( f; t5 S1 E& m1 E: A
//是否能暂停 (0=no. 1=yes)?
' }5 P, {/ r$ b& F7 s5 D$ Ivar pauseit=1# X! }: h8 f( M

$ n! `6 e, `  q//修改显示内容( g/ V1 k$ p' a; d
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'2 i1 Y5 O, I3 ^: c
+ @# k' @% b; z

; n, e" l, F4 A* l////下面不需改变////////////7 V' |) M  e" Z
: D) `5 _% L5 c. X: g/ L
var copyspeed=marqueespeed" v  j& v6 f2 N. U
var pausespeed=(pauseit==0)? copyspeed: 0
+ n% V6 p+ n, E! J6 j8 t$ F8 pvar iedom=document.all||document.getElementById
* D, D- K' m( Q* W6 Vif (iedom)3 h# ~' ?7 r# _$ g
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')$ n! _0 T: V( Z9 Q  b
var actualwidth=''4 U8 O9 h( W- t0 B+ ]
var cross_marquee, ns_marquee3 `" A+ ]2 ?# r& @: u1 |
/ v# X/ T6 Y' A/ J) h! F
function populate(){
) i/ x1 `( T& l0 k1 h7 kif (iedom){) y3 ?7 z5 B1 w
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee5 h$ K" _# Y4 Z3 [* }
cross_marquee.style.left=marqueewidth+87 L/ z7 O: [/ a) a% H
cross_marquee.innerHTML=marqueecontent% r9 c9 b8 f0 u" c
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth5 _. b6 L7 H- ^2 ^* \
}
8 n% k& ?& i3 y$ N# F# `else if (document.layers){
0 `% T2 n) ?/ P$ D4 \; mns_marquee=document.ns_marquee.document.ns_marquee27 \) ~, I" m  l; a
ns_marquee.left=marqueewidth+84 L9 r. }* r& `* ~
ns_marquee.document.write(marqueecontent)
/ W# A' s; G: B$ H& b: Bns_marquee.document.close(); W4 l0 ~. I8 s1 H1 }- e
actualwidth=ns_marquee.document.width
" M+ x2 O+ |- T8 _}) _$ T9 }; P9 J& b) ]" M
lefttime=setInterval("scrollmarquee()",20)" O/ g! L5 y6 A9 o
}
+ E3 J# }( B  l! {: K1 g  Cwindow.onload=populate& a6 a7 \1 ^4 P$ {. {
* d7 a! V- M4 \  g& `
function scrollmarquee(){
3 A2 D. H& d4 ~" b' f" tif (iedom){
( |' F; i$ n+ |+ n- P: u& o) w: }2 d& xif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 F# J, y, l& gcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
: D  o: t5 |: A: _9 W. ]else  X% @) K$ F; w' N
cross_marquee.style.left=marqueewidth+8
. f1 W3 K) S. Y1 j* ~1 l# D  a; }5 i% R6 o, @3 a
}
. I! f8 U# X0 F, I: uelse if (document.layers){
5 X1 T$ i) c+ {# r3 ]! p$ P9 \9 sif (ns_marquee.left>(actualwidth*(-1)+8))
( j, ^" A" T  G/ A7 x$ ^, Xns_marquee.left-=copyspeed/ Z+ ^( j, @/ q# A  t
else$ U4 M5 k1 J- F# O7 {9 F
ns_marquee.left=marqueewidth+8, x5 l$ x* @$ [3 ^3 M( V
}0 X! z9 ^0 c7 ]' N0 A- k
}
9 V- G5 O, I1 n8 q1 o" ]  u2 k( C, p) R* l; Q( {* Q1 I8 j/ ^3 E
if (iedom||document.layers){
. b8 m, ]( p% r3 b, }with (document){
  p1 S) h7 A1 H4 a% Adocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
. o* H  i/ |; S$ i% k% R7 V4 lif (iedom){
' v2 J- d* t6 }, y4 [( o2 [write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
% D# t6 O3 X4 S% Owrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')6 D  V5 c$ J6 ~7 d* \  r
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
7 v# e% G/ L* `0 s! q: l& P! p7 ?write('</div>')
- ^6 N7 W' D' h! k6 ]' w3 t}1 w: V6 N  e' L4 I
else if (document.layers){/ R# N  _: _, H; ], \" R/ k7 C
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
4 [: ?+ E5 d4 P1 ~1 @write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')% s* P  _9 @& _
write('</ilayer>')
% z( m0 B1 Z  r0 p}+ w% J! C( N# \  \* I1 A: d
document.write('</td></table>')
0 B7 u& V- ]# W' X}. G- m* O* N5 q7 r4 r% F
}
8 }& D& E/ i, {1 A0 Q</script>




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