标题:
网页之跑马灯文字特效
[打印本页]
作者:
zw2004
时间:
2008-1-21 20:53
标题:
网页之跑马灯文字特效
//修改宽度
1 Y* @& I) t L7 [
var marqueewidth=300
- l; v. h6 e, C! E: b
//高度
+ Q6 |/ \' w- @) g
var marqueeheight=25
/ d( o, R6 `/ t7 o' j
//速度(1-10)
9 P6 G' A( v0 x. e/ o" P! d! {& g- G
var marqueespeed=3
E1 |8 a- g+ E* e9 E3 [2 O
//背景颜色
" y: H. G; N, t" v1 Q
var marqueebgcolor="#FFFFFF"
: M% W. }9 T- ]) e% L" _
//是否能暂停 (0=no. 1=yes)?
& J6 K3 w/ M3 [- O3 @2 R
var pauseit=1
- H9 E& m5 Q" v! l8 P( V
1 p2 x' k1 c Q% V
//修改显示内容
" T/ _6 \. G4 E8 `$ y3 h+ Y
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
& b7 \4 V( Q1 t
8 l S6 v. F6 p2 p, [
# ^; G* `2 F+ w; m
////下面不需改变////////////
, d; c/ O" ]; z6 Z; U, R! ~7 D
% }2 C; b2 Q- v9 v2 H8 w+ d2 w
var copyspeed=marqueespeed
" r" f. Y W3 D! _; e$ V
var pausespeed=(pauseit==0)? copyspeed: 0
( Q& l6 L2 S% q$ [# r
var iedom=document.all||document.getElementById
; S, L2 l$ b" b; d, g! t& t& |& L
if (iedom)
- l& u: e; W& b! o
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')
7 k7 v: x% {3 _7 O! g
var actualwidth=''
0 U; e9 {/ D2 P
var cross_marquee, ns_marquee
& d3 @4 f4 s% L* l4 x" \% h
1 q5 f9 J, \9 ~# @' T! }
function populate(){
; f( T) k Y+ a ?
if (iedom){
" w2 V. M7 ~, O
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
" T$ f, Y; i2 l; Q- ?% B9 a
cross_marquee.style.left=marqueewidth+8
1 W1 ~/ T) q& H9 \1 e7 x
cross_marquee.innerHTML=marqueecontent
8 h- F& v' v+ s8 A
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
( h" y8 v- D: ?
}
8 @" }6 d5 ?* |
else if (document.layers){
. i' B' i! [6 c7 X" }
ns_marquee=document.ns_marquee.document.ns_marquee2
, E0 Y$ J" h, @
ns_marquee.left=marqueewidth+8
" e9 e' k. \+ H! x* P' L" L6 \
ns_marquee.document.write(marqueecontent)
# A: W" }% C4 T+ M0 t8 h
ns_marquee.document.close()
* L- d& O F4 Y7 S# r; Q2 {
actualwidth=ns_marquee.document.width
) c% S# C! s9 [: |" N4 t/ N
}
5 v# K% q* g$ e$ `
lefttime=setInterval("scrollmarquee()",20)
7 k! l7 e/ X4 Q% ~8 z
}
4 V5 p. c0 `& v2 x6 } w
window.onload=populate
) I! `9 ?5 G& Z( u; q
# J+ W9 x' M$ M# v* H/ u0 j
function scrollmarquee(){
. v2 A- ~" m, j9 b( L
if (iedom){
+ O. Z$ W2 v. b1 ]' `1 f
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
, E( z! p# p1 S: ~
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed
8 X8 \* W/ o2 b
else
2 K8 Q5 u+ { Y$ o
cross_marquee.style.left=marqueewidth+8
9 X) e) V( Z$ R1 @
$ p( J* ~' ]$ Q7 B$ b( l
}
( N1 T1 ~% I$ s+ b% j9 P8 w( S
else if (document.layers){
+ t0 I+ _. R, n. G+ Q) R
if (ns_marquee.left>(actualwidth*(-1)+8))
6 [0 l. I. S2 B6 k* q
ns_marquee.left-=copyspeed
$ f+ ]- e& `8 w0 ]. U: U) f" y
else
" ^; J+ _/ \7 W
ns_marquee.left=marqueewidth+8
6 |" w1 a; i$ Y# o
}
, W$ @5 d# B. j: g" F8 H, n R
}
) i7 R9 p6 D$ o8 e' \
6 c1 c+ S+ I9 V, e& I$ L
if (iedom||document.layers){
( W0 y7 e7 G& m( A( M7 W7 h
with (document){
7 j+ V/ W- ~4 U4 ^5 e
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
9 b9 l1 F# P; y$ {
if (iedom){
0 ^: v2 } ^0 J" i9 p) D
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
4 q+ C8 I6 [0 f3 N, ?
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
7 d1 |1 p1 v! E/ @
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')
( U% J5 A" a! G7 t
write('</div>')
1 p. Q7 m1 h; k9 @9 H1 I
}
$ G( f9 }4 h6 @2 G8 }
else if (document.layers){
# ~- Z3 _1 s d$ @0 G3 \
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
+ K3 O. \/ ~+ d% m0 E# S
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
- [& }- T2 N9 `+ w& a
write('</ilayer>')
_6 V' F3 @5 ?5 f1 \% L- g
}
" E2 F6 \2 Y+ x& |
document.write('</td></table>')
# Z/ \$ r9 {1 I/ }% t
}
8 q' e. ]5 K$ B0 A7 G l
}
9 `7 h0 [! W% B8 h8 X4 i& Y% y
</script>
欢迎光临 捌玖网络工作室 (http://89w.org/)
Powered by Discuz! 7.2