标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
+ N B. s1 n' B- f# o: z
var marqueewidth=300
; I( M9 _3 X, T2 T1 l
//高度
4 ^' c2 m; u- p# E
var marqueeheight=25
# g9 q; T7 [, M7 R( X
//速度(1-10)
0 P/ z4 l* A$ T1 X! C: Y3 H
var marqueespeed=3
( q+ \# _- {( k# ^; V/ T3 f
//背景颜色
& R" v c8 D# D0 {4 @
var marqueebgcolor="#FFFFFF"
* y' `4 R6 y. B* }
//是否能暂停 (0=no. 1=yes)?
- U6 [ R# [2 X2 `; Y+ F
var pauseit=1
1 ^2 [+ G" h, \% ] ~$ d& m# o7 n
+ g: t6 w3 \7 k! X9 S
//修改显示内容
& T8 A& j4 ?" y" ? U
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
$ C. [* u. s4 @( d
+ O6 |* X% x3 b2 `, A/ O
2 x& Q4 M7 `; x1 f
////下面不需改变////////////
4 V1 _3 a; e# a+ X5 t- x$ R
& E- \# J* c' m7 h
var copyspeed=marqueespeed
; a+ o2 D% N5 e2 z+ d" a, H( s
var pausespeed=(pauseit==0)? copyspeed: 0
% d! z1 W2 |% b0 x7 h
var iedom=document.all||document.getElementById
5 R) I0 J( _- ~# |
if (iedom)
; g' f' r4 _- R" _
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
$ p Q8 P- ~' _, }: h4 q$ a
var actualwidth=''
T+ ~; |" t6 K
var cross_marquee, ns_marquee
9 v% i8 G! @5 U0 d6 q, E, ~
1 d X8 ?) H6 J* K8 a5 x& L6 Z' c
function populate(){
: t( |0 }. b- t) `- `* m
if (iedom){
( E$ Q% P7 F, `0 Z6 @5 L5 V9 s( }
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& I+ I& E" P* c
cross_marquee.style.left=marqueewidth+8
7 e) I: w- H! f3 Y ^
cross_marquee.innerHTML=marqueecontent
! ?% P$ U3 J8 I9 ~$ P6 ~% f
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
) ^$ C& `3 \( S9 f
}
# j2 m7 z$ @+ ^ V5 n& t/ {3 V
else if (document.layers){
7 w' J3 i8 n( t3 D9 h0 }, y" _
ns_marquee=document.ns_marquee.document.ns_marquee2
- P) ]1 `( X6 H, O
ns_marquee.left=marqueewidth+8
4 }8 n' k' v0 x
ns_marquee.document.write(marqueecontent)
, Q9 ~8 ~) W/ d& X7 v2 P
ns_marquee.document.close()
& k# e5 u0 B P2 }) R
actualwidth=ns_marquee.document.width
2 a& r% d8 N4 N, d
}
3 ]* S; p; K8 N ]) d1 b& F e
lefttime=setInterval("scrollmarquee()",20)
& \: I& c. ~' _$ n
}
& x6 h$ O# l. f! i ^) I2 }
window.onload=populate
+ _0 L% |6 d+ z
" w. z. Y: E; t- D' [5 d& V
function scrollmarquee(){
- A5 K9 C& L# i [
if (iedom){
* A4 Z! u3 K) W, T
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
8 t, W$ C7 l( g2 m9 q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
: c E9 i9 C' _* R7 a2 n; o1 ]
else
G( y, Q; M5 h( x6 |8 U4 _7 e
cross_marquee.style.left=marqueewidth+8
8 Z: K$ o6 C, o3 G- A2 \+ D: t
6 Y/ h0 l% W% M- b/ d! J( |( h3 I
}
' ]3 S' v; Y& ?) R9 |: o
else if (document.layers){
4 }8 q0 n% v) [5 w5 Z; _/ X& g5 P
if (ns_marquee.left>(actualwidth*(-1)+8))
" ?& g* C P( {+ w" `1 C
ns_marquee.left-=copyspeed
+ }5 Q) J) v+ R4 ^$ }
else
- U4 e4 A/ X# Z; u9 j" R4 W3 r
ns_marquee.left=marqueewidth+8
6 k7 m( X. M4 F( m6 \2 q# U$ U
}
2 U0 @$ y: ~' V6 G% V' U, b
}
7 w- I5 }) {* B, A: y
5 z* {7 f( c& r& Z( m
if (iedom||document.layers){
% i1 @* H$ e8 |4 ^. ~. a2 T
with (document){
. G7 l! q/ ^1 X6 A$ Q- A
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
$ o0 T0 _% }' k' ~3 @3 h
if (iedom){
9 E. i: w ^" s) C3 I. V/ N& l
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
5 W5 k8 c/ U9 y
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
3 }% w+ i( k$ f7 S' l' r
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
6 I" ]3 b* A9 O1 h' D$ }: z
write('</div>')
+ ]3 m; ]0 e. B
}
6 X6 b7 _2 A* ~* T& N& z
else if (document.layers){
2 t- H- M3 q: t- J6 `, ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
' X% A# W B" B2 p, T
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
7 M$ ^* F' j1 A: Y3 D$ o
write('</ilayer>')
5 F: A `4 C7 `# V4 o
}
0 p! C. { {. l# }8 f
document.write('</td></table>')
a. B5 p( u( y0 g+ d
}
; i+ Z" M2 \) W" O- x8 K
}
) ]! {$ @4 u. f+ U3 K9 u1 E
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2