返回列表 发帖

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

<style type="text/css">8 E! b  s: Z% _/ V1 N/ f
#supertext {3 e9 z& D7 t0 C
position:absolute;9 H% o3 k2 I( l, ^$ a
left:0;
9 }" T0 w/ S" ~top:0;7 Z! C0 ~$ v- g6 _4 e
visibility:hide;( P- @, x: n4 p' l
visibility:hidden;! C7 D2 J, z3 T0 D- j4 V
}$ a$ X. A8 W3 R' L7 F+ @
</style>- P/ r9 k6 H) Y* U0 v) T
<script language="JavaScript1.2">/ c$ p4 J9 M; i! i: |' O
<!-- 改变下的字体的大小。颜色-->
; Q5 x8 S, L% m% cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# ?$ c- ]; P- a7 Bvar hidetimer='';. {0 h5 }8 ^3 n' G0 V
<!-- 改变下的弹跳速度-->) n8 }: u' n1 k7 _+ G
var BallSpeed = 20;# V- R3 \( ]$ d
var contentWidth;+ Q' m0 R" m# B/ N
var contentHeight;
. \) q6 @6 T! m9 zvar maxBallSpeed = 50;6 `' ~7 S, v2 s+ c, G2 e/ w

) e. O$ N) x) ]9 ]% b
$ o; F" P1 i# _: kvar xMax;
9 G8 O1 z3 H( Z% \var yMax;
8 F0 s* q0 A0 `7 gvar xPos = 0;
; v6 o4 i4 W& @, U+ s8 t6 x3 d% tvar yPos = 0;
/ R6 O4 F1 p+ K! Rvar xDir = 'right';
$ p! U' Y0 z5 v+ Dvar yDir = 'down';
8 K; T+ ]" l3 A/ W8 i5 Evar superballRunning = true;
; U7 |1 U3 v! d- M) }/ }var tempBallSpeed;5 i% R9 L6 P( e: B$ k
var currentBallSrc;2 c" p  q2 ^9 Y& u0 Q* r8 T/ G- |
var newXDir;& y. z( K7 a  W6 z% K" w9 ^
var newYDir;
0 F1 n: x) h* B1 b+ W1 \# c1 C, f2 B, V& `5 o9 a. h
function initializeBall() {
, S: l: D# t3 l8 c7 O, @9 o* t! |   if (document.all) {! @9 W- B3 Q" Q+ ~
      xMax = document.body.clientWidth4 s/ q$ _+ z5 z5 Y: D. W
      yMax = document.body.clientHeight
+ D; N1 b6 G0 ?  W* N      document.all("supertext").style.visibility = "visible";" f7 m$ q0 n6 E& V: C& f9 U
      contentWidth=supertext.offsetWidth2 z3 i8 N; a5 Q; R+ S/ _
      contentHeight=supertext.offsetHeight
+ T5 i) r' D# c0 O4 |      }! L3 h  V1 r; s5 R8 |, u0 K
   else if (document.layers) {) y. S0 f3 O) @; Z% h6 ]
      xMax = window.innerWidth;! g  q/ }  G1 z" N
      yMax = window.innerHeight;
  ?8 D+ _+ K! R4 ]  Z3 Q& @      contentWidth=document.supertext.document.width
