标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
d, e" ^3 P# R2 r2 G' `
var marqueewidth=300
W/ V2 e. o( g( P! R8 P$ u& L m
//高度
- {1 M9 g! E1 Y
var marqueeheight=25
7 A# n( a, R- ^6 M' d8 g- {6 n
//速度(1-10)
+ C9 q( I% j, N% s9 s+ X8 j
var marqueespeed=3
7 Z1 Y! W" I3 d( U- h" h0 i \5 t
//背景颜色
2 o, w+ u( N3 c8 |: L0 p' [) V. u
var marqueebgcolor="#FFFFFF"
4 i: X M2 Z. ~, s
//是否能暂停 (0=no. 1=yes)?
: n8 N+ j: g1 y* j
var pauseit=1
, {- G9 C) e$ C$ B" F- I/ q" i
# w# [9 D7 b& D0 B* S. {+ g# Y
//修改显示内容
* ~# Y. O3 e7 v# q- T
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
' L. o/ I7 s. B) F, g0 J0 f
8 o$ N% Y/ K& Y$ [: h( f
* S$ a. S: Q, M) T) [$ G% `7 S
////下面不需改变////////////
- `8 _$ d* ^* p& A& Y/ M2 x7 W! a3 I/ Z
2 g0 h: A& D5 x# F9 y, n
var copyspeed=marqueespeed
2 n5 O( }1 N/ i8 s
var pausespeed=(pauseit==0)? copyspeed: 0
! h5 K! E2 H/ J7 {" c
var iedom=document.all||document.getElementById
, G1 I: z0 n' n
if (iedom)
# z5 _/ c7 `3 j( M0 ], H4 K# C4 I
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
c1 i/ ^: [7 n* k# ~; w
var actualwidth=''
% n# i% }& y9 p2 v
var cross_marquee, ns_marquee
1 ^7 S, j# B' h N( ?
% }" ~- @. m: ^& b- P; X$ a0 R* p
function populate(){
) t4 f# K1 `4 `: L
if (iedom){
3 I( t' s& j7 U E* u4 r$ i1 w& q
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 \" Z+ T* G5 V: S9 a5 E" d
cross_marquee.style.left=marqueewidth+8
* X; w! X8 } G$ T0 A2 R; l
cross_marquee.innerHTML=marqueecontent
$ `9 r. p7 @8 o
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
' M# q! ^ J+ [5 T4 H
}
3 _ G2 K* [4 `& v' s
else if (document.layers){
A% m) ~8 o7 m* Y
ns_marquee=document.ns_marquee.document.ns_marquee2
" B4 |* x+ B1 `* R: y% m3 e
ns_marquee.left=marqueewidth+8
7 b4 s% L Y0 b2 F1 M
ns_marquee.document.write(marqueecontent)
X4 E3 n3 P. d+ {2 q3 y
ns_marquee.document.close()
% ]9 S! |1 o# t* c0 i
actualwidth=ns_marquee.document.width
4 q: C3 e5 w8 P* A! o, P
}
* m$ T4 C* V* R: e, z. r
lefttime=setInterval("scrollmarquee()",20)
( k5 G# d9 m* q1 R v' ]( i
}
% e5 G' {. e# U" d: \9 c
window.onload=populate
& }% n S# W P" f* n( ~
( _2 P* ^# A* {3 N- u ~
function scrollmarquee(){
# B0 V9 q4 j* U* L9 M2 f% T+ d( k
if (iedom){
2 m6 [% m% M/ d& i2 X. }
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* y2 W# b6 P C! B4 M# s# A4 r
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
! A8 m+ ?( Y" H% m% ?0 H/ c* e# a
else
( p% J; p' C0 n! T2 i
cross_marquee.style.left=marqueewidth+8
! n) H9 i1 n/ C
- j. f. x; N: @# W; b# E$ C
}
+ J9 |% w% T! y
else if (document.layers){
1 A8 @, d1 Y; @ I
if (ns_marquee.left>(actualwidth*(-1)+8))
n8 j) F( S+ T$ J* B# A5 _" b
ns_marquee.left-=copyspeed
1 t |9 H# x9 t6 U$ A
else
+ _' G, t+ l) ]% ]1 q
ns_marquee.left=marqueewidth+8
5 X" d4 }: O1 b* A" ^* w
}
2 U: x* h3 \. k, i( L: C
}
; q- {7 H* _; d S, k4 \7 Y( Z
" l9 @) Y& X, s' a
if (iedom||document.layers){
, I# _* h1 f: W: D4 ^
with (document){
, W) `$ Z' m/ C8 [* L0 V
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
8 g9 N0 ^7 K; ?* h2 C
if (iedom){
$ ~8 z( C7 G) z0 q1 y) ?% ]: X
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
0 e4 A2 V2 u4 F8 w
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- b' E9 m3 W; {5 h7 v- x
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
I- i5 t$ e+ B- j
write('</div>')
" Q$ D% E& O, @+ V" s6 s$ G4 X/ P
}
! A% F. j# h9 X/ Z! N) i5 K
else if (document.layers){
4 w5 u& I& F! w1 G
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
" a, M+ ]# a6 @' w8 l% I: W' J) G3 }
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
* k& h$ I7 y/ f+ S- V
write('</ilayer>')
! l/ F/ W/ i$ `4 Z. X7 y, m# M' z
}
0 o- p. q- h8 Z9 L
document.write('</td></table>')
! O( t# b0 G, [# w& |. g& h% T
}
. ]2 v: z0 x# l. S4 W. d. j" }8 _
}
% A; L7 X6 n, \; x( m( r/ [& x |
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2