返回列表 发帖

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

<style type="text/css">
! o& }) |6 Z3 V# B% v' F$ R; c#supertext {) U2 U& V7 I1 d* G# J
position:absolute;
3 E' @, P! @8 J9 d/ Z; k0 ?left:0;
; N- I+ h- |: L% a  d, Etop:0;) g1 G6 ~5 s$ F: p3 U- ]0 s
visibility:hide;
# v8 @: ]9 e6 w$ q+ }5 }: Fvisibility:hidden;7 G8 U1 L& {( |% k; }  ^
}# s3 ]0 [3 Q. `$ b) R
</style>2 D, s( H. M8 V) i! _# [
<script language="JavaScript1.2">+ C* X0 y2 {2 A/ j2 h. }9 ]
<!-- 改变下的字体的大小。颜色-->
- A" M4 M' r8 I/ `3 uvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') S2 p, _  i8 L5 W, Q
var hidetimer='';
6 F, {2 K2 U+ D6 C  H<!-- 改变下的弹跳速度-->" F" n: V8 G/ y- k+ x& {
var BallSpeed = 20;/ l) Z3 n' y' M1 ]- f* Z
var contentWidth;
) d9 T8 W* g* t% m* g. S0 ~. evar contentHeight;1 S1 X$ y- b4 [( c
var maxBallSpeed = 50;% U0 A( y/ l" O- Q9 E2 R7 }/ S4 w* k
5 I- f, v0 \" r, a6 W

+ r5 W" R5 C" h$ g1 Kvar xMax;
4 a0 p$ j# ?0 \# \% V4 {" pvar yMax;
$ q" ?$ ^3 B% y* x: l& nvar xPos = 0;
% P5 @9 H7 I5 L+ t! W* ~+ ~var yPos = 0;- ~- D* o- G5 u; Z( c. J7 r
var xDir = 'right';
; l1 j2 L$ W+ g0 lvar yDir = 'down';# Q( c; {1 c0 |8 F
var superballRunning = true;
& y# `+ z7 ?$ ~3 Lvar tempBallSpeed;
$ a, p$ n/ |" e; D4 d6 p, Gvar currentBallSrc;
, q" Y) _& f( T% }var newXDir;
0 v5 }0 T! p' R) d' G: z; R* Yvar newYDir;
9 Q9 W* q. Z& b5 u0 D/ l
' s$ f8 r) m7 Nfunction initializeBall() {
& D3 b% T9 K6 J& J0 N+ e4 a   if (document.all) {
* l) j$ g1 o& u7 p" u$ }9 s8 m, ^      xMax = document.body.clientWidth+ L! o- T- u( |5 H2 v
      yMax = document.body.clientHeight
! `$ H/ ]+ S$ S8 U# u      document.all("supertext").style.visibility = "visible";
( y- f: o) @: H0 i& i      contentWidth=supertext.offsetWidth
7 F# l7 X) v8 A" H1 m6 c      contentHeight=supertext.offsetHeight
/ J4 k3 b: o+ q      }
7 B. H; a; _- z6 r& Z# |   else if (document.layers) {
8 o1 Z5 t% i" Y      xMax = window.innerWidth;, ^% k8 R/ C# X; K$ l3 c( M
      yMax = window.innerHeight;
. X' P$ A4 q* v) x5 O      contentWidth=document.supertext.document.width$ G$ s+ T1 u) V" s0 L5 S% _
      contentHeight=document.supertext.document.height9 g8 r; E9 I  a2 x0 A4 l! f* b
      document.layers["supertext"].visibility = "show";/ K, `5 G/ l$ l5 e" J4 r+ i
      }
5 C) F! f, }/ ^" k! e2 H   setTimeout('moveBall()',400);$ _1 `$ y  k; s
   if (hidetimer!=''). y; F  [9 U7 G) V! [
   setTimeout("hidetext()",hidetimer)
: ~4 o8 h- u9 \* T& Q2 C   }
9 T0 Z1 R! m, t8 `: z0 }- r$ E- O8 U- J  h8 l
function moveBall() {
2 o/ ^9 E" {$ n4 K$ c, p! k   if (superballRunning == true) {! g) b$ \9 ]9 u: b
      calculatePosition();  _( j# x+ B9 i, W0 \
      if (document.all) {; N$ ?! f2 H8 W3 b, w
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 W- d/ @$ P  P         document.all("supertext").style.top = yPos + document.body.scrollTop;$ p' F" Z# A* g
         }: _2 X; s! R/ l* E# j8 _2 C: V
      else if (document.layers) {
! Z/ l0 F5 B/ z0 s6 D         document.layers["supertext"].left = xPos + pageXOffset;
* m  j4 B( Z8 l         document.layers["supertext"].top = yPos + pageYOffset;
4 k' a+ I- U4 e0 ?         }2 s' I$ H9 C, j9 v: W
      animatetext=setTimeout('moveBall()',20);
4 z3 A8 c2 B2 A. ]6 L2 W      }
' m) S# o6 E3 E   }. ?; p7 B" x& b6 v9 U

, j" N6 {- X( `: H/ Wfunction calculatePosition() {
) g: x) h, w  o8 j3 U* K   if (xDir == "right") {6 f4 C3 X5 N* v8 U2 j  s
      if (xPos > (xMax - contentWidth - BallSpeed)) {
! {. j1 d) p$ n* |9 S7 a& q! E: p         xDir = "left";6 W3 K' k! W$ k3 n; J+ D0 d, V
         }5 \7 Y* c1 n$ \9 Y
      }" o: @7 X, k' N; L2 q) }
   else if (xDir == "left") {
4 y3 q3 H8 o, Z5 ^) P      if (xPos < (0 + BallSpeed)) {4 g: R- _1 M6 ]5 I
         xDir = "right";
