Board logo

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

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

//修改宽度
& ~( t, z' y5 ?; b' p; s+ ~var marqueewidth=300
( R3 V) L4 J8 A; ?//高度/ s' P2 l4 L8 _: ?- U1 U
var marqueeheight=25* U; N2 n5 Y2 Y$ T% G
//速度(1-10)
7 E, y: y8 F. d7 x0 A7 \$ Tvar marqueespeed=3
9 L; G( M6 k  P3 K# W4 x/ Y//背景颜色* A- I. @' ^5 Y4 Z
var marqueebgcolor="#FFFFFF"3 O2 }. ]) @  P' {
//是否能暂停 (0=no. 1=yes)?% Z- z9 y3 o: y
var pauseit=1
# C3 M/ d* D, Q1 R/ [" o
" L  ?4 {( J0 Z8 h8 X//修改显示内容
% o6 P8 E' ~. g2 X- a1 Jvar marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
7 `4 ?  s+ E5 z- @* ?0 d
( j* }4 A) m; z/ ^  W' |
. R6 ~4 @$ K7 f) K. j9 G////下面不需改变////////////1 f9 e$ H" |. `) {
+ _# R( O6 G5 ~- s, J6 r
var copyspeed=marqueespeed: F" S$ ~- V1 ~7 w/ f
var pausespeed=(pauseit==0)? copyspeed: 0
, A, u8 y0 |2 a: Z+ B; G4 d' [. _. Lvar iedom=document.all||document.getElementById: D' k8 a; W, r: s
if (iedom)/ \+ d  r7 ]$ L: ^5 l
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
4 s1 w- n4 Q6 z  T- H9 G+ t5 Wvar actualwidth=''
. V( \* q7 b; F0 s" l$ @7 }var cross_marquee, ns_marquee
- |' P. N7 V& Q/ D7 n/ n1 W& O1 [9 c
function populate(){# `! V( V/ ^; _" g3 `2 W
if (iedom){& Q5 G7 K/ c! g$ q+ [+ l# ~2 t' h
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee# A' Q8 @5 z8 w7 }8 U
cross_marquee.style.left=marqueewidth+87 t  O" I2 U/ b8 j3 M& g
cross_marquee.innerHTML=marqueecontent
% {  q3 d0 d+ m3 v3 U7 d6 F& pactualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth. W2 t0 W, _  T3 h& m0 @
}8 i( J4 W" O( R0 C- z( D8 @
else if (document.layers){
& d* ^2 c) |# C; l6 y& Fns_marquee=document.ns_marquee.document.ns_marquee2& n! t4 [3 x2 Y- y
ns_marquee.left=marqueewidth+8
" o7 U8 P1 r2 z6 pns_marquee.document.write(marqueecontent)
; c# b& u* `% J8 L) Dns_marquee.document.close()
- t! N3 s+ |5 {4 \. {actualwidth=ns_marquee.document.width* R, Z) o( X7 O' P  K; O* h/ Z% i
}' h" N7 V. m  w4 p
lefttime=setInterval("scrollmarquee()",20), C$ g) |: I4 N
}6 X! V; X* D" ~' ?
window.onload=populate
8 U) f1 ~. ^2 R6 Q+ q
" K3 B9 N& ]% E* yfunction scrollmarquee(){
* ]* H0 e0 Y: uif (iedom){4 B2 O! F  `, G
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
0 P+ J# s7 b& Across_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
' B" E! f7 t7 Pelse
" W% i( Q! Y' @  F: [8 ~- `" {cross_marquee.style.left=marqueewidth+8
! M1 |  b0 n# ~- T4 v' B
# L) u1 f4 r' K% M- I+ G}
/ R5 L/ e2 V: `' @. ~else if (document.layers){
# H; a2 {2 r- p4 Iif (ns_marquee.left>(actualwidth*(-1)+8))
7 h* x- O% ]. T2 r, C  gns_marquee.left-=copyspeed
+ v0 g3 \. d3 _$ x: xelse
0 o$ Y, u: c! `* S( Nns_marquee.left=marqueewidth+8+ G) Z& `" G2 O9 L' \; ]
}* @; A% q: C( D
}$ {( q( D3 E& X- V" H
% r5 }: r9 G, D% M0 q7 ~* W
if (iedom||document.layers){, y- {% Q! F6 h1 U% k, j: P4 T* A1 i
with (document){
0 S# C1 U; a% }; x" [9 Z& Ydocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>'); `& c* J2 j0 l) l" `) L
if (iedom){
+ k# _( F4 g3 C- E) h% h; Zwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
1 ]! M, e# E$ x* \6 F: |write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">'); H' @$ C: X( q' f! u+ O- b: C
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')! \: E' |' ]  i7 M/ j* r
write('</div>')
, t& q3 H. R1 [* h) A2 y0 s}
, Z' s* {+ ^6 W2 U' R7 k% felse if (document.layers){. a% i2 T* |5 \8 ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ ?3 a3 q4 q! B8 |& T2 _write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')$ V/ ^& a  _0 P) X* E# ^& P
write('</ilayer>')* i" }) K6 L, @) q! a/ [0 h
}1 O. ^2 v+ J* q+ N+ t0 ^
document.write('</td></table>')
$ Q+ P  P, }7 ~9 l% a}
; K7 [; \! W, e5 s6 M' ?}
- M! a  ?. b+ B0 p# K" M9 X, z% s</script>




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