标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
% ?6 C _9 |. e
var marqueewidth=300
# I! D0 j8 j( F* I
//高度
/ f/ M5 _: m# o* N7 k- h, W8 ~! o0 R
var marqueeheight=25
' j7 @! v/ v9 f5 C% [9 h( [" {
//速度(1-10)
& T" h& f4 X9 x
var marqueespeed=3
, V: z: O1 `- o; f( c
//背景颜色
5 i5 R3 O6 P" K& ~/ {
var marqueebgcolor="#FFFFFF"
% O/ d' I* R/ L6 u# |3 h* M
//是否能暂停 (0=no. 1=yes)?
+ x2 ~. n" p7 ~! q; s* \
var pauseit=1
& M& N3 S- ?% w9 x1 A7 [
7 w' o( m! ]3 o6 w
//修改显示内容
- t& ^! T2 i) O
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
7 j( ^# M: T! P9 x
% u h8 S! x7 f
g0 G6 a# r( d s4 @
////下面不需改变////////////
! i- X6 t |% f: |
, D7 k9 u6 R9 M- C' J
var copyspeed=marqueespeed
1 I1 W% M7 G4 h9 j7 m* c3 g, b! g% w
var pausespeed=(pauseit==0)? copyspeed: 0
) e! |0 g2 F! g8 V( d. F
var iedom=document.all||document.getElementById
+ t. N2 i6 v8 y- s) v
if (iedom)
, r% I, i- J; h1 y
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
; p, f* g' e2 z( E! f0 y
var actualwidth=''
$ d- m8 Q* ~5 v B# R5 v+ o- b
var cross_marquee, ns_marquee
5 k! ^4 i: R. E1 V
. |1 e. E9 ?# L: X# y, F+ A% z
function populate(){
% S' u6 y4 w0 K) B4 m2 _/ A s
if (iedom){
; d/ U' W+ w% ?/ e; g9 a. g+ N4 p( D* O
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
9 A( V) C$ D& P" [4 q3 ^
cross_marquee.style.left=marqueewidth+8
; |1 v1 J6 L2 P! d6 ^4 w
cross_marquee.innerHTML=marqueecontent
9 i. R( F$ v9 @8 n! b4 N, h
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
: E6 \7 s5 c% G- ?9 a$ S9 ]1 r% m
}
' H7 E$ v3 x ^4 z% h& B' @3 N
else if (document.layers){
3 d) J k1 E% ]+ G
ns_marquee=document.ns_marquee.document.ns_marquee2
0 O; S w3 W( `" e- o" J6 j
ns_marquee.left=marqueewidth+8
/ J- z4 _/ r b
ns_marquee.document.write(marqueecontent)
1 X5 q& l! t0 U" } U4 s, E
ns_marquee.document.close()
* y& J+ n, p+ y) ^1 b' w
actualwidth=ns_marquee.document.width
; I7 m6 w. i5 x" \8 L( K
}
3 F# P% i+ k8 K2 \& R) S/ C3 P
lefttime=setInterval("scrollmarquee()",20)
9 b7 ]+ ?$ h. @0 Q* X8 W6 E. g
}
3 s/ r8 \, V6 [1 }4 g; m8 }
window.onload=populate
$ e: o8 E6 \: k
8 K7 _4 d4 r6 \$ g/ Y
function scrollmarquee(){
9 _4 J5 R: L. ^& W6 e" `; w
if (iedom){
( p+ o$ C& {, r9 M! O A
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
5 [" q9 o. T7 d
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
$ Z" Z0 F$ ?" _* y( y, @/ F- Q& R
else
% U. V I6 W& h3 i5 d/ g
cross_marquee.style.left=marqueewidth+8
# \4 ^. l2 c8 M' a! B& ?
6 l7 {$ U0 A7 x) N! i( }: R
}
$ J5 I% b* n2 c/ {/ E5 Q
else if (document.layers){
# U5 J' z G$ j4 A Q n
if (ns_marquee.left>(actualwidth*(-1)+8))
0 a( y" M4 G% @8 z5 U S/ y3 u+ e
ns_marquee.left-=copyspeed
9 ^" M: d# Y3 U9 h4 P
else
9 N* ^8 A9 d3 R) z* E
ns_marquee.left=marqueewidth+8
2 _; q8 K w3 x
}
+ L0 r( s, a3 I( E/ h7 C) K
}
+ X9 P( G/ O8 C( W9 W
. C" c% z9 ]- D& [. M0 _
if (iedom||document.layers){
9 Z. M2 I7 K& O2 K7 F+ y/ v
with (document){
0 Y2 d6 c! k* ~' }$ L0 a& ?
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
2 ~1 L, T f9 G; X& m
if (iedom){
$ C# r: e. G# ^( A5 h9 |! R' o
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
& h- J. T) f, f, \
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
* m; m" O2 z2 i- U+ D" x
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
+ Y# J( r6 |( j3 Z! v! e8 A. X1 v
write('</div>')
2 G! Q! R' p) `8 z% d. `2 ~9 ?; c" P
}
2 Y- z# a- ~0 A g9 B! U& X
else if (document.layers){
0 E6 P4 {% _& H% U7 I% P
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ {* V# @, N' \- X* W) V$ A
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% q q) g8 S) D4 U1 x' @3 ?+ ^- q3 @
write('</ilayer>')
; M- l# q9 z$ h+ u( d/ W
}
e. y5 r3 M' S% w# {4 T. q
document.write('</td></table>')
' I& H- @* L* k) g" `
}
* i# v. W- t4 J. d# l
}
) {- t3 Z8 \- [' g$ K% R
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2