- b; i: A8 g) `9 q: j9 ^      contentHeight=document.supertext.document.height! h/ F$ g$ M5 a! y# k
      document.layers["supertext"].visibility = "show";
! I4 j* N8 V/ @      }
' W3 H( Y; z- U: ]  j   setTimeout('moveBall()',400);
; ]) o% h% O0 B. B' C   if (hidetimer!='')
2 N. B# h0 q1 _8 v+ F4 i" K   setTimeout("hidetext()",hidetimer)
/ `$ r/ E; r: `$ Z+ U8 Z. F# M! M% z   }
& y, j5 b/ p: O+ }% h1 [$ {$ g0 D: G$ _3 w
function moveBall() {
2 {& p; x" A$ h( P   if (superballRunning == true) {
1 a4 |/ A. {1 p, Y2 d& h3 f/ [' R      calculatePosition();
1 m' L3 j% m) a      if (document.all) {
: n( t5 y9 `0 N" I' {3 v- w* f! Y         document.all("supertext").style.left = xPos + document.body.scrollLeft;/ w' @9 S* Q7 _; I6 w
         document.all("supertext").style.top = yPos + document.body.scrollTop;4 I. R, _) v2 |  O
         }: t% O- y2 {( C0 I# L+ T( t, I
      else if (document.layers) {: _' x2 ]7 _( D2 r3 _
         document.layers["supertext"].left = xPos + pageXOffset;
% q' P1 g% h# m( R+ h         document.layers["supertext"].top = yPos + pageYOffset;
  S! \+ `: \  y2 C% c         }6 Q* V# B" C/ Y, K( M
      animatetext=setTimeout('moveBall()',20);  [0 @( w5 [- J6 \  ?2 V0 [0 u
      }- w* S& J4 p- U8 u: y/ W
   }) p% }! c; d. B0 E
& D) V% a; `6 [4 B
function calculatePosition() {
% K6 S9 b+ l9 e5 k. z6 \2 t   if (xDir == "right") {- s3 h! O! A; \) ?$ Z# i  S$ f
      if (xPos > (xMax - contentWidth - BallSpeed)) {
5 X1 h; b+ m$ R. @. m2 T         xDir = "left";
5 j  S4 b- z5 M9 ~+ A         }0 A' i; ]4 I6 r$ \/ q! k
      }- }& z6 J1 g! q! A+ R% v
   else if (xDir == "left") {
$ l8 l- M+ v# {1 w3 e2 }      if (xPos < (0 + BallSpeed)) {* \: S& [# @6 K1 q5 z9 G" r  {8 l
         xDir = "right";
8 Y% M+ R: |+ ?. q0 m         }1 a" d8 ?  J) H
      }
5 r  y2 P; ~) R( U   if (yDir == "down") {
6 Z# h+ p, s- K. k& ]; g      if (yPos > (yMax - contentHeight - BallSpeed)) {0 V8 B% _5 k: H. S
         yDir = "up";8 x% l% J1 Q" ^0 O2 T
         }) P% t( ]! S: p* I# U' T( h
      }
5 r' i) |+ V+ t* U8 D5 ~- }   else if (yDir == "up") {/ ]( T* n* [0 Z! }2 r. W
      if (yPos < (0 + BallSpeed)) {
% V  Y- {  Z5 T& t         yDir = "down";
1 h) m2 B& T, B4 r& @0 ~         }# S3 R2 }- d/ W# c8 k. b
      }
# I) s- X1 K9 d# k   if (xDir == "right") {
6 B9 ^% ~' A# `- ?9 k3 `% }      xPos = xPos + BallSpeed;
! K6 |  }, @# u      }: M' t! p( w' ~3 d' G
   else if (xDir == "left") {' y# z/ S+ P- C) A# [+ n  V% l
      xPos = xPos - BallSpeed;
! W. g8 }( W# c- d# W7 ]      }
0 l0 I6 `8 o4 P9 ^1 c5 Q5 X/ M4 b   else {
* Q- ^0 d8 q3 z7 P% ?6 f, @) j      xPos = xPos;
7 D! ?9 T5 r& R      }" y' s% r1 g8 F) R
   if (yDir == "down") {
& o4 i4 _; d" Z2 g      yPos = yPos + BallSpeed;
; x* l) b0 t7 p5 }# E4 v7 Q      }
% l( |  r! q* X# [& {3 v+ q/ L, S, N   else if (yDir == "up") {
7 w2 X# e8 F3 H$ g7 m, x, j      yPos = yPos - BallSpeed;7 w% R) v$ J, c5 p0 j' j. \% k
      }: {  U4 m" v  k- m3 E" B( s
   else {' r& h* {3 l' S  s( b$ D& y6 ^
      yPos = yPos;
+ z# d3 \6 C* m, ~      }; ~: T5 g: [  O/ Z3 J  X
   }, @/ ]: S3 V5 ?# L+ k

8 T) X. S3 U, w# L- {( Hfunction hidetext(){( w1 y) ]! w: @* J: ]) B
if (document.all)
/ r, c1 [/ y3 e1 G, k  _supertext.style.visibility="hidden"
7 g5 Z9 C' l( W# V$ lelse if (document.layers)
$ ?: Q8 r$ F; r5 Hdocument.supertext.visibility="hide"+ `# X: z: ?; V9 b. k/ o
clearTimeout(animatetext)+ l* p; U' k3 M# C
}
: T2 @2 O: E/ B2 y8 {  K, H9 D% t+ p' E/ W/ i0 _
if (document.all||document.layers){6 j% \) [- L+ s$ p; N" ^
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ l" M* A1 O/ ^6 u6 P1 [5 @) f) kwindow.onload = initializeBall;* t' \: `2 c, K
window.onresize = new Function("window.location.reload()");
0 ~' B1 d( |7 j" j0 @( n+ L}
* I3 o6 |& g& [9 S/ C( l8 X
4 C* e+ w. h% |6 P</script>

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