返回列表 发帖

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

<style type="text/css">
, W+ Y# e4 Y" z( c& B9 u5 d4 H0 p( V#supertext {
$ k& h; X" C7 a' vposition:absolute;5 }& L$ e+ I$ c) U3 o$ H- U  A
left:0;
+ t6 d9 g# |+ u7 ctop:0;' c  m! d- @# t9 Q" c
visibility:hide;
4 Q+ X+ Q, ?, M0 u% v8 Tvisibility:hidden;
4 j$ F% K7 f: |}) v- T& b$ X& S9 g
</style>
% f, v1 Y. u% ~. G1 a! y<script language="JavaScript1.2">" e2 w( B5 z( x& F0 I5 h
<!-- 改变下的字体的大小。颜色-->
, L2 ]0 m+ x) ?& J- Fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" O% i) B5 [. C/ r. }
var hidetimer='';
* p1 N- z- q% H8 e& T  h<!-- 改变下的弹跳速度--># ], l1 Q1 j/ A3 e
var BallSpeed = 20;
$ n! D3 `3 W! m  E. t5 Uvar contentWidth;8 c+ P" O& [6 ]! J8 T, Y
var contentHeight;" m4 a* Q2 ^$ @) S7 f  b  B
var maxBallSpeed = 50;
- ^) ?( Z' K( n: ]  L* V+ f7 C( t- t6 Z- ?* {1 s, h8 I
( H1 V4 z  H/ J) C* @" v) Z
var xMax;6 _1 P; A+ d: ]; @
var yMax;
% O( I5 b4 Y/ ivar xPos = 0;! D7 L) m4 g6 r! m  M( J
var yPos = 0;
; i& t8 C$ G; A+ N# Dvar xDir = 'right';
% e# i# {1 z1 ]4 p& [7 Jvar yDir = 'down';
; l% S; c/ D& c' P6 U* @var superballRunning = true;$ T( q) R) k8 P$ t& M( G1 U# u
var tempBallSpeed;
! x4 _, h7 E9 x  k- |9 F0 W4 q1 Tvar currentBallSrc;
' R6 J: F1 A$ K' wvar newXDir;2 J2 L1 Y- y" m( S
var newYDir;
: I6 e6 i/ d) N% B
) S9 w* e# B8 q' p$ @function initializeBall() {
% A1 p* @2 k% Q' w* Z6 w& S   if (document.all) {
. Z1 _- g8 |' f( |8 s, y      xMax = document.body.clientWidth
5 z9 ^! P: \4 g3 m3 Y; a- Z: w      yMax = document.body.clientHeight, a, D8 e- A6 r) G% Q+ I
      document.all("supertext").style.visibility = "visible";
! S) e+ \/ p( S0 v      contentWidth=supertext.offsetWidth
. J& }& V* _& |  M      contentHeight=supertext.offsetHeight/ K0 i* ^8 N. C  {+ s$ X% X) n( n
      }) U) M! |* B: V5 p( R
   else if (document.layers) {- G: q! }2 ~7 [. k2 }0 M& f+ a
      xMax = window.innerWidth;% E5 e2 U0 f/ b" X) N$ ^8 |
      yMax = window.innerHeight;$ q5 d/ y' P2 w$ G8 _# ~
      contentWidth=document.supertext.document.width& ?9 Q' L0 f: `
      contentHeight=document.supertext.document.height
7 M1 F: c, v, K2 M; h. Z2 d      document.layers["supertext"].visibility = "show";
" F5 I5 j% Q8 i' c& ?6 U- H2 H. a5 L& i4 M      }
: N4 r1 H% D. @2 V) h1 c2 z   setTimeout('moveBall()',400);
( N, K; Y  ]# y8 W9 X" ]$ ?   if (hidetimer!='')7 ]+ \8 Q: L6 H& k) P2 ?
   setTimeout("hidetext()",hidetimer)  S4 T3 G, H6 P9 t! I
   }
