标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
2 R% [" f5 V& V% z! k
var marqueewidth=300
9 [& E1 K( V# {* g L* q
//高度
/ q9 r7 k( ?% f
var marqueeheight=25
3 y) B0 U; \# a
//速度(1-10)
0 \ j. m& Z3 @: z5 f: t/ I: E
var marqueespeed=3
* o- V* k' w& C0 ?) ^
//背景颜色
) t3 ~! C; ?0 n( ?7 ~6 d) C% s
var marqueebgcolor="#FFFFFF"
6 I! r8 ^% |+ i f- _
//是否能暂停 (0=no. 1=yes)?
" t$ o+ {; s4 d4 ?0 ^' N2 d
var pauseit=1
2 B) R+ \, a7 I2 J* E& Q
1 V0 M9 d7 i6 p! W
//修改显示内容
1 x K a1 _3 l+ n1 K% I/ x
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
! V/ J4 C: K* e* y u
6 n- g9 B8 }5 o0 u+ A- S# ^
2 L5 c% g0 f. J; s
////下面不需改变////////////
; m( H! o2 T* x; ?
& L) I8 Y: m& j) d1 }1 U4 A3 [
var copyspeed=marqueespeed
3 N+ _+ Z2 D: |- X: D/ [
var pausespeed=(pauseit==0)? copyspeed: 0
8 K+ _7 S. n" A" i5 l- a" a7 p
var iedom=document.all||document.getElementById
, ^% m- F: Y9 b; V# E
if (iedom)
% b: A$ K2 \7 B6 S
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
' f, d3 ~0 l& o \; T" ~
var actualwidth=''
+ k+ F" ?1 d4 w' N) F; i$ ?
var cross_marquee, ns_marquee
2 Y+ Q' J% x8 @
; U( V# G% t- `, t' P1 u
function populate(){
; z1 G& W# P* ]
if (iedom){
! Q6 m' o8 G! R0 u( F* j
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
, f b: P8 l8 N! S. t
cross_marquee.style.left=marqueewidth+8
8 A0 j- W+ _9 Q# t2 Q+ M6 p. G
cross_marquee.innerHTML=marqueecontent
; o0 A" h' y/ p0 L T' M' E% Z0 \
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
0 }, B+ V: u7 G5 ^
}
4 S. K2 _" s: h0 g7 p( N
else if (document.layers){
) b1 {1 ]! L; R
ns_marquee=document.ns_marquee.document.ns_marquee2
( _0 D J% N; Y7 O4 x& y+ _8 z
ns_marquee.left=marqueewidth+8
( u* I: p! B% t% p0 R
ns_marquee.document.write(marqueecontent)
6 u+ r0 e# R+ o0 ^5 N# ^
ns_marquee.document.close()
8 m. j0 ^& W0 K2 }, f" i' k' c
actualwidth=ns_marquee.document.width
9 a/ L2 c- U$ \
}
; n5 y) S$ H; I( ?0 X- A
lefttime=setInterval("scrollmarquee()",20)
" v* q# g. b: F) V6 u
}
. S4 ^7 U2 W; ^4 x" E, [
window.onload=populate
& q1 B7 r6 v# @+ O) z n
* k3 G# K2 l. n& T9 H
function scrollmarquee(){
4 N# @- L2 J) R8 z# e( N5 M" N& d! Z
if (iedom){
( ~2 d$ J0 h \( W
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
* j; G$ K3 l$ I& `
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
, i6 g7 d6 Z, i/ U
else
# D0 z3 W* e) B+ Q5 `* `
cross_marquee.style.left=marqueewidth+8
* y0 [; w2 ~$ W! ^5 j5 U
$ ~; I% L1 q' D1 t7 A! G5 z
}
% Q5 X Y! m8 X& b4 w" ]
else if (document.layers){
3 K' X! c( O/ G
if (ns_marquee.left>(actualwidth*(-1)+8))
' V" i% H0 u C3 ^7 E& s0 ]: a7 {
ns_marquee.left-=copyspeed
6 C# Z( g( y, i" l& E V3 R
else
3 G0 u U' o+ V# A; h0 Z
ns_marquee.left=marqueewidth+8
+ H8 i8 x6 L! |5 [8 E+ l% A
}
0 m& @: s7 }9 A5 Z
}
" c) x* j4 j3 x9 [, i7 V: M: m
$ u3 K% O* n+ Y0 R
if (iedom||document.layers){
& ~2 K& h* I7 H! ]2 N; |
with (document){
7 o8 i; R( [7 \' B0 h
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
( [! q6 H/ V% N3 v, F2 Q1 H& F
if (iedom){
9 M+ i1 m+ r/ c* s8 n
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
/ L u* j" A$ R' F7 z& Q: Y* a
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
" I) k9 N6 w* s% ?1 M2 |
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
! Q n( Q f- D7 K
write('</div>')
N. R1 d ?" I7 \- ~3 D' x6 R! N I
}
: k9 i2 N- c$ e8 l5 u! ?
else if (document.layers){
2 P* q& A6 H! W
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
; [3 c% D( B1 ?8 F& S0 Y
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
1 f/ i) p! l' {9 A2 x
write('</ilayer>')
! }9 s/ s" L! v: D" S1 r
}
6 p7 u9 j5 k! X) W+ p p
document.write('</td></table>')
" S; s$ j- k" g. N8 `& Z
}
" e6 R% E! E* k O" Z9 K! J
}
- \9 H8 I% J6 z/ \3 o
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2