返回列表 发帖

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

<style type="text/css">8 }+ r% ^  y( c) X, g& D% |
#supertext {
: R- P; F+ B" L# u8 xposition:absolute;9 P( ], ^7 ~  I* X
left:0;
* j% {$ {$ E0 ~7 Ztop:0;
! P" A8 n  b# d5 cvisibility:hide;
, e& [$ r& G- |  h% b6 i1 kvisibility:hidden;
- J: K. u. q$ f' x7 v- ~7 q}
8 H+ p8 F/ \9 P8 e# s  s/ P# x  L8 U</style>5 i' ?4 t# j# l* h2 b, `1 m8 C
<script language="JavaScript1.2">
- X, ~9 R1 L) ~5 B<!-- 改变下的字体的大小。颜色-->
9 l4 s  L$ d  P3 l$ p7 u+ {var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ U+ G6 b, y8 M( G0 I
var hidetimer='';
! i2 L% M6 p0 o  d! O2 d  h0 `<!-- 改变下的弹跳速度-->
/ X! n  l+ a8 b2 t8 z( U0 h9 p8 n$ cvar BallSpeed = 20;% l' m$ H0 l5 I: T
var contentWidth;  c3 j5 u: J* y+ b0 k0 u+ T
var contentHeight;. h1 n* {" }+ A% `* G; d  L6 i
var maxBallSpeed = 50;
2 A+ R) w5 d/ }' M' \2 k
  D2 x4 b6 ~8 X+ ~& _
3 g5 B, \: r: W$ N: o0 Svar xMax;
/ m# J+ V$ R& m% D7 _0 cvar yMax;7 ^9 A1 s! R( h9 E6 N! C( s
var xPos = 0;8 M  \8 Z. d% N, c/ H
var yPos = 0;$ q6 v9 U9 n/ H) W" L, ~4 v* s! i
var xDir = 'right';
% P8 s5 S" I) \var yDir = 'down';5 F$ Y  O" {& i+ A
var superballRunning = true;0 i1 L" Q9 H; i
var tempBallSpeed;. S) Y; W- Q! }4 u
var currentBallSrc;
+ K* O- Q' L$ z% Gvar newXDir;/ J6 C' T. x; h2 h! a2 _! k  ?& V" V3 X
var newYDir;! t1 }0 K5 `+ y# S2 G- C% {, i

+ b0 `" ^* m2 ]+ p0 f( w  E$ _8 A; @function initializeBall() {
4 k) i. G/ T: i   if (document.all) {/ \. k5 W' C+ m9 O3 L: F3 D% L% s
      xMax = document.body.clientWidth
) G" @  s, {* \; D- I      yMax = document.body.clientHeight  _% A6 v2 f7 [! x- T# Z& d5 I4 w5 Q
      document.all("supertext").style.visibility = "visible";
. R- Z3 D3 t8 p+ l) J  T! P1 ^      contentWidth=supertext.offsetWidth
& @2 W. Q1 I8 ]      contentHeight=supertext.offsetHeight
" }, m2 l4 c4 r* b+ p! f      }
( t9 j9 z! f/ c- y5 \   else if (document.layers) {
- j2 f; t' o9 h) y2 h; t9 f      xMax = window.innerWidth;
% u! _, F4 I- ~7 X1 U$ H/ l      yMax = window.innerHeight;" ~4 E# A& h: O! ]
      contentWidth=document.supertext.document.width- t. z: G% }! h2 Q3 ]
      contentHeight=document.supertext.document.height1 H+ _% M1 t+ t% {9 |" U  o
      document.layers["supertext"].visibility = "show";' V7 q  P# n/ t3 T1 j( K+ W+ l, d
      }
( ^  G. {' M% w# ?. @& [$ C0 x   setTimeout('moveBall()',400);
2 D5 U0 Y6 t, K4 z   if (hidetimer!=''): F( u6 }) i* b
   setTimeout("hidetext()",hidetimer)
3 }% G; x5 F" ?( e. l$ @% F% a" @. E   }
* D) m3 H6 `$ e" D& ?& W- D+ W. r5 O+ y& B
function moveBall() {
/ G7 b' c# r% A6 U9 q5 N6 V; ]+ G   if (superballRunning == true) {/ [9 I; T8 r+ X& H
      calculatePosition();2 C- ^8 d: s, W+ v# \: E) ?
      if (document.all) {
2 t- I7 `3 s, e8 `         document.all("supertext").style.left = xPos + document.body.scrollLeft;
7 {% C, O0 ?+ \  f. {* o$ {         document.all("supertext").style.top = yPos + document.body.scrollTop;5 _$ B- L# q3 t- Y1 _' U9 D6 R
         }& Y5 H7 |; T  l6 k, i) f3 C- `7 ]
      else if (document.layers) {
- a- c% ]/ c5 c  Y+ ]  }+ a9 ^         document.layers["supertext"].left = xPos + pageXOffset;/ |9 f3 B, K4 ~0 I
         document.layers["supertext"].top = yPos + pageYOffset;
) s; ^2 I1 L5 t6 e( E         }: Z5 M5 |/ I/ \. J) ~
      animatetext=setTimeout('moveBall()',20);
