返回列表 发帖

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

<style type="text/css">
8 ^3 B9 x0 x) X, S* H& f' F#supertext {
' r9 x, F1 q% x1 G4 q$ [0 R& i) a" g) Tposition:absolute;
  C( h) G% f' T! c/ Y* e6 tleft:0;
( T( ^7 O! U6 w3 N) mtop:0;
/ g- V( q  A" }9 j7 ovisibility:hide;' Z' W- x- Z  a% H+ R8 V
visibility:hidden;
9 `/ B, J2 q% B, s8 l; t% Q}
, N( f  f( E% b$ W$ c</style>& K  m- K# Q, f' [
<script language="JavaScript1.2">. n! {. y6 \2 C) a: M
<!-- 改变下的字体的大小。颜色-->% d1 ^% q0 r% d, Z8 b9 c3 R2 ^+ [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 h1 v, U: I5 p
var hidetimer='';
* Q6 a, v% Z) C8 w# O. \9 k<!-- 改变下的弹跳速度-->
* E2 a2 `. N( e9 O/ p) A/ n- b8 Xvar BallSpeed = 20;# I* |) r( B- N6 g
var contentWidth;
' N5 i  U5 G) D/ \var contentHeight;
; n) j! l. A( R# b& O. pvar maxBallSpeed = 50;0 O  R; k! V8 j0 l  j
# B4 d% a: a/ l% a  o
6 X/ x- V% Z6 F" T: G5 K$ J% i' P
var xMax;3 Q5 v9 |9 l8 x! `
var yMax;  D# L4 U% x7 A" \) L' W, k
var xPos = 0;5 R" L; s/ o0 V0 N7 O7 w8 _8 ^
var yPos = 0;( b5 h  D: x; p( N' \8 @: ?
var xDir = 'right';( n9 h$ D7 z- J$ _7 D1 `3 R( l
var yDir = 'down';' @& [4 t3 Q) L: [+ D! v
var superballRunning = true;( m9 N+ I; }4 W! ^6 O* w. y0 D) K  r
var tempBallSpeed;: T3 X) p% ?3 D1 [) |9 g
var currentBallSrc;( I- u4 t5 ]8 E. E
var newXDir;: @5 W$ i6 h. n/ e3 x
var newYDir;/ K( i4 v0 `/ H7 O- Y1 ?$ l, K
. K1 Y0 s2 Z* ~# d- ^" F6 E) T$ D3 _
function initializeBall() {
% z. |4 B  K  x# o3 D1 d  D( i' ~   if (document.all) {
3 E7 @  o! _4 P$ j; H0 [      xMax = document.body.clientWidth! Z; T9 L% G2 v9 V% o5 Q+ t7 w8 q
      yMax = document.body.clientHeight
6 [7 y- U8 W* p+ |      document.all("supertext").style.visibility = "visible";/ ?- a5 j2 @  n$ n4 O
      contentWidth=supertext.offsetWidth
8 l! p7 V4 f& g' _      contentHeight=supertext.offsetHeight
+ x8 v* }1 g0 T0 w( |8 S2 Y      }
6 E) F" J$ W6 f1 D) H. [   else if (document.layers) {
" _) g0 Y8 ?! n1 j/ `4 M      xMax = window.innerWidth;
9 c! j1 Y- n7 F5 e      yMax = window.innerHeight;
+ X% t! |- q; F  w* j      contentWidth=document.supertext.document.width8 G+ q( b  L9 g0 O6 P- j
      contentHeight=document.supertext.document.height
& u" W7 Z6 O( ?% S4 ~& b6 n      document.layers["supertext"].visibility = "show";
5 k/ W* y; a& R; D- _8 W2 K: `/ P      }/ a  Z3 L4 z. d+ D7 e7 o1 k
   setTimeout('moveBall()',400);
' w4 ?/ Z* g6 l+ S/ ~# E% G   if (hidetimer!='')
6 Y2 o' l4 _' Y* z/ k# I   setTimeout("hidetext()",hidetimer)# h- m+ ?' ]0 k9 [; X( j  P% r, x
   }
) S9 M( x4 z3 |5 {* S/ f( c
5 U5 K) [0 n0 G# e4 yfunction moveBall() {- F/ ]# A9 s( c
   if (superballRunning == true) {* N8 G* R* p2 n% I6 M. C2 \+ l
      calculatePosition();
9 H" m0 ?/ B% A      if (document.all) {7 d: n5 p7 f# o, `2 K, e
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
: V: `( X/ W# X4 x& k0 C- a% _$ e' l         document.all("supertext").style.top = yPos + document.body.scrollTop;
: z8 w7 I7 b$ p. @% F$ i6 q) x* y         }0 ?) L$ N: w) s9 x; j
      else if (document.layers) {
# P1 Q3 C6 x7 t( G! B         document.layers["supertext"].left = xPos + pageXOffset;1 T) X8 ?1 z; `& @" g
         document.layers["supertext"].top = yPos + pageYOffset;$ Y3 |& d2 i! f6 }' q; a/ E
         }6 W0 }! F/ J4 h+ }1 P
      animatetext=setTimeout('moveBall()',20);
