标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% b( Q4 j# s& E* E& L5 Q, R
var marqueewidth=300
% H2 N, |$ q) V8 o9 K* _( M
//高度
1 o. L- }- |/ @! H0 U5 B
var marqueeheight=25
4 E# x$ O& }4 g. Z
//速度(1-10)
: v) B1 F- Q" M
var marqueespeed=3
* i3 o# N9 z8 J V; v8 f! I
//背景颜色
+ V& T* g0 ^- U1 C
var marqueebgcolor="#FFFFFF"
. T0 o/ r- i6 E0 \/ F7 _
//是否能暂停 (0=no. 1=yes)?
" M% E: _) \' {$ Y2 g4 q
var pauseit=1
3 X" h9 Y2 y- i* Z. F* ?( Y
, _+ P8 t4 d/ w- Q( A5 s
//修改显示内容
5 I/ `. f' `$ S- [4 f
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
9 s" ^1 ^: k: K2 f
4 X6 u: s1 h4 ?- _
) {! Z- L& }' w: Z$ p
////下面不需改变////////////
& M% g" l" S% }" X: B4 w
: s; B: ]( J: h, ^/ w+ E
var copyspeed=marqueespeed
6 x( ]& w6 U. {5 x0 ~
var pausespeed=(pauseit==0)? copyspeed: 0
% E# w9 N7 L& L2 a
var iedom=document.all||document.getElementById
: b. f s; O+ {4 |% k! ]' V# l1 a. R
if (iedom)
3 W E& ]! p) {- [" l; N
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
6 P* P# W' A( m# g
var actualwidth=''
k- F2 k# R; y
var cross_marquee, ns_marquee
0 Z" X* ?. m' H
$ W" B4 B1 O) a5 ]1 z- }- u
function populate(){
0 _) ^# d& I/ r; a5 [4 n, i+ f
if (iedom){
, @5 e9 ~" L/ q
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
& i8 p' U! u4 S3 }- e* h0 i
cross_marquee.style.left=marqueewidth+8
/ K. R1 y9 [ n; `9 \ C
cross_marquee.innerHTML=marqueecontent
+ v& E% V! t: }+ C( H" g
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
2 T7 A2 x9 x1 W: L: s, j- x
}
0 I, `$ c4 J+ Z- l; W! x5 y' x
else if (document.layers){
8 U" C5 U6 j* ~5 j+ O% L2 d
ns_marquee=document.ns_marquee.document.ns_marquee2
9 d* n- B+ P, l; c
ns_marquee.left=marqueewidth+8
3 B' o/ w: m& l0 a! f
ns_marquee.document.write(marqueecontent)
& g, m1 J P) f/ k5 I
ns_marquee.document.close()
; N% X% k1 S& [ B: `
actualwidth=ns_marquee.document.width
9 L9 c6 e% Z% M. m
}
/ H' a% k7 B9 ]) L- e* ^
lefttime=setInterval("scrollmarquee()",20)
8 Y5 L+ @, v: F/ `( I
}
- b$ W5 m" }3 ]4 Y3 f# @$ M
window.onload=populate
! B0 E) Y- a( u; v( _8 T0 g: `& b
5 v3 P. f7 `* Q1 L, O& [7 S# E
function scrollmarquee(){
5 u: z" t" U' Z; C8 g2 \" g
if (iedom){
9 I" }( e+ G# p- j, U6 F7 H
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
2 n% U# S1 T- a* Y7 _& ]* x- g' a
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
' f: U! q- O" H: b) A! D+ s1 J. C- h
else
* F. I; A. @! S0 g8 ^7 i0 g) q
cross_marquee.style.left=marqueewidth+8
2 D$ J6 Q6 @$ o5 E7 e0 f
+ }* j8 `% J1 R, n, D0 a
}
6 f/ D. s& B& B
else if (document.layers){
1 R' X& ~3 ~% F9 D; Z: a: c0 l
if (ns_marquee.left>(actualwidth*(-1)+8))
s* T- R6 y v# A m
ns_marquee.left-=copyspeed
4 z7 J z( x9 s
else
6 o& w& m; r" R! x/ d
ns_marquee.left=marqueewidth+8
2 F8 S7 i* W1 |9 Z( Q
}
5 K' b5 c$ g$ Z, b$ a# [
}
- E" n1 z& \2 [$ t" Q* g+ }, {! ?
* v }5 ]* _! B. M6 N2 R
if (iedom||document.layers){
5 w3 p( u: B. c/ W4 S! o! w/ o1 C
with (document){
0 a; B# h% y! r2 j/ t- g+ Y" s" \
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
" Z. s- R& ~$ v. H! x: z% S
if (iedom){
! n+ J# i, P9 D
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
1 S# [8 L9 i- E/ |
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
! V/ I. _6 q5 |$ w# u# f
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ V3 b- b0 ~1 ~7 E- j4 g" j8 E
write('</div>')
# n5 k6 U$ G- @* [, I( d; n I
}
' a+ Y6 d) [6 ]
else if (document.layers){
" E9 K/ B4 w5 ~+ L* C% t
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
9 V" T+ ]' O1 w- W
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
$ |4 p1 [( a6 a# J) b6 [6 ?
write('</ilayer>')
& i2 _4 ~: ^2 ], ?) E& F) ^
}
- f8 Q* i* Y; P/ \3 ^- f7 p
document.write('</td></table>')
2 l2 j4 R3 c. Q+ \0 j' |8 U( M
}
+ T, w/ H3 ]8 g$ a9 Q
}
) z& Z. I$ r& X3 o7 L( m; E
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2