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

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

<style type="text/css">5 m5 s$ Q  E) G- T4 t
#supertext {  z2 v. p" T# _0 H
position:absolute;
; b3 t. T2 `8 r; C) Y; [" I" qleft:0;
2 `; J) G; y2 Z# Itop:0;
3 d& P' ]# c) D2 \visibility:hide;: }$ q4 E$ j, [5 L8 A
visibility:hidden;
: `8 P! B/ ]4 p. g( K" H5 q}
) _+ l5 I8 ?9 D( p</style>  x1 x% o0 a* E  B
<script language="JavaScript1.2">
7 @  R* b6 d) T3 i( v" I, Q! O<!-- 改变下的字体的大小。颜色-->6 ~: k( t* |+ ]# k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( z( O9 L" d7 u) qvar hidetimer='';, O" e2 ^- A# A6 e* h4 L& U
<!-- 改变下的弹跳速度-->
7 _* x. [6 Q6 s. I; avar BallSpeed = 20;) I1 b1 K8 [) a3 l
var contentWidth;
& C; Y6 K5 h4 x" Bvar contentHeight;  ~" E- P$ Y* O* @
var maxBallSpeed = 50;6 W* o$ p: J- C4 I2 Z1 i! E2 U

8 U4 I" \6 T/ {! O5 m% W# S) |8 s$ d2 @; n
var xMax;2 q5 l' ]( P, b- S0 Y0 A" @
var yMax;
8 ?6 V" Q4 K# {/ x3 l% Yvar xPos = 0;
3 @4 v, P- ?. m/ uvar yPos = 0;
( n. U' v! Q+ V* v. W/ D9 svar xDir = 'right';- o# j( L2 ?) U1 }
var yDir = 'down';* O) j2 a- ^/ J2 q
var superballRunning = true;
5 H$ u! U% u' u0 v4 r) Wvar tempBallSpeed;
; v* t! q, `: s# q# \5 F$ Vvar currentBallSrc;4 j! w  p8 o4 w4 ?" `' H5 b
var newXDir;
* q5 ~3 Y: C( Svar newYDir;
% h+ Q3 K$ ?% U8 r8 Z) J- X8 l
  m3 k2 l5 I: u; }" Wfunction initializeBall() {) m3 @, Q3 t9 U1 N3 ]
   if (document.all) {
, W4 F( o5 d# s  R      xMax = document.body.clientWidth
+ n3 J9 c. ^) C$ X5 [      yMax = document.body.clientHeight
7 }; T* j6 Q; ~      document.all("supertext").style.visibility = "visible";. M; n" j$ ~" X# L1 V; f
      contentWidth=supertext.offsetWidth" i8 X# r' f  v( O0 Y
      contentHeight=supertext.offsetHeight& _0 Y5 B- d) t3 [% b
      }3 Y% M; l! W& f$ S! ~
   else if (document.layers) {; R3 g) C& J6 X/ C
      xMax = window.innerWidth;# `1 s& K! Q# V: o3 q: R" W
      yMax = window.innerHeight;
