返回列表 发帖

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

<style type="text/css">( F) c3 M' u& m, x, Z/ N. `# S
#supertext {9 S- {7 t6 a2 m0 o1 S: _
position:absolute;
; U! c: w; t4 P5 X0 M7 Cleft:0;
& W  c* P) }- q$ itop:0;- Z! I, z9 O- F5 T& c. p) C
visibility:hide;( O- e( Z% k3 W! s1 t: h. ^9 B9 O5 C
visibility:hidden;' b( I( c8 z. V  W8 d9 x
}5 |* o. J/ W% h0 t8 z
</style>3 Y# Y: h3 |9 R( j* }/ _- O
<script language="JavaScript1.2">* D8 M6 [, q6 _! ]
<!-- 改变下的字体的大小。颜色-->2 w5 x; \% F9 W: s- v4 e
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ F9 Q6 q. Z+ h% w2 J
var hidetimer='';* Q8 G  [, }2 v5 ?
<!-- 改变下的弹跳速度-->5 x) n% R9 Y1 g: Q3 I, W0 D* Z# ^3 a  g
var BallSpeed = 20;
7 U. C6 ~' d1 L& ?var contentWidth;( B1 x- P6 G+ r* f/ }1 L: ]. B2 R, n
var contentHeight;
7 E8 u# Q: N* `var maxBallSpeed = 50;* G0 j- j9 D( o" c: Q1 r! l+ w
1 W  ]: i2 ?6 w4 `8 M$ Z+ @" V

! T# H) h6 c7 ~: r( O0 Bvar xMax;: a1 g9 Y5 J0 S3 u
var yMax;
8 V0 H$ }( }& x; mvar xPos = 0;- E- x( R& s: W$ K& k
var yPos = 0;
* d4 x2 n  {9 F- n3 {# Zvar xDir = 'right';: ^; P, v) M5 {: U7 z
var yDir = 'down';0 f  A! e1 V2 R1 J' B
var superballRunning = true;& L7 P2 W7 g5 w
var tempBallSpeed;, d/ o1 v+ t$ u5 y/ d
var currentBallSrc;
! v+ r5 t0 d7 n3 l! }# Bvar newXDir;6 p0 u0 [( ]) S) B& Z1 S
var newYDir;
- a7 x! o6 a) u4 H4 _
$ [- ]; s3 [5 W. @0 U" f( yfunction initializeBall() {4 V- V, S% M/ _( B
   if (document.all) {: b& T5 [$ q0 [* e6 i
      xMax = document.body.clientWidth
  r1 C& r) _' u4 O% n      yMax = document.body.clientHeight
8 _7 v  V2 c' |' J: c      document.all("supertext").style.visibility = "visible";) Q/ m' I5 L/ m& H- _
      contentWidth=supertext.offsetWidth% P  z* d2 P( [
      contentHeight=supertext.offsetHeight
2 P( H( }8 j" z6 g$ }2 @1 P5 K# n6 D4 _      }! L- f- A- S& U# `1 F% R9 {& p
   else if (document.layers) {
/ Y8 G/ `5 Z* |6 x! f( D7 o      xMax = window.innerWidth;
  `; R0 D. P+ `% W      yMax = window.innerHeight;
: q* K# B& u* v, D      contentWidth=document.supertext.document.width
6 P- b# j* s! W4 Z0 v8 z      contentHeight=document.supertext.document.height5 m# I% t5 S* ?; C6 ]. R
      document.layers["supertext"].visibility = "show";
* ?- Q, u6 ^8 O7 ?! ~      }
8 W, o3 A: S0 `2 {0 c   setTimeout('moveBall()',400);
- ~: |  D, |( |2 |$ t   if (hidetimer!='')
, D- W! U3 R2 u/ M0 n+ Q) m, ?   setTimeout("hidetext()",hidetimer)
4 ]( U* ~" d8 i+ R  k9 a% u* q+ ]! w   }
& E. R  @' q( y3 y" t. J9 g: m5 V
$ H' v2 m/ y/ kfunction moveBall() {* ^; B: w/ b7 U' k' r
   if (superballRunning == true) {
# T; B3 c1 p, D* v      calculatePosition();
2 `8 u+ o9 I* F2 `4 U7 h8 J      if (document.all) {
9 C) h' I/ u- d0 ~9 Z         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ H6 R, r# v  Q  y& b5 Q
         document.all("supertext").style.top = yPos + document.body.scrollTop;% l5 R0 f7 l& c4 O
         }
7 O7 G" M. d6 H: k      else if (document.layers) {
! \0 n+ d9 p; V1 H2 L+ g         document.layers["supertext"].left = xPos + pageXOffset;
/ N$ V. Z! z. M: |/ `3 `/ _0 {         document.layers["supertext"].top = yPos + pageYOffset;
/ \" I% F5 M, T" a         }6 K- q& V- Q- u1 v  p
      animatetext=setTimeout('moveBall()',20);
9 s# n5 X, ~5 S# q      }( a) ], f: `. ?* y
   }
) @+ s  l) A' X; _' e
% K6 ]* ]5 o7 g$ {, B% Z4 _9 Rfunction calculatePosition() {
8 L/ @8 x; u; L/ H   if (xDir == "right") {
$ B2 c3 C: o$ f! v- K      if (xPos > (xMax - contentWidth - BallSpeed)) {: d, G' b5 }; p' k8 M/ B; p* v
         xDir = "left";
* R8 \0 D7 H6 D$ e1 d         }1 C, c  K4 M3 ]# \" k& w- |0 }
      }
2 f, s: C7 N: r7 v# h$ Z   else if (xDir == "left") {
% ^3 Z1 ^0 [6 `      if (xPos < (0 + BallSpeed)) {
5 B7 V* j" M: h' E         xDir = "right";
+ K# \5 q8 _- L4 X: u         }' U* k9 c/ f+ a% m5 p! o; b
      }
( X% B0 q$ Y+ Q1 i3 I; G) h1 w" T! S! @   if (yDir == "down") {
8 R7 Z6 ]% o7 W& W7 t      if (yPos > (yMax - contentHeight - BallSpeed)) {
6 O% F) g/ j% Q4 @4 E6 l( C. J( u         yDir = "up";6 z9 Z' H# \- L3 a! o. `
         }
, {: X& r' H: g6 ?& U0 I      }% u! ~# ]2 {0 U3 V9 U
   else if (yDir == "up") {
. S" P, M0 T" ]6 q8 I: [4 h* E4 p      if (yPos < (0 + BallSpeed)) {5 \6 h  r* n2 W+ O. z  [3 E
         yDir = "down";
7 Z3 [) ^8 R# ?         }
  q. y( n% e; E7 u1 h6 k      }
2 @* @7 p+ G6 n9 |- P* m" N$ E4 y   if (xDir == "right") {
1 v# [& O" D, }6 ], a. b  W      xPos = xPos + BallSpeed;; }3 A. o0 K, M! r$ }$ M' z. H3 Y
      }
! }" O8 e# T/ p( h1 u   else if (xDir == "left") {
+ s9 X( n8 g$ B/ M, [: \      xPos = xPos - BallSpeed;
8 G8 c- L8 e1 X2 [0 q: N      }
- o) l% ~3 C% S6 i   else {/ N4 r# e" k$ t; l' x
      xPos = xPos;
# m, d, X+ C6 j% K% S      }; M2 Y2 L& M8 N
   if (yDir == "down") {% G6 d  \. J4 X# d. d2 ^
      yPos = yPos + BallSpeed;
- r! w7 C/ n; g6 \/ W      }
) Y( u2 m7 C+ j" g+ Z- X4 |   else if (yDir == "up") {
6 [- }8 @5 q9 C/ |$ i7 N) t% H      yPos = yPos - BallSpeed;5 l- o, i: t0 ^3 @! _
      }
! c7 P) v- i# L, Q, B4 W   else {
8 o3 R9 k& V4 q9 [6 E, J" B% \8 u      yPos = yPos;
. H5 M# U* r3 I% X0 ]' B      }
) @% [: Y, |9 }: |   }
6 n3 ?( Q6 G9 j% s! _$ f6 [; m6 s/ h# c4 O
function hidetext(){
0 t: F: ~; @# F* ~if (document.all)
4 v2 p* }# J( a3 N6 p6 v& Psupertext.style.visibility="hidden"
; J" K2 d6 I1 Z+ q5 ~' \+ belse if (document.layers)
7 L3 r7 [! A* I( D: H9 Rdocument.supertext.visibility="hide"
1 h3 R9 H% P* V# P$ _3 a$ dclearTimeout(animatetext)3 V: x, e" o) `$ K. f/ u6 {( ]
}
/ g0 X$ b; E; ]% c" ^. E( q- n+ C' Q' B' a
if (document.all||document.layers){7 D3 d6 b, a) U$ `& N
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- s# D6 M. \0 b" Z+ bwindow.onload = initializeBall;
) [7 Q5 t( c. B# u/ }" xwindow.onresize = new Function("window.location.reload()");
* m" z, a- {! C; C7 @& ?}
8 ^7 l/ Z/ |- J- ~3 ~- e# i0 q+ y6 L% H6 p: ^; ]
</script>

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