, K8 ^" Z# Q. l! P0 ~" t" H8 q         }2 t8 w$ @( o2 N
      }
1 d+ P5 @% p" r   if (yDir == "down") {, }7 e6 n% x; W0 d- ?
      if (yPos > (yMax - contentHeight - BallSpeed)) {* i0 G0 N" J& P& U: A8 D$ n6 u8 T
         yDir = "up";
1 g$ \9 {/ [' w3 o6 f( p         }
5 g9 P- f: x3 v. g      }( ^0 s: C# B7 I- R: d% L9 i
   else if (yDir == "up") {
4 O1 @. O6 K0 [0 q/ h  p      if (yPos < (0 + BallSpeed)) {
+ |$ k. W0 A( a1 U4 R! T$ `+ j         yDir = "down";+ d. A% C" Q( e3 a
         }
/ m9 Y2 S8 @3 X  E      }* _# A2 F1 G. W, ]
   if (xDir == "right") {
: A9 ~2 J$ E. V5 {! L+ l( p      xPos = xPos + BallSpeed;  ], w* d% N7 t7 S7 r; n1 ?
      }
+ B0 M! N( F6 ?/ n3 ^   else if (xDir == "left") {
4 d& z* X- k, ]; Q      xPos = xPos - BallSpeed;& A4 K% ?, d, @5 k
      }& t1 H1 N  K1 B4 H1 O6 k2 c
   else {
0 H0 y4 Q7 K2 Z9 }      xPos = xPos;
; @+ f" k* Z' Q% U      }6 g- E4 O% v+ j: r/ q1 K5 Z
   if (yDir == "down") {
0 @, _- u( n+ d# M* L2 h5 I3 v% H) h      yPos = yPos + BallSpeed;
. n# G8 u, c' ]5 n( Y9 _* M  o1 {      }
; ^* c, C9 e( K" V$ j+ `" y" r   else if (yDir == "up") {
+ |: [( E, M' ?) ]/ [' w      yPos = yPos - BallSpeed;$ P( O. b5 t6 U; W
      }0 N9 M# W/ S9 r0 F5 h
   else {
# c) k, ?2 L- D, w, I& `& I* b      yPos = yPos;1 t" i+ q5 I# D( ^6 E5 o9 ?9 N
      }! u9 b) x8 q8 F; w. w/ S' _0 o
   }1 M" k0 P. r, A! D: f
& p4 n/ S& A7 @& S4 L9 I& l$ k
function hidetext(){3 s& @0 v5 V. I6 o. h8 B0 F6 R
if (document.all)
1 S9 V: [7 h; H5 ^. csupertext.style.visibility="hidden"+ A$ \4 Y$ m, U( Q! Y
else if (document.layers), t3 @- O" y: Y: g6 r% E
document.supertext.visibility="hide"
! t* S3 L$ Y1 ~6 J6 L4 JclearTimeout(animatetext)& U1 x" P$ v  `
}7 Q6 y) D! b2 j* }2 L! n/ k( e9 t
- W" R8 \6 n8 }! g
if (document.all||document.layers){' `6 j  c" \% F" w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ d0 U6 ^# y% z
window.onload = initializeBall;" z4 V! o. d8 y- V
window.onresize = new Function("window.location.reload()");
& K1 p' I+ N  C& M  E+ B}
+ H6 Y: C% ]  L/ S- @) g3 n( ^6 e3 d
</script>

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