返回列表 发帖

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

<style type="text/css">" A4 s. F: e3 o* u! Y% N" _
#supertext {
: U' u2 z) C) T7 Y# Qposition:absolute;
# Q) S4 N1 N% G8 D$ o2 Dleft:0;
$ p) Q, W5 x' htop:0;5 B, z* f/ O( v: i
visibility:hide;
$ N8 {* B- a9 C9 b! xvisibility:hidden;
& _( I% j! L( \' h: Q, e' }}( j. U! F( z& ~) I# x* D
</style>
$ ^* F3 B' ^, y<script language="JavaScript1.2">
: b8 _. b3 K( Z3 q/ T<!-- 改变下的字体的大小。颜色-->+ A; h- s) U1 X% o, j
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" p8 ]( K) \) a$ tvar hidetimer='';
( F$ D1 N0 ~2 a& D* F. A<!-- 改变下的弹跳速度-->7 ^7 P- K5 X" n0 H9 ]# S7 H
var BallSpeed = 20;
9 s9 k% Y: \1 y3 g! fvar contentWidth;
6 S3 y: t) F+ a& i! z' Uvar contentHeight;
& X" W% A$ D; u9 cvar maxBallSpeed = 50;, _5 X, c; i5 u: M! t

0 l: g: {* w' P9 M' @0 I, f3 |. @: O6 x( F! X1 B  z' q, o% p
var xMax;
2 O# o2 u* w" c5 s/ gvar yMax;
& ]: V" R6 i2 Rvar xPos = 0;
% A: T) o) |9 Q2 L9 qvar yPos = 0;9 r9 e6 T$ z. u5 p2 O9 J- M
var xDir = 'right';' u' b2 M& t6 x6 \% ^
var yDir = 'down';
  l; F3 L& Y4 t, Hvar superballRunning = true;
* ^) E: h. z, w0 p2 avar tempBallSpeed;. m7 q% C% C; I% [! O5 H8 R
var currentBallSrc;
' A; e" e" N9 z9 [" g+ S! Pvar newXDir;
8 b* e$ H4 t0 N' ?% z& ivar newYDir;" a& |  P, Q* @8 h6 k

  j% ^) _9 E; r6 n1 [# J( _function initializeBall() {- J9 r; Z# C* Q
   if (document.all) {" f+ Q9 X" k* R, ]3 A
      xMax = document.body.clientWidth% f$ x+ P. I' t" R) J* L& B; r
      yMax = document.body.clientHeight
4 u% U( T3 @; {" G, D      document.all("supertext").style.visibility = "visible";8 r, K6 r0 }% ]2 J
      contentWidth=supertext.offsetWidth% Q- s0 P& x5 T: @  j* e
      contentHeight=supertext.offsetHeight
% {4 ~3 }6 }# w# D. |& ]      }3 |) n2 L6 T$ W
   else if (document.layers) {  _! V# w. J& \+ A$ L' N
      xMax = window.innerWidth;9 t* G3 o+ U- W$ r! e
      yMax = window.innerHeight;' Y; W, T. _* |0 d; e, o$ ~7 G
      contentWidth=document.supertext.document.width
/ Y! @2 k! {7 p      contentHeight=document.supertext.document.height
: q+ A* J( i9 R2 s+ \8 H5 {+ `      document.layers["supertext"].visibility = "show";- l7 c1 W; I5 I  |+ {% }+ |! F% S
      }
1 H6 o  X  W0 a, c; ?8 g' A   setTimeout('moveBall()',400);
9 t# G/ {# A' I4 N" I   if (hidetimer!=''). O- l- W; f8 `# @# D9 s
   setTimeout("hidetext()",hidetimer)8 S6 X+ _+ M2 J, N6 |8 A
   }. p/ c& r5 A' r' e# T9 a: M

" Z$ D6 c* \. `function moveBall() {
! T7 c# |. P; ^/ L0 c; j6 ~: ?   if (superballRunning == true) {
/ O2 h3 x# Z: ^      calculatePosition();( ~$ i  U* V9 {: {% K. A' R
      if (document.all) {7 r7 q: J% I: i
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" O; ~: v: U" o- y, z4 o3 |         document.all("supertext").style.top = yPos + document.body.scrollTop;
7 \; N( |7 P( |! B" ^3 F) x         }6 B: m6 z" ]7 @0 @4 H: K
      else if (document.layers) {
: D' K% k5 A3 z) B$ E( T# q' i4 G* M         document.layers["supertext"].left = xPos + pageXOffset;
9 i. e) I+ ?7 s' l# V5 P( u         document.layers["supertext"].top = yPos + pageYOffset;
. c# a- x1 n+ I3 D) q7 e( P6 o         }
4 y$ q! z& F0 K2 ~. n      animatetext=setTimeout('moveBall()',20);& F: a7 r; o5 P2 ]4 d& o' P' h
      }
7 t7 ~$ P) b$ w# O   }3 ]+ ~" G+ g6 R. Y9 U1 {, Z
; O$ ?& V$ A- M3 t
function calculatePosition() {5 h9 H/ c8 O4 `+ g1 E. f
   if (xDir == "right") {
" K  R  F7 h& o      if (xPos > (xMax - contentWidth - BallSpeed)) {
( j1 E4 y$ Z/ v' u. d& j         xDir = "left";5 f. c! n$ R9 X( n8 `7 i
         }0 ~0 }6 k. V% h
      }
& ]4 t% I$ D! Z4 S   else if (xDir == "left") {5 l* I8 h2 C8 ]0 c$ g
      if (xPos < (0 + BallSpeed)) {) v; }0 z$ j6 J6 Q& o6 |. E
         xDir = "right";% f1 }3 _, D9 `; ]3 j- `1 X0 g
         }
