获得本站免费赞助空间请点这里
返回列表 发帖

网页之不断弹射的文字-特效

<style type="text/css">  W- ~+ b1 v6 w0 }3 p1 i0 P
#supertext {: G3 }8 k; P& Q7 Z9 P1 S
position:absolute;0 ^# P% ^' _0 b' p
left:0;% P% ]2 j1 Z4 o9 j6 K/ {! |" G
top:0;, x4 W. `  a# t, Q
visibility:hide;: i  c' O/ L# G7 r/ F; W) q" U
visibility:hidden;* k- o9 s  {# Z& |& Y* c7 V
}
# b9 ~% a: V) R# C6 |</style>
0 x  Q9 n# J$ H/ }4 l% J<script language="JavaScript1.2">
/ F* w8 a* ]  a. A<!-- 改变下的字体的大小。颜色-->- _0 E: h+ Z$ Y( N6 t
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 Y' l# i! h( b$ }$ \6 E/ evar hidetimer='';; i2 [0 E" N% a. J2 K4 E' N* Z& G3 m+ v
<!-- 改变下的弹跳速度-->
  U- U& W2 }  K8 m! D9 H$ E* a& vvar BallSpeed = 20;
- R9 E1 O0 ^1 Q/ K# Wvar contentWidth;
) S8 V, }3 x2 vvar contentHeight;
; \. ]# E' r8 U8 b# n! b* _2 ^" ?( ivar maxBallSpeed = 50;
1 `: g: h9 d' I3 P1 o' M/ n! n* _. G

: J% l' x7 k" C  D3 Kvar xMax;
7 B, R7 k4 N  W8 q& U: ]) @var yMax;
; b! d+ Q9 f8 d" `* \6 `1 avar xPos = 0;
1 U; F5 t7 L2 C& V$ tvar yPos = 0;0 i. }- G* v% Y5 K3 z8 v5 V1 \
var xDir = 'right';
8 o8 Z( \" Y* ~5 f  ^! k/ L+ T- rvar yDir = 'down';
7 w4 q/ I5 w4 A& E1 G( Ivar superballRunning = true;
. J" Q* k9 D; `0 H/ t! dvar tempBallSpeed;( n$ l" T1 D( j) [
var currentBallSrc;8 m1 N  H/ w$ N) s( n& q- J
var newXDir;
: y; V8 D. ?) r2 z3 l+ gvar newYDir;
& s) P) c3 ~; c# s- C
. Y. l: c& [4 {3 ]% l# Ofunction initializeBall() {
  G3 V6 M  u5 N! R2 N# O   if (document.all) {
" F% D5 @) a/ K* C3 K      xMax = document.body.clientWidth& V( U; S) ]7 J4 q) M2 F3 x
      yMax = document.body.clientHeight; T3 Y; H5 a! d2 w8 R* ]3 V
      document.all("supertext").style.visibility = "visible";