* o5 G# `" C9 x; M" Q) g      contentWidth=document.supertext.document.width. c3 P, M5 ?) N. C% R0 L% A
      contentHeight=document.supertext.document.height. T$ e- r2 ]& t! J7 [: K( R! q2 q
      document.layers["supertext"].visibility = "show";
, I4 A, z6 Z& X9 m) _* W. U      }
. {9 X2 Q* [; |7 c   setTimeout('moveBall()',400);: r+ \3 q2 |* \  r& o3 V" F
   if (hidetimer!='')  c0 a8 X& J2 A: q0 {1 l
   setTimeout("hidetext()",hidetimer)
+ w& v/ u/ v; w7 ~; \; y! [   }2 G1 S( j  e3 }& P

7 V6 u7 H7 {  f% f  Sfunction moveBall() {
5 ~8 s2 D( r8 W& A# h   if (superballRunning == true) {
' R  @0 m* s. S# \8 D7 U( A      calculatePosition();
; `  t2 y/ h6 ^! ^      if (document.all) {8 c1 r+ E2 c- S/ e/ z( a
         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 H7 p2 p( k. w4 T; B, }9 T
         document.all("supertext").style.top = yPos + document.body.scrollTop;; u6 v8 T6 ^; u# Z0 H+ a
         }5 z+ S) }* W, S! b
      else if (document.layers) {
/ C- g! U6 W4 V, c$ p  D         document.layers["supertext"].left = xPos + pageXOffset;4 R: W  h! z3 C
         document.layers["supertext"].top = yPos + pageYOffset;
+ }! F" B6 j+ Q         }: \+ ^  |8 u# @0 U% x* e5 \
      animatetext=setTimeout('moveBall()',20);
) H6 @% z% G( ~# V+ s      }
5 Q" d7 B( O. j% k9 D" G+ ~. I   }* R" ^, i% ~4 I. |
! m- U- }8 R& C
function calculatePosition() {
3 \5 q! x! t. |   if (xDir == "right") {
8 T7 m; u" F4 b7 v! c) k) z      if (xPos > (xMax - contentWidth - BallSpeed)) {
1 w6 H9 N# G8 h2 n- |/ u; g' h         xDir = "left";6 e+ ~9 c$ [" w  T
         }
* H" {4 L5 L, f+ C: {; D2 \. z      }
7 S7 I4 o  S# }4 J   else if (xDir == "left") {
* E3 _8 t' I, v$ g      if (xPos < (0 + BallSpeed)) {
7 U5 T8 C  z8 J. p         xDir = "right";' l& E) A  Z& ?( G* b2 ?* i
         }
. O( c2 f  Z, m$ L: L      }
3 _8 i8 R. n4 J9 r& D   if (yDir == "down") {/ \7 l" C6 a, \6 \/ m
      if (yPos > (yMax - contentHeight - BallSpeed)) {1 H( {, A8 V4 m
         yDir = "up";
/ @+ S$ t. R& p- f7 B/ ~) f         }3 I# f$ }/ a9 V: c. g
      }* g9 ^. R* z1 a$ u3 Y9 ?$ `* ~# P
   else if (yDir == "up") {
- t" F) X3 G) ~7 q$ Q. k$ _      if (yPos < (0 + BallSpeed)) {1 O0 A4 I4 {1 U0 ]6 _+ v2 N& [5 m
         yDir = "down";6 X: ]* d6 x5 Y
         }
$ a# h/ l7 U2 B9 x      }
3 ], v* S3 s" i" z' S% G   if (xDir == "right") {8 o1 ?# ~5 ^* k" R/ V. d! r! d
      xPos = xPos + BallSpeed;) U7 b- O8 A9 N
      }
% N9 E. e7 [* }' I" [3 P' B! }0 q   else if (xDir == "left") {9 y. I3 s) G5 T4 p+ M8 ?( S' P' y
      xPos = xPos - BallSpeed;' j: x  A  \7 M& \
      }( \- n' z  t  V# L. O9 N7 z. T
   else {
- B* m  D& q! I+ A      xPos = xPos;
5 n6 f0 n6 z) J5 _/ h      }0 ^" R" G: P- `7 G$ N5 a; V
   if (yDir == "down") {  H2 T- I; o9 Z8 e' X6 a9 U
      yPos = yPos + BallSpeed;
0 \+ w/ ?) s6 g      }
( Q1 C; l9 K& e8 J3 o! D   else if (yDir == "up") {% @, Z2 K& \! W1 ~! Z; G( c- T
      yPos = yPos - BallSpeed;
  f$ R( I( s# e0 W      }, N  _3 d0 B* a# [
   else {6 W. ]+ w0 d. h1 Z: Q
      yPos = yPos;
6 [( _# v& Z* T) m, Y6 u      }) [2 X5 |$ Y! Y; z) O* T& W: b1 M
   }
; t% j4 u& m* ^  L: l4 x/ y$ \+ ?9 w: @% H' F) y
function hidetext(){& k2 ~+ }$ N8 s. e
if (document.all)
5 J( f8 K# G& F2 B# asupertext.style.visibility="hidden"
% Y3 ^" [( x1 ~else if (document.layers)# X6 y6 x1 p7 G- }
document.supertext.visibility="hide"
  H. |' {/ t+ F* t4 s2 ZclearTimeout(animatetext)
9 d; s# R7 Q- j' O# s$ n2 L2 l, c}
( V1 D6 S0 `/ \& W+ u& R, d- [# y7 Y& q
if (document.all||document.layers){
9 T. b6 H. d! E4 m* e) J* V( Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 O8 c; w% a. V+ X$ i8 w) d/ E1 ^7 ywindow.onload = initializeBall;
: M+ P5 o; m# s( g- }2 ^window.onresize = new Function("window.location.reload()");" p( F! a- t* V  K" z' W
}
! k& [$ |% l4 e3 Z+ ], l$ `/ Y
2 `5 |! q; Y5 b7 n7 H9 N  d</script>

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