标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
" ?: d# O; `2 r- ~
var marqueewidth=300
6 d/ h$ C& t$ Y3 A! e. g
//高度
8 o5 |! Q8 w% N, l2 ?: {
var marqueeheight=25
% P6 p( b6 _8 ?9 J3 K7 h. Z* i
//速度(1-10)
7 ?' w) H% b" p+ n& O* {
var marqueespeed=3
( ~9 h" M$ ?* O, B9 p# v& H8 Y
//背景颜色
4 x& Z* _2 T0 L1 }! V
var marqueebgcolor="#FFFFFF"
. ?# p$ j$ W e% F+ p2 L" ?
//是否能暂停 (0=no. 1=yes)?
* T0 f1 _$ V0 c, I
var pauseit=1
/ ]. J! t4 [2 n7 @6 \7 g' ?- u
$ D* X/ F/ L! W; |: i
//修改显示内容
7 ^& j" ^! z6 i4 ~9 @
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
6 g/ j: ` I( Z: \( L
_: g" C. G4 s- Z9 c
& M- s9 s4 Y( h8 q: Z
////下面不需改变////////////
' O. Z9 D8 y' n& z: s7 M% g- }$ V
9 V: B3 T0 d: ]! ?" G
var copyspeed=marqueespeed
5 Z! T0 w8 r* H( \" ?, W
var pausespeed=(pauseit==0)? copyspeed: 0
7 n3 m4 _$ C( ]0 J( \# `0 }' C5 e
var iedom=document.all||document.getElementById
+ M% \. n0 b/ Q* r! s! O& G
if (iedom)
% z) m L6 K+ Z; G4 |" ^: h2 Q
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
6 a2 D$ b8 v# l. j9 M/ G. d# g
var actualwidth=''
& y+ B+ X, g( s
var cross_marquee, ns_marquee
! w8 W3 \: E, p+ {) X6 P
G8 {; }! B3 y9 t
function populate(){
7 O( e- z+ h9 p6 A+ z
if (iedom){
) H1 S! u5 I0 {* `. h3 H
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
! G) ]2 W/ f( S7 ~ `+ q! m/ I
cross_marquee.style.left=marqueewidth+8
' |# n! ?$ t% j
cross_marquee.innerHTML=marqueecontent
: O" k3 O2 P7 E: t# M2 x/ G( r% y
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( `6 S# Y; _$ i a0 z4 I- b; g, f
}
8 I& N6 Z4 a, a2 p9 K
else if (document.layers){
9 p0 c9 D! }) a) |" j' ^. C* a
ns_marquee=document.ns_marquee.document.ns_marquee2
& c! R" k& E7 r* ~
ns_marquee.left=marqueewidth+8
$ F' Z; \7 ]- o* o7 F% f9 h. p
ns_marquee.document.write(marqueecontent)
) x1 Q' {. ?; Y6 |
ns_marquee.document.close()
0 p. V; Y, [) C( ^$ `! ]# R
actualwidth=ns_marquee.document.width
9 z+ A* l; ?/ {8 k9 f6 S0 o
}
* W4 W- m* R$ j" L7 F$ B" k/ \( u
lefttime=setInterval("scrollmarquee()",20)
M% }% }/ y. {9 d5 p
}
% ]. y. f, x1 V j
window.onload=populate
3 x9 n' O% u3 _( v* X
0 x0 y! O1 }5 F: h# l- C
function scrollmarquee(){
3 s8 B& F# x- q# [' d
if (iedom){
1 g# I; B. W5 K4 C
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* m- z4 `3 O ]2 G4 a
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
3 K" k- N1 w) g% A [' p' O- U/ Q
else
6 O2 {& Z: J/ l% E1 f
cross_marquee.style.left=marqueewidth+8
5 P9 R: J0 c0 l/ q& G8 m8 {: H0 U* w& R
, n7 m9 V; |3 J% L1 A
}
f+ S# E& _% G: |% E6 N
else if (document.layers){
3 N7 v; R% r. Z7 g& u
if (ns_marquee.left>(actualwidth*(-1)+8))
; v# z$ w5 s5 T4 F5 D
ns_marquee.left-=copyspeed
( E. n8 @# g: v9 \1 {! Y
else
- L1 C& I/ t& D3 m
ns_marquee.left=marqueewidth+8
" ^- J" z6 ?, a E4 J: y
}
$ Y% ~5 i* d! s* [% D. R. {
}
9 w2 _2 X- ]2 M G [3 s
0 @ s* n% P/ b( R4 o
if (iedom||document.layers){
0 u8 y3 E0 T1 O
with (document){
% C/ _; e9 m. H9 y) A
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
" p; [' j3 O) A/ | _
if (iedom){
' F$ t) E9 ?% Y0 K
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
* {1 [- a6 ^: \# S& K: D
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
. Z) v' c6 o, l4 j7 w
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
' E1 d. \% i2 H1 Y& r
write('</div>')
4 }7 _6 z9 l) d" @: p
}
/ P3 j/ B; _" ^8 L" C5 l8 w
else if (document.layers){
+ r9 H' a. Y5 m: h3 J0 n+ |
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
1 Z- q' a. d1 X' i
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
, c$ h, F3 M* L: q# @1 ~
write('</ilayer>')
8 q1 m: u' m/ b8 p7 C
}
+ ]! z$ ?. c) W% L' J/ q2 `9 K/ Y
document.write('</td></table>')
* L' x2 A \- B: j9 X% E
}
; x' f2 R+ b5 E
}
9 h) V+ m' `/ s
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2