$ T  B, o: J7 K6 u3 [4 y4 P      contentWidth=supertext.offsetWidth
( P- ^. x: R  g6 Z1 N: E7 q. E/ x      contentHeight=supertext.offsetHeight
5 \4 J9 v5 b- V: W- w2 ~$ y% {      }
% ?; \& O5 [8 Z/ e1 D! v/ T   else if (document.layers) {- J2 [) t3 {6 u0 {% z1 C5 H/ ]
      xMax = window.innerWidth;3 P+ N$ p7 f4 T. o& K/ Q
      yMax = window.innerHeight;
, w9 U6 {; o9 h$ Z3 a( F7 q      contentWidth=document.supertext.document.width1 |+ e7 d/ B; r
      contentHeight=document.supertext.document.height  @- W9 r; j' l  e% X3 o0 |2 B* z2 J
      document.layers["supertext"].visibility = "show";* j0 @1 p# V% g9 t8 U
      }
! U3 h$ U3 T( Q3 q   setTimeout('moveBall()',400);$ k& w1 [: W" G( i4 w' |
   if (hidetimer!='')2 Q3 _" J+ S3 x; g" n5 \! x, \# V7 x
   setTimeout("hidetext()",hidetimer)7 W9 O5 g. g* f7 Q5 ^: k: r1 K
   }# k$ g- M# \5 E  R% U0 {- o' H
+ [* U, H) N6 l4 e( |6 ~) p
function moveBall() {5 W9 X  }7 m. i) Q# Y
   if (superballRunning == true) {. ]& o" c$ x# J$ r2 w: Y
      calculatePosition();/ _2 K/ ?9 {7 {/ m4 `, V  k
      if (document.all) {: @( k: Z) k* G9 p! [/ c7 `' }
         document.all("supertext").style.left = xPos + document.body.scrollLeft;' ?7 t, w/ O: E; x1 e5 a# n2 V! Q+ _/ H
         document.all("supertext").style.top = yPos + document.body.scrollTop;+ w) _  n  f, H+ D, {
         }0 V: Z4 `  k9 ]0 c- H. p1 {2 K# h) i9 s
      else if (document.layers) {
& Q# D# ^3 q  h" x2 X' Y         document.layers["supertext"].left = xPos + pageXOffset;
& e6 @- N1 g$ [1 m         document.layers["supertext"].top = yPos + pageYOffset;( b% l' ~' ^" u$ f& d: Q6 d- c" x
         }6 t2 _6 k; R2 x! q+ }
      animatetext=setTimeout('moveBall()',20);
$ B9 Y4 E) w; A8 }9 U      }
( ]7 `* I( R% M! N5 E& M   }
* y$ I; A1 M" {" r6 X3 x7 J
; n- m/ R8 h" hfunction calculatePosition() {9 Z: h4 v) D( _% m3 N& s# T: N
   if (xDir == "right") {
' E& D) z* X2 d: I7 S      if (xPos > (xMax - contentWidth - BallSpeed)) {
  B6 @- ^$ ^5 a& D. Y+ F: y  y6 H         xDir = "left";
! Y+ ?/ H5 i4 u8 D/ q         }- [1 `! ]# g, J- a3 u
      }
+ D& B. F, R; C4 f4 ~- m   else if (xDir == "left") {" ?9 M' N. V/ {$ c$ ]; p! `& }
      if (xPos < (0 + BallSpeed)) {
( E8 w- j6 ]; x$ j  T, q) i         xDir = "right";7 g4 j/ j2 G' p! }
         }# _5 S1 D+ S/ g6 v( v" l$ L# r# p
      }1 `0 C1 o; n+ f1 s6 M4 W
   if (yDir == "down") {
, X; L$ O3 w- z6 v5 b3 T9 c3 S      if (yPos > (yMax - contentHeight - BallSpeed)) {4 A; @9 U- {& X( ?  n( P* m: I, A
         yDir = "up";6 i+ x- o- l( h% A9 c3 i+ l
         }
0 l: b& }2 b9 w% D      }
& i/ D  P4 f4 v5 ]8 |   else if (yDir == "up") {7 f& R( e$ L* @0 s1 }8 v
      if (yPos < (0 + BallSpeed)) {
# J. x( U5 k4 |) P; e+ e         yDir = "down";# Z! c$ r: E3 K9 {
         }
7 k$ K. H9 u- d( ~4 }4 ?& h      }9 {' }9 c2 z5 k. C( ?) q* J$ R
   if (xDir == "right") {
/ H% Q* u' f/ C8 m4 r      xPos = xPos + BallSpeed;. e' }. ?7 k+ B; c+ u) P& q
      }' n  G/ E$ z. x+ h/ O
   else if (xDir == "left") {# e7 ]0 E4 l. T$ K0 S
      xPos = xPos - BallSpeed;
9 h) ]7 f4 a  m# l$ S+ T      }
$ P  e; {4 `% e* v9 Z   else {7 ^- B7 _  D! e- o5 d. Q( n: v) ?
      xPos = xPos;5 l9 F2 e" p1 q7 c2 L9 M
      }
: c$ G/ C3 U* w8 k   if (yDir == "down") {( Z" j# Z5 u5 j8 f6 _
      yPos = yPos + BallSpeed;
% `- a( J& j! B3 z/ t$ ?8 _/ s      }! s( Q1 ?8 u- ~# G8 L% L
   else if (yDir == "up") {. L  h, r. g0 J. g1 y9 G. v2 m4 W" W
      yPos = yPos - BallSpeed;
( X6 i+ M6 n) m/ l: G, B( R& a      }
7 K5 r! o8 R; R# L) i   else {
- A& t( S  D9 n4 ?( n% i      yPos = yPos;* @9 ^- p6 d( j
      }
' j9 [% \. U7 M   }% M( [8 D9 S2 s# V! @

8 S/ d+ \2 e2 i4 Q- U9 g4 x) d0 }function hidetext(){
8 r7 R% N+ ?! C- ^2 ?% s9 zif (document.all)( f" R* L# _" {- L
supertext.style.visibility="hidden") K: G2 |! O) s1 u
else if (document.layers)
, y2 }0 F; [- _# T$ Odocument.supertext.visibility="hide"3 C7 P; o7 c; v# X3 K# i
clearTimeout(animatetext)
  U9 s4 K2 n: h7 A& H7 e2 H}
) B1 s) x7 B) ^. U9 P6 C
: O2 B3 d$ ?7 @7 G! T$ u/ v- Sif (document.all||document.layers){
, j  C& L" w0 \document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ a  H6 Q6 c; L; M4 N& fwindow.onload = initializeBall;
+ I2 I7 b0 A5 Y+ U- N. a* \window.onresize = new Function("window.location.reload()");# g6 f* I- K( C3 A
}
# C6 f- W8 o* h0 C: j# M; D
5 K( J9 s) q; a) l</script>

返回列表
【捌玖网络】已经运行: