返回列表 发帖

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

<style type="text/css">
$ l$ W$ P# k1 Y6 F2 y* ~- O#supertext {
& \9 \! t) p( ?: y- X, Kposition:absolute;8 G- J: t* U7 c% ]. p& V* T. B" v3 @. n
left:0;, L% H/ V3 a, L" q* k) M
top:0;" _7 m: S7 ^' l! Y6 _6 }
visibility:hide;
# [0 A) Q( s; u# v* Bvisibility:hidden;
* q% T2 d* q8 T}
5 s) W2 g7 L( J( i& A</style>
9 g- ^# s. ^9 l" h1 A" n1 o/ C% B<script language="JavaScript1.2">
# B% U. W! D, n& k<!-- 改变下的字体的大小。颜色-->
/ h" L+ h. ?! s5 l0 @7 pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ ?1 b" ]& a% S
var hidetimer='';
; L4 C" Z# _1 R% x<!-- 改变下的弹跳速度-->
! u1 R7 W6 ^. x" [$ |2 [. zvar BallSpeed = 20;
6 V2 C9 s; R: g  C) y* fvar contentWidth;% t3 e8 j  ~/ O4 o- Q7 d
var contentHeight;
) X% i- U! [' a( A- W1 l; {; z% Fvar maxBallSpeed = 50;6 Q( g: D) k1 {/ t' o. b
3 G" ]" y) x) o0 K6 B; f

2 T" \" v) i" S- U4 @" ivar xMax;
, Y: ^" z7 R4 U/ Xvar yMax;
$ {0 s$ Y1 r5 rvar xPos = 0;
9 E+ d& Z* |( h# o4 k4 _4 Z. kvar yPos = 0;2 i; F0 x& f5 g. w* h7 B$ ?9 m
var xDir = 'right';) H1 u. N7 ~/ \5 v. B! `+ W( M
var yDir = 'down';+ z) C) z2 Y$ ^0 k$ y
var superballRunning = true;  r8 d. N" o5 R- O+ T
var tempBallSpeed;
( }* m8 K% l: _5 T+ q# X3 vvar currentBallSrc;
9 o: g* K& A  w+ ?: dvar newXDir;: C3 x; R/ ?! O! R# K
var newYDir;  _) ], }  g; v! L8 w
$ @" Q* o6 H- }9 K# @$ e
function initializeBall() {1 b: E6 G" n* u; |: I$ _1 _) t
   if (document.all) {* ]% H) M0 ]8 p) K
      xMax = document.body.clientWidth
& m1 `7 V' p. k; z) K      yMax = document.body.clientHeight3 e. y3 ^/ P  @6 b" y% T- z/ J
      document.all("supertext").style.visibility = "visible";# X# \- r6 L/ A0 @6 B" A& q
      contentWidth=supertext.offsetWidth
2 ?% K$ R9 @& q- w0 `. w8 z4 F      contentHeight=supertext.offsetHeight$ r8 M) ^. k4 W' p% D
      }, A2 b0 y4 ^6 A; |+ h% N( J
   else if (document.layers) {
) X/ h/ r7 F" u3 b      xMax = window.innerWidth;
! O* P2 c' H/ M$ D      yMax = window.innerHeight;! |6 C( P9 E8 |, h; s
      contentWidth=document.supertext.document.width
' f) I2 }. p- o' I/ g" O      contentHeight=document.supertext.document.height6 w) F4 ]+ G* _7 D+ O4 h% J
      document.layers["supertext"].visibility = "show";
' ^, V. _/ a  r& ]* M" V5 D      }
7 T. c' g- ~  {8 ]6 M  V# x3 D   setTimeout('moveBall()',400);
" O; m4 \' d  x/ i0 n! J4 N% `% I   if (hidetimer!=''): N8 G8 M; e# d3 |- y
   setTimeout("hidetext()",hidetimer)
1 f- f& x5 N* ~8 y2 R* F3 q   }( @) M! Z* a* E7 W$ `1 M5 b
4 W) I- r& p8 P7 Z, {' p
function moveBall() {
  n, J/ e# H+ ?7 I2 u   if (superballRunning == true) {
0 j. Y6 _/ t0 P0 h" G; f      calculatePosition();
' {4 W  t& c5 X# S      if (document.all) {+ a! j3 V2 X) Q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;8 V3 F3 n0 l1 M! Q
         document.all("supertext").style.top = yPos + document.body.scrollTop;
; F% P) U* T9 T6 \% I0 H         }2 ]! Z# S6 w& T* ]4 g3 ^6 W
      else if (document.layers) {8 ^- f4 }8 _! j0 s2 \7 J; R
         document.layers["supertext"].left = xPos + pageXOffset;
6 C/ i6 H% I' w3 ~: X# [         document.layers["supertext"].top = yPos + pageYOffset;
: ~3 O: h. H# A         }4 O4 m+ m- J9 v0 y
      animatetext=setTimeout('moveBall()',20);& F# |4 g3 U3 F! }, V6 _
      }% M8 a7 E9 s1 `0 E$ M
   }
2 M8 t3 L9 M- ~' i
$ F4 H! M% B5 l) ]function calculatePosition() {) L% ?2 K% E$ Y0 n! M7 Z5 h
   if (xDir == "right") {
! k5 h9 L# y* M) U* a      if (xPos > (xMax - contentWidth - BallSpeed)) {1 V, u! L$ r7 w$ [
         xDir = "left";
, r7 J# i' A9 F8 G3 \         }
4 w+ g5 X/ Y5 c" A: p      }
. W; q' D2 A) j   else if (xDir == "left") {4 a$ W7 \! Y* Q# c1 R$ a
      if (xPos < (0 + BallSpeed)) {
) W1 p* x& s( `' i+ y+ a8 }* a: Y         xDir = "right";
! u' Q; |; h0 F6 L         }* P" O( o  C$ E( L7 `
      }
& N' F' _2 I6 X   if (yDir == "down") {
, u  ~6 e" o9 z) h# P      if (yPos > (yMax - contentHeight - BallSpeed)) {
1 ?8 L( n5 s" ]% b+ ~: `. V         yDir = "up";
* t; Z" P7 P0 K3 f! ~         }
/ p, |3 Q; @$ N! n; f, E/ F+ Y      }
' g& |9 \2 J  d! a+ k: f$ j   else if (yDir == "up") {7 y3 A$ ^- y3 [2 |
      if (yPos < (0 + BallSpeed)) {0 I! E0 i! G; z, q: o
         yDir = "down";# n$ ]2 P0 _7 w& _5 g) }/ P
         }
  o  t& C/ n0 O1 ]. ^: ?      }
. o4 B- ]# `* c   if (xDir == "right") {
' j. W; Q3 V( g9 \7 |( Y      xPos = xPos + BallSpeed;' I4 k) [2 ^' T5 n! f" j
      }
) @7 G+ d, Y' c4 H5 }  v   else if (xDir == "left") {$ ^% r$ W7 b: k
      xPos = xPos - BallSpeed;& o. b  T, e# }* x% q( y1 |& R
      }
. S7 q8 ?4 f7 ?# P  S, J   else {  |6 t; ~0 L/ r2 I! S6 j7 v+ E
      xPos = xPos;0 s: B. g( G. {; ^4 j7 O
      }
2 ^5 Q7 X% Z4 S2 m1 R" L+ s% o   if (yDir == "down") {
  }5 q4 A: ?8 ~; Y" D# e, B/ ]      yPos = yPos + BallSpeed;5 t; v( i9 T4 N5 o& K+ d
      }+ ?. n# _' M3 l% j& i
   else if (yDir == "up") {: g, o5 o% V8 f0 A7 e9 ]
      yPos = yPos - BallSpeed;
3 U- S: B7 i8 A* s* x      }# b. u- O4 R0 s2 s7 m
   else {% r, O1 F' y- g& L4 n
      yPos = yPos;
# H( c1 h1 Q3 T5 }' I      }
1 _5 X5 K5 H  Z   }
9 f2 H( [, x3 E, v& g. }6 i3 d; g+ C0 O' Y+ x
function hidetext(){. \3 U# b, |* y& w5 ~2 g
if (document.all)
/ d3 h  e- c3 w0 [$ Asupertext.style.visibility="hidden"
+ s2 o! W" ?  g% q$ Oelse if (document.layers)
* k" C' [- b* \# pdocument.supertext.visibility="hide"6 B! [) h9 F# s& d  ]0 Y- W
clearTimeout(animatetext)9 v9 @6 A& }4 r( t' k
}
; D' S6 c7 ]% ?( s% Y
, T$ q0 N( {# ]3 vif (document.all||document.layers){
! B3 F4 j' [- W+ r# {7 Hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( `& H9 A  |2 h+ P. @
window.onload = initializeBall;
% ?; V& b% `) R2 |! Xwindow.onresize = new Function("window.location.reload()");
# y2 l1 \$ a) k% `% H5 o}/ J5 U/ o0 G$ E, ?* v" H+ F- u  ]

2 v% ~* e, D1 U" U& W' A</script>

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