Board logo

标题: 网页之跑马灯文字特效 [打印本页]

作者: zw2004    时间: 2008-1-21 20:53     标题: 网页之跑马灯文字特效

//修改宽度8 b' q# U) T; K
var marqueewidth=300
. H5 `$ c) }( S- n" b5 r) U//高度
! p5 ^' f7 a4 Tvar marqueeheight=25/ J8 L2 V5 `) J& c6 p. Y
//速度(1-10)
2 }* ^) @2 d7 Gvar marqueespeed=3. X0 r4 }5 ?( Z" m& c# J
//背景颜色. h2 U. G* t5 l
var marqueebgcolor="#FFFFFF"
4 y( ~/ d; h& m' R2 o' X2 u8 l/ E//是否能暂停 (0=no. 1=yes)?
" {# G  N+ `) ~% avar pauseit=1
( g% m- F4 \2 D* A5 d( \
. S3 n- I' H! C8 q//修改显示内容$ u& f" ~7 t  U$ D% v* f
var marqueecontent='<nobr><font face="Arial" size=2><a href="http://www.jzzy.com/js.asp">欢迎光临七色风网页家园</a>--这里有从上千个网页特效中精选的300多个实用的特效,另外,为了网友更方便地学习,我们还改写和编写了部分的特效,并作了详细的说明和必要的使用提示!</font></nobr>'
' X0 f: A9 d$ p; V! y9 I) W9 E
: [9 {% }5 y' X# I7 o( [# z/ g/ o  B
////下面不需改变////////////7 }5 m/ ^" Q; F( ~  s6 M: S1 ]" E

( N! P' ~6 u, B+ S  Vvar copyspeed=marqueespeed3 X& S! I* `; ^
var pausespeed=(pauseit==0)? copyspeed: 0
/ w8 J+ |' p6 z" O. Bvar iedom=document.all||document.getElementById
# i* e1 k9 I6 R1 oif (iedom), z. Z1 p" {% e4 K8 k( X; q# i6 z
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100;left:-1000">'+marqueecontent+'</span>')+ D* f( M- y$ R4 A$ H4 Q  V) i
var actualwidth=''. |8 `6 Z+ ?1 n& }( i- |7 v2 w
var cross_marquee, ns_marquee
; n8 ]- H/ K3 s. D6 e% Z
6 a: j" k2 R# |function populate(){
+ V+ L1 _+ m. a6 g/ I/ dif (iedom){
- K& N' ?- h) e, e0 tcross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
4 n  T+ ^% d& P2 |$ o5 E4 D" o* \cross_marquee.style.left=marqueewidth+8
+ v) F4 Y9 f4 ?, u* _cross_marquee.innerHTML=marqueecontent1 g  v3 ], W9 w6 I
actualwidth=document.all? cross_marquee.offsetWidth : document.getElementById("temp").offsetWidth
  }. m; z$ S. Z$ k7 e  z8 `7 ?9 H}
* k8 K, u" S# e: P- _else if (document.layers){
( c$ @# t1 c* `. o6 Z, A% {7 ^ns_marquee=document.ns_marquee.document.ns_marquee2
' V% p3 D. H/ \$ z+ J* x2 Yns_marquee.left=marqueewidth+8" W. L, a) [$ H5 D# L
ns_marquee.document.write(marqueecontent)
: d1 a3 v7 Y, gns_marquee.document.close()
/ g8 S& z/ M# O% A1 @3 g* Y6 vactualwidth=ns_marquee.document.width  o" q- I7 x2 m$ [4 q
}
- F" q' {1 q$ l# k  R+ }lefttime=setInterval("scrollmarquee()",20)
$ u+ `: A0 L! G1 h( s5 {}
& ~2 \1 d: n. `" awindow.onload=populate0 Y1 @7 R! c' z" U* m3 }

' Q' U  a6 f, Jfunction scrollmarquee(){
) A8 C9 }. ]- W1 _" G2 E! M# Sif (iedom){
* |3 F7 P" v2 J. J* v/ sif (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
7 {9 I5 k0 V( v3 j$ b) ^* c  h6 c) Ycross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed9 |- i! T6 d2 A# f
else4 H8 l0 u4 m: A3 y  U% B, W
cross_marquee.style.left=marqueewidth+80 k$ B2 |$ m$ ^+ d# a1 [

, j5 E7 ?, W9 U0 h" O9 W+ x1 l* U}
8 n2 Y$ G# V0 Y8 _4 Yelse if (document.layers){
+ u9 i; D" v7 n: M: Oif (ns_marquee.left>(actualwidth*(-1)+8))! x6 `, v$ p" j% \
ns_marquee.left-=copyspeed0 r6 q4 {1 H$ |/ }
else' |. q, y( j" t) c' A# T) D: x
ns_marquee.left=marqueewidth+8
; H) Y* j% M( z/ l& j1 L+ S& S}: |7 z  {5 _7 h- }2 o/ a9 K
}7 p9 s8 y# c+ I) m% k* {" {

! s, U9 w: y" W+ Mif (iedom||document.layers){( r: ]/ N0 `/ ^9 j1 J: i( ]
with (document){2 L1 Y8 t: @; V7 [# n& H
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
  i0 f$ U2 G* o( ?: n& wif (iedom){7 M: |( w$ m- q+ G" r
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
0 G. |( C7 Z1 F& n9 }/ n# D8 ?, Kwrite('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')1 Y7 w: a% Y, a( G$ ^
write('<div id="iemarquee" style="position:absolute;left:0;top:0"></div>')8 O0 j: d% |# ?" K( ?7 k' i
write('</div>')
9 d6 x9 S% V& U3 Q4 k, F}
: w% y5 Y" b0 K" ?' Qelse if (document.layers){& o# F* |* E; g0 ^( _5 U" x9 O
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
' I. n9 {1 w) w+ |( T/ n3 Fwrite('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
% ^$ Y8 e& j/ h4 I" j! Fwrite('</ilayer>')) c0 U2 ]- u  s, [, B
}
! {7 |% H$ [; _1 Ydocument.write('</td></table>')" H8 [& _. k' }" R
}9 n, R( Z0 v5 _+ A6 |
}' A: O2 f- c* e4 H% {
</script>




欢迎光临 捌玖网络工作室 (http://89w.org/) Powered by Discuz! 7.2