标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
8 o. u; K6 k. m& [
var marqueewidth=300
+ P- g+ a/ U- j( k. Z
//高度
" u- W. i" X# ~+ H4 d; m
var marqueeheight=25
0 r/ L* v L7 }! u! ]# @
//速度(1-10)
0 `- D( c4 v v+ ?
var marqueespeed=3
7 X) c9 b. f8 o; `. m- l% ^! ^
//背景颜色
. f; F$ e9 |3 p" \1 |( C% e
var marqueebgcolor="#FFFFFF"
5 x$ E0 F( ^ X: C+ Y& m- F% ]* N+ p
//是否能暂停 (0=no. 1=yes)?
! e+ i2 p0 X1 r! K2 n
var pauseit=1
! f0 k& o0 z$ D/ h6 |# I1 V
4 p% w F4 m& S% G, U* i* y3 k: k
//修改显示内容
6 C9 H5 b6 u0 c3 v
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
+ Q# N/ f0 B4 ?
5 [% s) k+ ]0 G0 {
; L- `8 n7 i" ^* w( a
////下面不需改变////////////
- h$ F- I1 b) l
$ O1 Q/ i) e1 q
var copyspeed=marqueespeed
8 c' P0 V) u* m3 E3 L4 ?$ C0 X
var pausespeed=(pauseit==0)? copyspeed: 0
/ _2 }/ ?& k6 t* W& q
var iedom=document.all||document.getElementById
% Z, ]6 {& i* H
if (iedom)
3 F3 p# J/ ?# V7 K
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
( e5 B* ~+ r, @: P+ l7 r- |
var actualwidth=''
- L# }% |) r# A. {: _" |! M
var cross_marquee, ns_marquee
) k4 v" I7 U3 H
& o+ w1 y& U4 q7 l, A
function populate(){
0 a5 L& e0 Q9 p7 F2 y
if (iedom){
# T9 K3 M& B+ F, x/ s( h
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
% w& a3 r" U/ J' u- q1 ~1 r
cross_marquee.style.left=marqueewidth+8
! n' h/ d' a7 f& d: `
cross_marquee.innerHTML=marqueecontent
: P9 C/ T% L/ m/ X% W5 i
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
6 a" G* a) Y; {
}
, q0 c G. W. t: v1 [
else if (document.layers){
0 x& b7 o7 d/ Z* l9 `
ns_marquee=document.ns_marquee.document.ns_marquee2
4 r2 k! n2 S4 C# {4 j
ns_marquee.left=marqueewidth+8
, z: h4 u% F1 c3 ?; Q4 v6 z5 J$ T$ E( ?
ns_marquee.document.write(marqueecontent)
7 O6 H: s, {5 ^ @6 r
ns_marquee.document.close()
0 n8 `5 X1 g/ _. w
actualwidth=ns_marquee.document.width
8 }/ y" M. p- p3 @+ E
}
1 T; |, L: n" Y% E1 a5 v$ w
lefttime=setInterval("scrollmarquee()",20)
. F, b3 ^+ r# n+ f L5 y
}
# H( ~! z% A3 t6 t
window.onload=populate
1 ], k1 |; W I k
5 d* ]" C3 h9 z
function scrollmarquee(){
% ^) {- [ U7 b6 ]* ^
if (iedom){
! s& E) y) S0 ~6 X' a0 z0 G
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
4 R4 ^% {- M0 q
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ i' n, n( j7 [8 B( h- h5 c- ?
else
Y$ m6 r% E- v3 @ @* P! }
cross_marquee.style.left=marqueewidth+8
1 R& Q$ r( E! c* z. ]" V
~. d4 Q( m3 d4 w1 S; x1 T% e
}
( ^. R& k8 k% I% W
else if (document.layers){
2 J! X1 x8 }; P5 v- ~' o3 m( t
if (ns_marquee.left>(actualwidth*(-1)+8))
* R+ d' |* E# U
ns_marquee.left-=copyspeed
0 h+ r" Y$ ` j8 h: K( k
else
% Z" l1 \- Q/ Q$ e* L( h
ns_marquee.left=marqueewidth+8
7 |$ p! |, i" B
}
# L. |5 `7 d# C4 Y' h/ ]$ e9 T
}
1 C! B' u. b8 a. p
+ C S P: J9 N- Y# B1 m
if (iedom||document.layers){
2 q0 x/ v( g6 \. Y' C! U5 t/ K
with (document){
4 e/ G: w0 x1 ?, i. x
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
8 I F4 [: @4 Z4 d
if (iedom){
+ `) _! O2 W9 B* F0 c5 f
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
" ?! l& [; A j/ V
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
; }/ R& K& o+ E" `
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
4 ^$ s% x* Z u$ ^: v! i9 R) D* C
write('</div>')
# W( D8 X: R, C1 L& X- O7 q
}
6 Q( E2 q# S6 ~& ^/ U; @
else if (document.layers){
1 |( B* M6 `! u2 ~: i( r: c
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
# z1 I+ E n8 x+ ^
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
2 b t a* D8 e J( c
write('</ilayer>')
; t; b+ U1 Q- q, q
}
$ R7 L& X& E, ~2 T
document.write('</td></table>')
. q1 e U+ s4 `6 Z% N* d
}
: [" o5 ~9 {0 w/ `
}
0 `0 C c* c" \/ {9 @/ a3 a
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2