标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
8 b$ h+ y/ ^; ]+ K/ \3 |. l
var marqueewidth=300
& t" j/ t7 X' x- ?* T3 J8 G
//高度
) c+ |$ w7 @! O, w; A Q r' j
var marqueeheight=25
! f3 y' k5 m$ @& x2 p3 j
//速度(1-10)
3 E" |$ H6 R2 |" x: P8 f* i
var marqueespeed=3
! k" z; V9 g+ V H
//背景颜色
3 L: r" X% y- R4 N; T
var marqueebgcolor="#FFFFFF"
& L# l( b5 n. x% y' G: Q. u1 E
//是否能暂停 (0=no. 1=yes)?
5 V2 K% a7 Z3 }0 `% [5 W5 M
var pauseit=1
8 A E# G( X. k
+ _1 B2 |5 r3 s( _
//修改显示内容
8 Z3 L7 p6 y# a3 o
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
. e* l2 F5 y! ]5 Q2 M& Q
6 y) g1 K* I! c1 ^# j" ^
* ~& a/ W! v! r" N5 I
////下面不需改变////////////
. @* ^3 b6 B B0 w/ x/ i
& \! B) X/ ^4 G6 v# r$ |6 v
var copyspeed=marqueespeed
, R) W, {; g3 N
var pausespeed=(pauseit==0)? copyspeed: 0
) k! s! F# \" I$ z
var iedom=document.all||document.getElementById
* y6 M* m- X( A5 l/ X
if (iedom)
( Z0 K1 l: S6 K) k( p! n
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
# Z6 B) q- ]: l- t
var actualwidth=''
0 ?& p! b- V8 a7 `
var cross_marquee, ns_marquee
0 `) I. @! ~* `1 C
) t" W4 P4 g! |; c
function populate(){
. y& H% H0 V0 b. r3 ^) ~2 l: I: S: C
if (iedom){
5 E. w5 Q2 k- ]9 a" m; V* z
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
0 P3 [- I. |/ q' [- I. A2 g; P
cross_marquee.style.left=marqueewidth+8
+ r7 {* g9 w1 Q' X3 G! f4 M
cross_marquee.innerHTML=marqueecontent
, p0 \1 J9 _# d& S! X! s
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
! d0 e+ M" ~" C% l4 n
}
: B$ y# ~. E1 k/ m- J
else if (document.layers){
( G5 ? s& [5 Q
ns_marquee=document.ns_marquee.document.ns_marquee2
4 L8 j- X& U* S! w9 k
ns_marquee.left=marqueewidth+8
, w7 z* W' D! f4 ~# W9 d2 R
ns_marquee.document.write(marqueecontent)
4 V9 _- E5 ]4 _! {" |2 |1 n
ns_marquee.document.close()
; q0 n g' Z5 w2 E8 E+ r8 D( r
actualwidth=ns_marquee.document.width
( D& b8 ^* L& L$ L2 }1 i) J" g
}
. d1 Q/ x7 {! g, g* x, U
lefttime=setInterval("scrollmarquee()",20)
$ p; ?' i }7 I' E
}
0 o- H( J7 g) l) j' l% r! y/ n/ ]
window.onload=populate
5 G q6 `( Y* Y# |- j
# W! I' U; o) T% I5 _4 D
function scrollmarquee(){
; k$ p# h+ W. a1 I8 G) j2 i# s
if (iedom){
$ U+ x9 z- J6 |7 g. _
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
/ h+ m& b" U4 g9 j" A, H
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
" n* Q: W8 i0 G' ?
else
0 u& Z0 ]4 [2 Q# E0 Y# @3 q- L
cross_marquee.style.left=marqueewidth+8
L4 w9 \# t- Z; ?
7 b' ~ Q1 ^5 L
}
- `6 \" r" w3 B+ Z6 J- V
else if (document.layers){
6 F3 P$ b- ]2 g9 A) @2 q6 F! S
if (ns_marquee.left>(actualwidth*(-1)+8))
9 }# l+ ^6 O" t" ^2 D! i# t
ns_marquee.left-=copyspeed
5 f- V6 Y% ]( S5 \
else
: A6 `' |# J. c
ns_marquee.left=marqueewidth+8
+ F' l7 p" n, w! ?! R
}
! S! x: @" m0 _% a' z/ x
}
' J* @0 h$ v# n# x! \, t' G. N6 `
! W3 a2 B9 h7 M2 z9 N& W# p+ p& b
if (iedom||document.layers){
7 n7 k# ~) s% @- G( k$ s& s7 p9 u- Q. ?, T
with (document){
+ ~% @9 ^2 ~+ I2 @0 }9 a
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
: r3 v Z6 S" R- m
if (iedom){
% J1 p# Q% T/ \- ^
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
n! N& t# {& v# Y% U4 b" y
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
% ], J2 k& V1 F* ?! |: ~
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
" J2 @7 D3 b$ _& R4 y! ?+ a6 v, k
write('</div>')
, `. o- f- j5 S { y
}
5 |8 X4 C$ R& o0 ]/ B$ }0 w+ F
else if (document.layers){
7 K9 B+ t- \' c8 b; t4 F+ {
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 d0 _: k" S& I) n) Y2 p
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 l( W/ U. f. w- K
write('</ilayer>')
' y' L# x* y' b. _* j
}
0 o$ z$ S' r' q1 s) ~0 [! i. \* t
document.write('</td></table>')
! c7 w$ J# y! l( p( z, k. y9 J
}
4 H5 P! n) }# q# [& [" A
}
" c5 A5 N0 b5 |2 {+ ?& H9 S# {5 D8 s# x
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2