标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
. y! F) h8 f; W* a6 \
var marqueewidth=300
3 I( Q8 P V8 z, N7 x+ z
//高度
0 p7 F- W; ]- N5 \9 K* c
var marqueeheight=25
i, n6 P6 g+ d3 y
//速度(1-10)
: z, @0 @7 h, H3 z7 S
var marqueespeed=3
, k7 J& T8 z2 A" i# {
//背景颜色
6 M6 E" v3 B" [! ~+ w0 v
var marqueebgcolor="#FFFFFF"
3 v! N5 d: v6 p. S
//是否能暂停 (0=no. 1=yes)?
8 O9 V5 ]* x$ |
var pauseit=1
% Q/ {, t# g( l& Z9 u
+ Y/ h% M+ N" I n( L$ P
//修改显示内容
8 E: ~+ W+ M* \0 |
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
* _9 \- X2 E1 \8 V
( N; P5 X3 C4 T% q8 x/ w
2 I; p( G: T- q0 j3 Q0 E
////下面不需改变////////////
~6 a' e0 K* V, r# k1 [) p5 T
+ x8 r9 ^, B; W: H' [: A( ?$ N
var copyspeed=marqueespeed
" {" U, b: ?. N3 m+ ]+ I7 _
var pausespeed=(pauseit==0)? copyspeed: 0
1 W2 T9 U! ]! f
var iedom=document.all||document.getElementById
: F+ F9 h1 M# G
if (iedom)
, h/ I6 u- d3 @
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
& T' Q/ d9 X- F1 I# g
var actualwidth=''
$ l* d" Q: z' G; U( z) C- m; D- D/ P
var cross_marquee, ns_marquee
8 P4 j$ r, ^; u* n/ G& }6 F( A
5 v- H& C8 t8 K: {- Z
function populate(){
+ I, m5 \6 f2 u+ {6 _
if (iedom){
% H3 |- ^) F7 v3 q0 B- [! }
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
/ {1 g% n1 C, K+ B/ O7 ?% |
cross_marquee.style.left=marqueewidth+8
: G( i$ G+ ?# j. g4 a
cross_marquee.innerHTML=marqueecontent
0 t6 C; y9 W2 b7 |
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
/ A/ X+ L. q: f# x/ p3 m: D& L
}
' F; d# k. m% t) Z' W
else if (document.layers){
4 U7 G% {4 [7 u% v, N
ns_marquee=document.ns_marquee.document.ns_marquee2
: T* d. p- j Z0 b
ns_marquee.left=marqueewidth+8
$ I8 r1 f5 j: g1 t- g# f7 l/ B
ns_marquee.document.write(marqueecontent)
. ?& b8 s, l$ p9 s* f
ns_marquee.document.close()
6 j' p6 j, m" h4 s
actualwidth=ns_marquee.document.width
& G! Y6 L0 q# e/ a9 n
}
$ k# Y+ X" q! S8 d
lefttime=setInterval("scrollmarquee()",20)
. U, _" D$ x1 ^; m
}
8 ?8 m; V% c }$ g3 E/ k
window.onload=populate
8 l6 k7 R' V4 d) i* Y! S2 x" |( y
& J; E$ Z/ j6 V8 R# u
function scrollmarquee(){
" k2 ]. p# ~) ~3 D/ F: i% W! [
if (iedom){
% t1 o! j: w6 c3 M) e
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
/ ]6 p8 S6 l0 h* v6 Z7 j
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
/ D) L$ b" z; L: N& K
else
+ E: W& J# V B0 ]' }2 V
cross_marquee.style.left=marqueewidth+8
' X- C' w6 }" w5 G1 x
; \3 z/ c( K+ ~ l+ q
}
$ O: [- R1 j- P' A# N; S/ `8 W( @; _
else if (document.layers){
9 i9 l' z( e6 O7 q: G: K4 \
if (ns_marquee.left>(actualwidth*(-1)+8))
( e" D. [" r9 q' O
ns_marquee.left-=copyspeed
1 J/ Q. G# [7 w" a% N# w4 v
else
6 S0 y4 z& o4 y: C& v5 i% @9 t
ns_marquee.left=marqueewidth+8
. b$ v. J2 G+ |* R) V
}
: z8 i# D& g- H3 W0 I
}
! d1 C: N' n4 b2 ]
9 v: }( w2 d9 r
if (iedom||document.layers){
2 H2 [7 H- k& O1 ~5 Z4 Q2 y" z6 V/ {
with (document){
+ K. ^+ R1 j' O% X3 t! h
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
1 m- h$ \8 Q9 b7 N3 ]$ a) V% [
if (iedom){
7 z2 I, c* y" L: ?6 N: S! u
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
- I1 P3 ^, S( E: o4 x
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
- A; e8 d C$ ^0 z9 o% G8 K
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
) ~1 @9 }7 o$ ?$ ?
write('</div>')
+ l# W2 P$ d9 Z1 L ?( W+ m
}
9 p. |+ o. J/ L( m& D/ R
else if (document.layers){
6 a! @! y- O1 H9 u a: D$ B; R4 M$ ]
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
) s' t. o: s* X n! M# a2 t5 x* g- a
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
; x( Y' B A) r k7 j/ b
write('</ilayer>')
5 ]' }( e0 l; d" c9 s2 B `1 r
}
/ I# v) _ U6 s4 Q; U; m
document.write('</td></table>')
* }# d4 r) I1 B$ c+ ~
}
& F" x7 G7 ~6 d" N, F, D5 j
}
# `- `6 F5 z) J% g; l
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2