5 |7 e8 B0 X+ b9 p1 v( V# T! p7 d6 {, s# o1 g3 [) q% X% ~
function moveBall() {2 S! ^9 p# I% [" R- \' W% L
   if (superballRunning == true) {0 i" P" R/ c7 O1 T. l+ N& y
      calculatePosition();
! ?; [- V* H" l3 s      if (document.all) {
5 u+ K  A0 `7 F( Z3 @! J& |; v         document.all("supertext").style.left = xPos + document.body.scrollLeft;; w8 J, P+ D- x
         document.all("supertext").style.top = yPos + document.body.scrollTop;, a" l- k( Z5 p% @$ s* L
         }2 y( w4 ^" g1 i9 g* q3 d) o1 [
      else if (document.layers) {8 Z" b0 `) V$ [) j* v7 `5 ~
         document.layers["supertext"].left = xPos + pageXOffset;
$ \. N4 i, u( m         document.layers["supertext"].top = yPos + pageYOffset;
) Q; w& g/ Y, |& i         }! a# Z: E& o( W( V
      animatetext=setTimeout('moveBall()',20);
# {$ o" i& k- I) g% d& p      }6 F  ~( c9 ?, D" w6 Z  e' `8 w
   }: O( w& i+ ~: X9 T: F, j. c; Y

3 d0 u* h. y. h" |function calculatePosition() {
% r+ j3 b! ^* S0 O" m  z8 r9 J   if (xDir == "right") {
0 d: R5 a* m' G  [  p+ o& y      if (xPos > (xMax - contentWidth - BallSpeed)) {
! `3 H! E1 j0 [         xDir = "left";
' h% k- b" |+ F  A* q5 ]         }- w1 A" j$ J  k" |* {
      }0 e% V# \1 b! Y. N
   else if (xDir == "left") {2 r7 B2 X3 r  v3 g
      if (xPos < (0 + BallSpeed)) {
7 ]5 D0 A9 ]) J* ]$ f/ [. f         xDir = "right";
# n9 v$ P# M/ |8 o" a; Y! u. d         }0 W) z$ s0 \' Q, R9 S+ d
      }; d1 \2 F+ `1 v) B0 Y
   if (yDir == "down") {+ `1 T$ |( C. B. ~3 w& j. ]
      if (yPos > (yMax - contentHeight - BallSpeed)) {+ I) P8 N1 A1 a$ u$ p
         yDir = "up";
: G; k8 @1 c$ O+ U8 y5 T         }* C% i& J$ X0 T3 ]& C, g
      }* V3 m$ y: |$ J; L
   else if (yDir == "up") {+ n# ], ^3 L5 ?; P5 G: \) c
      if (yPos < (0 + BallSpeed)) {% Z' B% H& x& G- X
         yDir = "down";
1 f( c7 d4 Z! x/ b; l! n; d         }$ {, ^$ ]: P0 l1 X. Y) g
      }
; a6 U" f4 Y3 @3 v; r  z   if (xDir == "right") {
8 [4 N2 W; V5 }" ~3 U6 y$ ]  ~      xPos = xPos + BallSpeed;
! s' B' z, ]! H% @. C" z      }
9 r/ `6 j3 s  x- T   else if (xDir == "left") {1 |9 f+ u( q- E0 Y( F- s4 ]# V
      xPos = xPos - BallSpeed;
# C" N( P- B- i. l  H/ I3 o3 U      }  ^( C) l/ d5 O0 [: u
   else {) h  I% w9 }) Y" O! Z
      xPos = xPos;6 {4 `7 }+ D* L7 D: }/ g/ b7 l6 Y
      }% j1 i* ^9 O* D
   if (yDir == "down") {
1 w9 t' J. _' W: O* M      yPos = yPos + BallSpeed;
$ X- b/ I7 C5 q& H9 }% y# V      }0 e: Q/ _5 n. i; v  u: D7 h5 l
   else if (yDir == "up") {# P1 E& @. B# [6 p8 D* {1 X* z
      yPos = yPos - BallSpeed;
2 S, R+ |' a5 c( A* x, F5 Q      }
* ^" x% _' q3 t6 p   else {
  G( g, g: }9 G+ i0 H. y      yPos = yPos;$ z8 D- c  e8 N+ ^
      }, B# N' u; e4 T' o, d. z8 a
   }
0 Y% E% U/ W6 u2 B% a4 [1 I8 ^
8 L' Z% l$ P2 n$ ufunction hidetext(){
2 L: ]  c6 m+ v( H& }if (document.all), Q4 E$ y! ^. F; p3 v& M, x
supertext.style.visibility="hidden"
4 {* C9 L$ t5 t6 ^1 b. zelse if (document.layers)( N6 q  g# G- v/ R- J7 q, @0 m( _8 i
document.supertext.visibility="hide"
; ^" C1 T4 |9 z2 ^" DclearTimeout(animatetext)9 |! }- A: h9 Y: L) c5 h. y) g* A
}
# A8 Z4 [; V9 r: q! m" N6 \
; e  f3 n' i1 Z, h3 q+ Sif (document.all||document.layers){8 J) L9 j& L" \" s5 h- F/ S
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 V7 p, y3 C6 Gwindow.onload = initializeBall;
! D# F: l4 Y, ]0 x8 s# [window.onresize = new Function("window.location.reload()");
+ @% U7 c5 c& A: ^1 A. t}
: M/ _/ T' ?" D  p( A0 z% |) D* R2 c# i; ]/ O' t
</script>

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