标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% K1 b5 l) N2 W6 ^0 I" n/ h
var marqueewidth=300
Q" }) s; g0 k% S
//高度
# @0 J2 @( R2 \, M) a2 t
var marqueeheight=25
* F: w7 K: k q" y/ M( m# x
//速度(1-10)
, I. J! }* M& G4 O
var marqueespeed=3
+ s& F: d6 G$ r5 E2 P
//背景颜色
) k3 a3 H/ D; [0 {' A
var marqueebgcolor="#FFFFFF"
) p2 x. b6 [/ {4 s# H
//是否能暂停 (0=no. 1=yes)?
( _8 Z* [" S% v
var pauseit=1
2 s5 X6 G5 a9 {* N- O
( L3 `0 Z, p& Z+ |* n
//修改显示内容
4 x4 Z8 n& K% J- h J
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
( g! E% K6 u! b- K: |/ k
1 o3 w0 r# V0 C0 J# \# Q& ]
4 p4 G7 a! k& q
////下面不需改变////////////
" X+ y( R4 x. G6 f2 [
; V, } y) |, Z: P) d' w6 Z
var copyspeed=marqueespeed
* T' a# Z2 y4 q4 R9 w' r
var pausespeed=(pauseit==0)? copyspeed: 0
. @3 m1 X- P z% ^
var iedom=document.all||document.getElementById
- [: L3 W& B6 W; y
if (iedom)
# h1 J: H- o9 {& P) V: F" W: i
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
# |, F% W6 |; l# q2 C& m6 g$ k
var actualwidth=''
! Q# ?. Q* H& F% ^2 ?0 |. {( R# |
var cross_marquee, ns_marquee
" k* ^+ u& U& O- H& U) a* [
) P8 F0 X" h, ^; @7 a0 J# z o4 |
function populate(){
Y6 Y8 ?7 ?& k- G% u( O
if (iedom){
3 k! a7 Y6 i8 {0 ~8 ^2 c* N1 M
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
# c! U+ x3 i7 {
cross_marquee.style.left=marqueewidth+8
7 {- u; N$ }1 A- s; O) p
cross_marquee.innerHTML=marqueecontent
) b: _+ V/ ?- G
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
4 r4 i; A( t$ E7 c; H& b
}
5 |! z' _& g3 Z* j
else if (document.layers){
; \6 f" e4 O0 Z" e6 r: f
ns_marquee=document.ns_marquee.document.ns_marquee2
9 E% ~1 B1 R7 U2 @; `: U
ns_marquee.left=marqueewidth+8
9 N3 u {* l! v( F# j7 T2 g( Z
ns_marquee.document.write(marqueecontent)
2 H, p0 A5 X' `( c3 U5 y5 Z( x) j& R
ns_marquee.document.close()
( U1 P% Z- |2 I0 g# i; q. [! l
actualwidth=ns_marquee.document.width
# h: l4 K/ D. T& [) H+ |* o
}
6 L- O% ?4 I5 |" s0 C
lefttime=setInterval("scrollmarquee()",20)
1 H% E: F% P4 Y4 E0 g/ U
}
4 N7 ?* O" @6 }6 r
window.onload=populate
# x( h, H9 Q5 f, y; T
7 ]4 h h. O0 B3 q0 b& ?, C
function scrollmarquee(){
* M+ M" q2 h9 B# e! z: e* V' i
if (iedom){
% L; h- X7 p# {7 h" T; w# x8 D b: Z
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
9 D6 C* I4 V! I: [1 J6 _5 ?
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ M/ z: M! I5 u# [
else
" F4 q" [) ?# x1 h3 T( g
cross_marquee.style.left=marqueewidth+8
+ S% p8 _5 S! w% V1 p* j u5 i+ U4 H
! {3 f; V8 {% \3 w1 i0 `
}
8 Q. v) R3 G& \% ?
else if (document.layers){
7 W) Z7 s6 t' G+ N- b
if (ns_marquee.left>(actualwidth*(-1)+8))
) Q8 y! O! w8 L& X$ G
ns_marquee.left-=copyspeed
7 D- B* Q: X3 R% K, O4 G7 p
else
6 O) x B0 O1 T
ns_marquee.left=marqueewidth+8
+ l2 U9 K! u9 T1 q4 {) W' `
}
9 E( c5 L8 e5 C# |! Z* y
}
, r% m) P- s, L. k" F
* Y+ P. A6 q7 \1 s
if (iedom||document.layers){
& W% \+ m! l* }0 m! _' v8 h
with (document){
) _/ h4 o" q0 ]4 S4 x8 C% n- m
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
3 n# l% z6 m6 ^" F5 t
if (iedom){
0 e, d* B, M/ l! J) g
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
) _# K3 M5 T! S0 D# {
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
$ b7 Y9 c6 _, E' Z
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
2 x i5 q! F) r8 Z
write('</div>')
: j9 h+ P# {: `/ `
}
$ v0 Y- ?( ?1 V8 p
else if (document.layers){
1 T* f6 `6 r# Y4 n# [6 q8 c
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 h! Z- B( Z5 n7 e# v0 Z$ C
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
+ n3 V! t# q6 }& Z
write('</ilayer>')
/ W1 C. ]& R8 v/ _+ n S4 K
}
( I+ K' O: E) u2 F0 G U
document.write('</td></table>')
& g4 o7 \& _8 G. a
}
! h- V7 _/ F' q. e
}
: d5 M+ _- A0 g& }
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2