" G/ ^3 Y1 T$ a% q      }
  d4 @+ t6 m. I% f   if (yDir == "down") {
; c0 g* o" l+ W& ^8 y, o      if (yPos > (yMax - contentHeight - BallSpeed)) {6 T* r( \% v# w* Q+ o0 G
         yDir = "up";
% H& [  _7 S% Q# X* w& l6 d         }; `) A7 J& t! o& |: g9 ~
      }
8 t0 `* l9 i2 g' E' I  i: X   else if (yDir == "up") {
3 k: w' `0 }% h' W- T/ I9 ?      if (yPos < (0 + BallSpeed)) {
# H9 p' p5 x# I         yDir = "down";
7 |5 w! p: U: A4 `$ X5 O         }( |& {5 [3 H6 o4 E: K
      }1 j4 j7 ]  ]* f2 }0 B" _
   if (xDir == "right") {
/ w, R; _! D  m; |% f/ g" ~      xPos = xPos + BallSpeed;5 C6 @: `$ c0 P2 p5 {
      }6 q; g6 q9 r8 q9 |( B. m' B6 o
   else if (xDir == "left") {; n+ o3 J" V( ]( M
      xPos = xPos - BallSpeed;! w+ T: G2 C- v7 k. h, m
      }
! q$ e. J0 E. x# F" i0 [   else {
! M* V- f' Z$ s* S      xPos = xPos;
: X0 ^8 |" x5 C3 I$ n      }5 T4 f" o" C/ V. \+ E
   if (yDir == "down") {9 \. B2 @2 ]$ L$ G- g
      yPos = yPos + BallSpeed;
$ Y; x& l, j) k9 ^6 }5 N      }# E0 P! n/ B- Q3 Q
   else if (yDir == "up") {
9 Z* B9 n! R! M) D2 K; X      yPos = yPos - BallSpeed;0 |* {! [9 h/ B
      }
0 ~8 ?; m4 o! Q1 a& X0 W- d  r   else {5 I8 S, r1 X$ e0 |% O" P) l
      yPos = yPos;8 c+ A4 O  U' s& h  P1 N3 U4 s
      }
9 G: x' I  t( c   }
6 d4 Y4 o4 B& x4 r; ]8 C! k" U- |7 y$ _. \+ D
function hidetext(){; G% f9 q8 l' S2 P" `; v
if (document.all)
) m8 Y8 d( F0 s  ^( Wsupertext.style.visibility="hidden"
: J$ \6 A  g: [: @$ [& i9 Velse if (document.layers)
1 M8 U" E4 [$ }$ bdocument.supertext.visibility="hide"
; d( D2 n# G7 R$ \/ QclearTimeout(animatetext)- P9 R4 E; ^: z5 U
}% u$ S* j; e& z+ I1 O- X; ~" }2 j

. K, Z, ~5 T3 X1 ~if (document.all||document.layers){
8 A4 o$ |7 l6 L) R! `  kdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ j7 i7 S) c8 D4 t# A0 l6 w) b+ b* m0 M
window.onload = initializeBall;! l, o! w/ C& [+ h/ F
window.onresize = new Function("window.location.reload()");
0 C* c  ]. N9 @- w" j' |}
; o' z6 G) Z# N0 D) r& ^
: o* o- m" }6 X2 w% Y" i</script>

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