4 h5 M* Q* S' l2 N# n1 k: i' \      }( A- u1 V* m3 n# H6 v# P- k6 [; l
   }
; {# d! `4 G, T3 {0 b; d5 |$ y" w) Z
function calculatePosition() {
- `8 d  _7 y2 a" w' J9 Y   if (xDir == "right") {, O' B, H7 E" y4 a1 L
      if (xPos > (xMax - contentWidth - BallSpeed)) {
" m  Z) I3 w. A- a( c1 X9 h/ }         xDir = "left";; Q- ?8 T; |: D( D4 z  V/ O2 l# W
         }  ^+ j1 I5 p+ h8 S5 A
      }: ^4 o3 Z7 ]4 q6 i4 V( E% M
   else if (xDir == "left") {
; h. X, V7 l# f) d( G4 x3 Y* k      if (xPos < (0 + BallSpeed)) {% v' q4 }" Y7 s# v7 K5 G# J: B; M
         xDir = "right";
4 @, G$ N- l4 W/ T: D. k         }
9 E) C- |$ X6 e( R; j1 ^      }: ^$ y  i% |) L) g4 [
   if (yDir == "down") {; q9 e3 z: i7 c
      if (yPos > (yMax - contentHeight - BallSpeed)) {, G' W7 f. r# n5 U
         yDir = "up";' k$ _. |0 ~" e& |
         }
; w- q8 X; f" k. p" T9 |/ _  ]% |      }  n, |. n) Q4 O& Q( _" z
   else if (yDir == "up") {
3 U: |+ q* H* |- x5 _$ D      if (yPos < (0 + BallSpeed)) {- V" E1 E. l: I& k8 Z6 ^
         yDir = "down";/ ?$ U7 r2 J6 M" K8 D3 _3 Y& z- I
         }
& t/ n4 X* j) N  D- B      }
* k5 G( k$ Z* G( X, w   if (xDir == "right") {6 f, O) h5 e* J: \! s
      xPos = xPos + BallSpeed;/ `) D$ w' X, i4 s* e
      }
% N7 G! p# X' i9 X) @! r   else if (xDir == "left") {
: R  Q1 D" Y3 z3 C      xPos = xPos - BallSpeed;6 \0 k6 j6 F8 A$ J- d- u' W
      }+ P4 P; ]+ n2 }6 D
   else {+ ]) P* w( G0 E
      xPos = xPos;$ E  i: W1 {% O2 z5 K
      }( U# @9 M6 b4 b+ l1 D( Y! O; L
   if (yDir == "down") {6 l) S1 Z' o# {' p7 \1 N0 j
      yPos = yPos + BallSpeed;
+ @2 J0 j! h8 |/ [* L5 p      }
$ X+ J4 m  t& s' Y. {   else if (yDir == "up") {  x' Y  H1 [3 I
      yPos = yPos - BallSpeed;3 w: `* g7 I$ Z* X% n/ G
      }
. r3 P4 S: F0 J   else {8 p/ H; t8 h( ~% \$ j$ e, w6 T
      yPos = yPos;+ h, A# E7 n$ U! N1 W1 U$ L  ~
      }
( s! D' t* J6 I$ L   }1 `, H* C: @* L' _+ E: F

/ k& h' ~8 D" i" \4 K- r, d$ ffunction hidetext(){0 k* T' B9 `* G: q
if (document.all)
, T5 ~/ d% F6 |) F# Z- O( Osupertext.style.visibility="hidden"; Z6 L+ e  L) |1 a& R" T/ i4 ^
else if (document.layers)8 o7 K/ f, T4 I) n% T. s
document.supertext.visibility="hide"
% Q, c) T$ a" v9 C% ZclearTimeout(animatetext)( }( h2 }* Z7 j3 S. A: p
}7 N4 c0 {8 r" J/ L( {9 v

2 r5 r+ P8 q, hif (document.all||document.layers){2 i8 v% D% t; y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% |& U5 r* [( [' {1 Q8 g' hwindow.onload = initializeBall;
$ O* g7 k1 i& Z, n6 X6 Owindow.onresize = new Function("window.location.reload()");
& y% L4 n( ?0 S6 \, c' k}
  B1 M' m1 T0 v. K+ `0 p0 [) L4 [! p  l+ c; _+ e
</script>

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