返回列表 发帖

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

<style type="text/css">' h& L; C& _2 W( n0 z) T) T, D2 B7 Z
#supertext {
! E0 [* r% @8 J5 xposition:absolute;
5 L, D7 n/ H- Z8 N5 B7 E( m2 m, V0 Hleft:0;
# D, S1 }, w2 E8 b! i# Vtop:0;
8 C4 c9 r! ?1 u, U2 Dvisibility:hide;" L( U7 o% t) L5 u" n7 w
visibility:hidden;( O5 ]5 N  u4 ?( ^7 D2 l
}- J8 I- t' y7 u
</style>% |! U% s: a6 o6 }& L
<script language="JavaScript1.2">
0 L+ w6 z% ~! _6 q4 _$ s# d8 F5 i8 {<!-- 改变下的字体的大小。颜色-->& S, D+ C* ^( m3 z9 l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 X9 [3 u$ j) b' k  r. b; L' A
var hidetimer='';- `( R3 {- A- j3 d6 h
<!-- 改变下的弹跳速度-->% H! Y. |% c3 n: t
var BallSpeed = 20;
% y& E' Q7 `# c) I6 p8 svar contentWidth;
7 K( r# w) a4 P, @9 Gvar contentHeight;* N7 L" q$ K2 m/ i1 w2 h: B3 X- [
var maxBallSpeed = 50;
8 V! @# e. n! \. [4 a5 N  L# F; R: K0 V. Q0 H
% A0 M2 d! O8 S9 D' j5 I6 }# N
var xMax;3 Y, {2 w  M: L5 o/ T
var yMax;. v& e4 n5 E) N: s: W( z$ j' ~3 a
var xPos = 0;
: _0 c+ W. j7 G! O% ?) V' Pvar yPos = 0;
, y' q! \9 K* L: a8 ]7 Y" svar xDir = 'right';
+ s2 d! L+ H% X. t( F7 \var yDir = 'down';
, C" }  D0 |1 j5 r- g7 s" Avar superballRunning = true;- G) g  q8 q  p
var tempBallSpeed;
6 G5 L2 J; p8 p- b: b2 Vvar currentBallSrc;
4 Q  {5 r' w4 K' dvar newXDir;
4 O9 t1 k* i" y7 q! z& I& Lvar newYDir;
! j! S  E+ Q6 J; q4 R5 `
' i" _' G# R4 p/ v8 Sfunction initializeBall() {
7 |: E" \& y8 I   if (document.all) {
4 h5 M8 F( V3 I9 U5 }' n7 R+ g      xMax = document.body.clientWidth
& K6 m$ r: A4 k4 u2 z! R      yMax = document.body.clientHeight$ @: W9 j( f. k6 \3 C
      document.all("supertext").style.visibility = "visible";8 ^* m6 {' `: I9 ^* R& q
      contentWidth=supertext.offsetWidth
0 p1 c$ K6 Q8 W; {      contentHeight=supertext.offsetHeight) f# j; e* A$ x0 Z
      }
. R9 t0 g- }* E4 l8 Q+ a   else if (document.layers) {: a  Y9 V  B: [4 X0 O- t
      xMax = window.innerWidth;( h& A- U& w: s
      yMax = window.innerHeight;# Q5 w3 q. u! V: _
      contentWidth=document.supertext.document.width1 s( A; X9 d, K
      contentHeight=document.supertext.document.height7 L# i( }  Q5 f0 t% @4 _
      document.layers["supertext"].visibility = "show";
2 p, i- M- }$ P* u% q( f      }
4 Y8 b/ `) m9 q; c   setTimeout('moveBall()',400);; R( H: r' _6 j( y
   if (hidetimer!='')* N5 \) i1 n+ f1 Z4 @
   setTimeout("hidetext()",hidetimer)
/ z4 [& ^, i; c2 F/ |* V   }$ c/ H/ n5 q( k' y9 m# O
* a4 v1 B' w5 `+ ]( T3 H
function moveBall() {
' e6 B9 z! r& }   if (superballRunning == true) {% k" k7 c* f" o; e5 G$ u
      calculatePosition();
  ?) _$ v- d' t8 {      if (document.all) {
( W+ T% R5 v, t  f9 ^' f         document.all("supertext").style.left = xPos + document.body.scrollLeft;7 e0 S, a# T9 u% V6 d8 A
         document.all("supertext").style.top = yPos + document.body.scrollTop;& t: L- b- c6 L
         }
: G- t* f4 A6 K( a$ E5 \      else if (document.layers) {3 H* p7 F; t# o) y# j
         document.layers["supertext"].left = xPos + pageXOffset;8 b, Y$ a/ L  {9 w) W
         document.layers["supertext"].top = yPos + pageYOffset;8 W) A$ t+ Z) h9 f0 x0 [
         }, O9 _( l5 v4 Q* C5 R# D/ X
      animatetext=setTimeout('moveBall()',20);/ C, m' B/ l3 {  h$ i
      }3 [* z: \" M; d: Z$ b" _( g
   }
4 ~( a9 W% v0 `
% ^) r- Y5 T( D3 Pfunction calculatePosition() {
4 i. `$ T7 c& |   if (xDir == "right") {& h' X0 y$ V4 @& W
      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ R. B& `/ y) i7 k9 r0 o7 E! e5 w         xDir = "left";
* C8 z, J4 l# L' r, p         }
& d4 s" a: i% h4 a6 H8 Y      }
0 m. x% A! o! W4 I0 ^   else if (xDir == "left") {9 f* I* Y+ F7 a$ o4 r( O
      if (xPos < (0 + BallSpeed)) {0 ~# J, |* O6 ]( b" r- s
         xDir = "right";
$ R# K7 B1 y  h" D         }5 P; z% {! C# Z6 h
      }
! e! \: P+ e+ X4 k, y' E   if (yDir == "down") {$ Q: N" y+ W+ ~) x) _
      if (yPos > (yMax - contentHeight - BallSpeed)) {* s& f& [; o( h' b; R; o
         yDir = "up";, u% U9 T0 H. o/ o1 {
         }! ^# w& v* R: A/ R
      }' p8 G/ t) ~7 l: S: Q! K& L
   else if (yDir == "up") {
* e3 f$ o% V0 @7 Y, i3 n" S8 [/ c6 H      if (yPos < (0 + BallSpeed)) {/ B+ p* a/ N  l/ D* `$ t; I7 H: Z
         yDir = "down";
& Z9 Y1 h* a* r7 O' s) ~         }
4 m6 f! S  @0 p      }
8 q: P: c4 ]  g. w2 ]   if (xDir == "right") {5 e, P, c2 n3 d
      xPos = xPos + BallSpeed;
* R$ ?& n  r2 l, [      }
: O# G) d  Z% v0 ]" R. Z   else if (xDir == "left") {
* ]6 D; l  ~$ S& t5 m- @1 m  e      xPos = xPos - BallSpeed;
2 |/ n+ A! |; ]: U      }8 }6 L* O5 `# R9 F
   else {
; \# B+ ]" ?* G' ]& [      xPos = xPos;
2 c5 J$ p- K1 ^- m9 b0 v      }5 F6 a' ~; D9 ?
   if (yDir == "down") {5 Y+ K) m0 ^, x6 c+ {# `
      yPos = yPos + BallSpeed;/ }& g, d2 X- e, E3 e7 ?8 R
      }