7 l0 t$ E' ~! W- \) B$ k      }* ~$ h, M9 i/ i" x
   }( ~; e0 X! u" t& W4 w& e1 i

& `- H/ M+ _+ X4 p( Afunction calculatePosition() {
7 P+ G, s2 \; w- {   if (xDir == "right") {
9 `4 i% I% L5 a# i  F      if (xPos > (xMax - contentWidth - BallSpeed)) {
( W! P8 W6 H$ f* ~- w% J' B0 y4 E         xDir = "left";# [% W" z3 }' P: {" G; E; M
         }& x; m# E4 ~% P$ Y2 _2 T6 W* K
      }
! Y$ g$ C2 k1 G   else if (xDir == "left") {1 C, [6 v% `, n. `- a6 `2 x/ E/ M
      if (xPos < (0 + BallSpeed)) {6 R$ ?* e- i' u& i4 a
         xDir = "right";
% K2 m+ ~# [# B# \2 l1 \         }
7 k, d; {4 U6 o- f6 g) U) L0 \+ i+ Q      }6 x5 @/ ^+ t% c8 e
   if (yDir == "down") {! P: h+ b6 a7 N- s6 b
      if (yPos > (yMax - contentHeight - BallSpeed)) {1 c1 \- C# ^; v- T5 Q' Y6 a/ ?
         yDir = "up";1 G3 }, A; p, Z! x1 O$ f
         }
5 S2 |$ T' x0 G  s/ G: {6 c      }8 `  H  Y+ W: W- J+ F
   else if (yDir == "up") {
9 Z# C; H. ]+ J  Y9 r% [' |0 z9 X      if (yPos < (0 + BallSpeed)) {
3 F" t) p1 u( \         yDir = "down";
. ^, E% e1 I% L) P0 M& _         }
1 Z" N5 A0 ~" C( L      }6 i& |6 H9 l* P4 H
   if (xDir == "right") {
9 [) y/ j, g  E  \3 u* ~  i      xPos = xPos + BallSpeed;
' L( j9 i( t8 F, Q      }% @( H" C/ _5 k: }' q
   else if (xDir == "left") {
/ ^9 L! X- A: D3 h6 P% Z3 E, |      xPos = xPos - BallSpeed;
, `: Z2 N" \5 W, I      }
, }6 u% m6 V4 k2 S5 L8 }   else {
6 @' V- |+ W. ~      xPos = xPos;+ F( P$ E0 N! x1 w6 L: h; z& `" a- M  n8 r
      }+ q0 }$ [& }* y$ ]$ }
   if (yDir == "down") {& K+ ~6 }" Y* L! f0 Z1 s% w6 |, D; Z
      yPos = yPos + BallSpeed;
: ^6 E! g4 }. X- S3 p" S9 z      }
3 H8 @' J1 i: B3 s  @4 A0 N4 {   else if (yDir == "up") {
" c3 N: g8 M; }' g- S3 t) ~4 u* e      yPos = yPos - BallSpeed;# x; Y" ]' _& N  @
      }! I4 w0 x9 b- P
   else {
! W" U; G+ f; K" o% y5 t% Y( F0 ~      yPos = yPos;3 i; S) p2 n) F( }
      }
, ]) Z  R( J+ G2 ^   }
6 r, A6 k+ l+ L  H& Z9 e4 e9 g* S# W7 ?& v2 b0 |
function hidetext(){
$ a8 G6 l; Z& tif (document.all)+ |7 s4 }+ x5 K( ?
supertext.style.visibility="hidden"
! o, V# j0 D. [% @. r7 I8 N- E" Oelse if (document.layers)
9 O3 g# E0 O: o' y6 V8 [( F: e% P+ l" Odocument.supertext.visibility="hide"
/ j. g' Z8 L8 B4 KclearTimeout(animatetext)
* M' r% q" m- t' ^}* M& L0 c1 ~' ^; |/ V2 E
9 B: C/ {" g- U: [- U5 p6 K2 U- Z
if (document.all||document.layers){9 d2 T" w3 E8 S5 C; f" C* |2 b3 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')  Q1 R; d- S$ p" ]& g2 r
window.onload = initializeBall;7 D. @  g! |0 Q: W" r2 t4 w
window.onresize = new Function("window.location.reload()");( |7 c0 e$ N/ X
}
2 U3 S( b* U0 ]8 j7 g2 E" ]1 r+ y8 r/ D( \
</script>

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