标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% _- O5 W0 f x$ ]1 v- }
var marqueewidth=300
- ]/ Q' d" \( R7 x$ c, r
//高度
2 y. l8 E. ]$ r( P0 I- G. I7 H
var marqueeheight=25
8 d% U ?& ~# `. G
//速度(1-10)
9 M6 B' Q% {( t5 a4 `2 P- e& F
var marqueespeed=3
6 s" _; Y, b$ a# t! s
//背景颜色
6 `! G8 _) Q6 y0 [ B
var marqueebgcolor="#FFFFFF"
, p, v+ a" _* y, p- c4 m: @
//是否能暂停 (0=no. 1=yes)?
/ K( c5 [8 q/ E. v: k
var pauseit=1
6 [+ \0 d9 p$ N2 D5 p: J- g4 \
8 T2 |5 C7 ]' `4 ~$ Y
//修改显示内容
& e. p* @; r$ ?' X6 v
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
8 m' o2 y- Z( ?( p5 ^) Z; @
4 X% q/ H% l1 x2 X; t
* m2 P: k9 a* P$ E( }! }$ d
////下面不需改变////////////
. J' {" U8 Q9 V- `8 Z
# Q# F/ D. _5 h2 l2 U4 H& S
var copyspeed=marqueespeed
3 n! v( e1 L5 c6 U& T/ m
var pausespeed=(pauseit==0)? copyspeed: 0
" \4 |- i7 `9 B% c* O! k' \
var iedom=document.all||document.getElementById
$ y8 t2 m8 k2 \) J) o8 [, A
if (iedom)
! F) r# P K2 A- d
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& \% C1 `; c, s% R! u: G( S6 R) j" |
var actualwidth=''
8 `& N% R$ r: u' s! U
var cross_marquee, ns_marquee
; u' n" s) ?' m% }4 E8 Z
& C3 a' ^- r! h" n
function populate(){
! g# R2 W( p/ X# [. Y3 s+ t
if (iedom){
2 k. }" u) V. D' i
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
+ F4 I5 k$ M* |2 o f: u2 i! r
cross_marquee.style.left=marqueewidth+8
0 a& {$ [. P a/ z
cross_marquee.innerHTML=marqueecontent
% E4 O y/ m/ T; p
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
" |! q+ d; u% ^; t9 x8 \7 j
}
Y9 C; I5 y3 p' g. |7 b. @( {0 x
else if (document.layers){
, ~. F2 i/ p8 ]5 n9 s
ns_marquee=document.ns_marquee.document.ns_marquee2
( ^7 t: ~# f7 p. g& p& B
ns_marquee.left=marqueewidth+8
, o* F6 t. C7 k7 u- e3 S
ns_marquee.document.write(marqueecontent)
/ B' u' `% N' O ?
ns_marquee.document.close()
X! b. X( B' L6 e1 d
actualwidth=ns_marquee.document.width
: M! [6 Q' k6 g) `
}
) h3 d k) m, H1 c: ~. z! o
lefttime=setInterval("scrollmarquee()",20)
9 E* m) {4 K6 J2 x/ l
}
9 T3 q$ Q; K3 t& w6 Y* `8 p" P
window.onload=populate
1 I' ]0 k1 k( C9 v0 L u2 q' m2 G
5 G5 k. W1 b1 c: r5 H
function scrollmarquee(){
9 Z n2 I) H# Z
if (iedom){
3 u. M0 `" U0 T8 O
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
! d7 u. j: f; i: j5 L% ^
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
7 P- e- F7 N. o3 k
else
W% a" z9 n) M0 i- }
cross_marquee.style.left=marqueewidth+8
- v( a8 [3 e4 W' ?
# @' l C4 b3 @% U1 ]9 R% p& k
}
) c' w( Y2 K$ ~; R& o% S
else if (document.layers){
) q0 s- a: H7 e3 l! z- L: x9 N
if (ns_marquee.left>(actualwidth*(-1)+8))
" O; ~( C/ ~4 k" B- ?' V4 D
ns_marquee.left-=copyspeed
( Q8 c$ @+ f# S# I' q: `+ L
else
/ o+ d3 @" ^* r8 G; C+ {3 H5 N$ Y
ns_marquee.left=marqueewidth+8
$ W" z: \6 u5 A; n7 a& f) H
}
W& i2 E( x5 [0 J
}
0 f3 Z4 c, Y. R. A: ~/ [
0 o* u* |, n5 e/ X, M# S
if (iedom||document.layers){
; _5 I1 z4 o, ~3 @5 [2 |4 M1 X- X
with (document){
" q6 l: I5 V! m0 J' V
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
; O" M' S6 D" w" W
if (iedom){
3 Q0 `. e& ?: y, Z! y% X% O
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
# o( z5 w- F7 e& c9 P) h
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
* y5 ]9 p7 J. J8 G
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
. y- f3 {& b. n0 V7 g$ q) [0 A
write('</div>')
. t. C# n: J2 X8 e
}
6 A2 z$ r& M4 @4 X Q
else if (document.layers){
( m$ t$ }; A; I0 B: ~
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
6 h0 P0 N0 K: ]2 k$ H; N4 K
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
9 d( e% ^' ]5 v5 C' f7 |% j
write('</ilayer>')
; x6 ~: b! T" }( K6 X8 j6 Y
}
) q4 C3 }2 e( }0 ]' c' e
document.write('</td></table>')
" w8 ^, @ u" | @$ ?; J
}
5 m0 P! f0 `1 M9 O, x/ O& e* X/ U
}
! n9 E \1 X4 s3 s# \
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2