6 |# `1 v% u" w1 g9 j   else if (yDir == "up") {' j0 Z+ n1 I3 r2 Y
      yPos = yPos - BallSpeed;
& y  A/ \- K  x. P3 m      }0 O# D) Q" L+ G$ U( f
   else {! r% ?0 p0 N! d% G3 r
      yPos = yPos;
- _" V* ~- J) J5 U      }5 t. R. y0 I* Y: _: G
   }
& T/ `' ?7 ^5 U5 [$ C
$ [; ?' k8 m  U4 f2 zfunction hidetext(){5 f  I4 J, r) V: z; e# x) `
if (document.all)) c* X8 K4 s; d6 c
supertext.style.visibility="hidden"
  A. ~' t2 U# k& p7 yelse if (document.layers)
: a2 e* L6 d0 i* ]* r; H# E. ddocument.supertext.visibility="hide"
9 c3 e0 |0 ^7 L' ]5 bclearTimeout(animatetext)+ u0 ?6 x7 ^# X& l  v7 Y
}
# r. e4 }1 h* a: u" s& h# e6 m1 n4 G% E; K+ ]; V( X% n3 I9 X
if (document.all||document.layers){/ g/ c$ h6 T7 A8 H5 k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ O9 e0 ^7 y& i6 X: L% `* ewindow.onload = initializeBall;- B- L5 n. P0 l, Q0 ]
window.onresize = new Function("window.location.reload()");4 J5 F  a9 L" E, D. Z' e8 \, ^
}( Q# {2 Y$ z/ x) _
- o# a3 }. x9 Q
</script>

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