Board logo

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

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

//修改宽度4 j* Q5 v# {* d, x8 `7 ]5 V; \2 d
var marqueewidth=3008 ]* A/ y" V) l. Z& |
//高度
1 l8 Z2 I& J6 f# q, w: jvar marqueeheight=25
" S1 X' W+ R: r" T. f8 ?//速度(1-10)
: ?9 x( D; g5 i1 s) B) {7 B; l7 Hvar marqueespeed=3
& ?( q9 |" e8 i1 e. w0 e//背景颜色! S* B1 x5 M0 k# v( E
var marqueebgcolor="#FFFFFF"
% }+ I% p8 f  [6 U//是否能暂停 (0=no. 1=yes)?5 V' @: q2 B/ i; V
var pauseit=1/ k5 S4 ~; C9 b9 c5 o8 l

' u$ `6 p- h$ |. l//修改显示内容
; `# @$ L2 W. f( d3 G6 ^var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>', n; `) P( O# Q, j8 F2 u& ^

1 q4 H5 U. H' l) l* j  l4 W
- Q" V9 S6 R( @' V////下面不需改变////////////2 _, e% k9 N# I7 D" P2 _6 u+ y

" F% @! M4 k- w. [3 E7 l! M+ cvar copyspeed=marqueespeed: L$ J& i" a3 X3 @& d% y5 U' x3 m2 p
var pausespeed=(pauseit==0)? copyspeed: 0  E" e1 m' I. e* S% ^7 X
var iedom=document.all||document.getElementById$ A: v; Q# I; a( z( d
if (iedom)  p- @, W& t* V
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
" R4 u0 r* o( ~  [6 Avar actualwidth=''6 G# y" Q9 h" J, u$ a
var cross_marquee, ns_marquee7 e" J' Z" f# n3 U2 q3 {

/ G3 ~& h& h! F! H4 F+ tfunction populate(){
8 |# }8 S( x9 l; `1 G  Tif (iedom){
' }* }+ m9 |/ R/ Q# `1 J# hcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee( P* @1 E. h* s3 w% E) U4 j+ S2 s
cross_marquee.style.left=marqueewidth+8" {4 A. a2 x+ X) i' m3 B7 e
cross_marquee.innerHTML=marqueecontent. b" c$ x; T1 \& g; m, k) @
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth! a% e  `- A/ \0 U! K
}
8 `0 j" g0 v- }7 E; {3 velse if (document.layers){
7 w8 D- T& w  `9 |" j& Hns_marquee=document.ns_marquee.document.ns_marquee20 r/ M. ]$ o4 W% s
ns_marquee.left=marqueewidth+8  P, w) r, P# K( |0 Z2 N  G! T% k
ns_marquee.document.write(marqueecontent)
8 T' z) z, ^0 T4 D' lns_marquee.document.close()
! J" O( R+ T) Xactualwidth=ns_marquee.document.width2 ?; ]) E& }0 y* ^' G
}% M: G3 x3 ~4 J# r
lefttime=setInterval("scrollmarquee()",20)& i  w5 V# X- f: x) f
}: j, ]0 x7 n9 h
window.onload=populate; [9 p5 x6 i$ E. V
" j" l  K/ z: v) @; |  }6 F
function scrollmarquee(){' c, M9 h, w: W2 O* d
if (iedom){' N3 _- d- a4 n! h8 y8 z3 O
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
3 N, T+ v) w+ A  Pcross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed9 D( Z3 U# q  }' K7 T5 g
else5 @9 g6 y1 J6 |# T0 _' |
cross_marquee.style.left=marqueewidth+8  A; g+ F/ m7 U) n
: k8 N. u+ c/ U1 v
}
) D) Y2 k1 j! r# d2 V) |3 kelse if (document.layers){
9 q; f5 x" t2 ~, e0 Oif (ns_marquee.left>(actualwidth*(-1)+8))' W: z! ?5 t( }, {* z* i
ns_marquee.left-=copyspeed( {. p! \5 A) H* j, q5 q; X
else
6 n. ~/ F4 X; c% v% Xns_marquee.left=marqueewidth+8
; p& J7 m, ?1 g4 d# M" @}1 C4 H2 f- |& f% Q
}
0 z& L. o1 X$ }  `$ o( u
6 r  ], E  x- R3 H! Zif (iedom||document.layers){
& ?3 N7 v: N4 @& Y. @with (document){
9 N7 I" g, C% D) ~6 R# cdocument.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
' t" u$ W8 W, }* f/ r( O2 Dif (iedom){
. P: k# O6 x8 a1 M# s4 kwrite('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')4 z* i4 X" K8 X! D/ c
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% ~! A) m/ \, l* `* E1 I; t  cwrite('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')# G3 y. C/ s1 _2 |, {
write('</div>')# I' r8 G  U: u- z% E* {6 V
}7 k' l1 d- Q- T, a9 m
else if (document.layers){
7 E3 Y# T% a3 x* w' N# U. y; V$ Cwrite('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')! k/ y/ s; ^2 u$ p' Z1 \* |
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')8 w9 Z# w# I$ h+ O
write('</ilayer>')  {0 K, B) K- |1 B  W
}5 M( j: c" g! w, p, s7 Q" m
document.write('</td></table>')5 Z! r# V1 h, k' v
}
1 P1 E. k* W9 F( ~  ^7 g& t}
" H0 ~9 j0 e9 }4 _: R6 F</script>




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