标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
$ A1 C {% Z8 e! C- I& ?
var marqueewidth=300
) k; T# H) Q* N, R& p5 h& ^
//高度
% \6 r" I+ s9 w* {5 V* u
var marqueeheight=25
8 s2 {% v3 H; o, Y+ ~5 f
//速度(1-10)
, ?9 |( \9 x4 s f
var marqueespeed=3
4 }( ~/ x0 _- K) d( g
//背景颜色
( o2 _9 A: o! v: u( F
var marqueebgcolor="#FFFFFF"
/ @9 n/ r v7 n$ @2 o: l4 D
//是否能暂停 (0=no. 1=yes)?
1 n0 i; G% V; g2 M/ {
var pauseit=1
6 U- T1 v% J* }' }7 K( w
+ ~2 u- _* o/ b' V) D
//修改显示内容
+ x; E5 m2 ?& [ t7 K* g
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
1 [* h# G5 {/ D1 R! Y% j4 T+ o
. J0 W: ~2 D/ d* H, U) J. t
* P$ [5 X- t0 K3 v! E! P6 ^5 [
////下面不需改变////////////
0 a& ^# L9 r" V6 E& Q9 r$ B; z- \
$ u8 p( [: ~' c1 _1 m: g, @
var copyspeed=marqueespeed
0 I4 b, I# }% Z* a' E8 O
var pausespeed=(pauseit==0)? copyspeed: 0
% j/ X4 }5 B7 q$ ]" R/ B
var iedom=document.all||document.getElementById
; y9 H* X* w h+ g3 f8 H
if (iedom)
* w+ [( I- \; S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& S& T/ B/ h8 Q8 V# V. z. C
var actualwidth=''
5 w$ z" H1 j+ V# X5 s/ I( h, |/ c6 ]. V
var cross_marquee, ns_marquee
6 I$ i/ S% O- C6 Y* r$ Y
" O/ N4 D; H- I. m6 D* b1 k
function populate(){
% y7 y$ }2 a8 ?' E
if (iedom){
# @6 X) Y0 A1 q! [$ \ L
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
# [& w: n4 c# |% |3 O- T
cross_marquee.style.left=marqueewidth+8
3 h9 W) U7 ~ X3 Y, _ M# v
cross_marquee.innerHTML=marqueecontent
2 T7 V, n, s5 N8 z/ f4 R, g+ h
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' U( h4 H8 z) p8 g9 M- e1 l0 ?
}
, [7 x% Y4 s4 r
else if (document.layers){
! E; k$ _- Q) C" d L
ns_marquee=document.ns_marquee.document.ns_marquee2
. v0 ^8 Z: O& D/ I9 V3 E2 }
ns_marquee.left=marqueewidth+8
n6 r& S- D, X+ h& `$ t* k
ns_marquee.document.write(marqueecontent)
$ @7 k" f E% Y8 a% e; r1 k
ns_marquee.document.close()
7 \) c- @6 q: l& ~% O4 |2 T7 a
actualwidth=ns_marquee.document.width
4 J) V2 ~* y! ]. N
}
# M4 t, g" C% b& Z' I
lefttime=setInterval("scrollmarquee()",20)
o% _! V# ^4 q5 ], q1 |4 ~1 R: C
}
; R+ T* u2 `# _$ J8 _! {
window.onload=populate
) D# m3 z A& C5 t
+ y2 u& k. r( T: k+ H; E& F* V' |
function scrollmarquee(){
- W3 F1 }, C& b+ n5 L+ n7 G1 I
if (iedom){
4 ?- O2 {( H" d s, V5 I/ P
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* q4 A8 M2 z" R
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
2 K. W; V2 Q# w9 q
else
) I; n$ j F5 W+ @6 l
cross_marquee.style.left=marqueewidth+8
5 J. f, H/ a8 I; M
8 b+ Q' T& d" O
}
4 h/ U7 i8 p, Q
else if (document.layers){
4 y: l0 Z* j C/ Q$ l6 o
if (ns_marquee.left>(actualwidth*(-1)+8))
8 e. d! ]9 P" h$ H) N& m
ns_marquee.left-=copyspeed
/ C; H, x) R- i6 N' D
else
2 Y4 m5 l1 h% e2 E( l
ns_marquee.left=marqueewidth+8
( I4 J6 F. |: {* H% N7 x4 `
}
$ h9 `; T3 B. i$ s& V* y1 z
}
- D2 O+ ?2 r( @. q+ }
7 p$ {4 F& Q6 M- }! N
if (iedom||document.layers){
6 W1 p. ?4 j) F2 e
with (document){
5 p% T6 {, q1 P
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
5 h8 e# p5 H' R: j' u
if (iedom){
9 i4 O$ O9 y, x( r. _' b' Z! M
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
0 D0 d/ V, ^2 l% \) N Y. j
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
, W5 X, v5 h+ S7 s1 u
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
5 A# t+ O* ]8 }' I$ K1 H3 `0 A
write('</div>')
S) v8 N5 L" s# P3 w7 I
}
9 R/ U2 Y% }$ b" t: i$ u
else if (document.layers){
( z, r$ x5 C- |
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; e8 \+ v7 B. W) E+ l6 U6 c% ^
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
. S: M4 S' c5 C
write('</ilayer>')
& M6 Z. j/ F$ h* v# g5 O1 ^
}
6 P; p0 t; b1 l* F
document.write('</td></table>')
& J3 {+ S! K f3 L$ s% I
}
- I; u# i4 n, ] }) K
}
6 r9 L1 w. z, D$ c4 h& X' u. A, z8 Y
</script>
欢迎光临 捌玖网络工作室 (http://www.89w.org/)
Powered by Discuz! 7.2