返回列表 发帖

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

<style type="text/css">$ m+ R+ ]- s. z7 |% E
#supertext {) }. R% r" l+ E
position:absolute;. I* K, ?) H2 x! w
left:0;! Y8 s8 u5 ^4 a0 q8 j1 I' `2 N
top:0;. u' V2 t% O) C- \& }" e, q
visibility:hide;
8 s2 d3 U% a$ h0 tvisibility:hidden;' S* {7 d. X. Z* [
}% d1 ^+ o. O+ Q; }9 H; \2 J4 G
</style>
4 _2 `% `  \! F5 v# }  q<script language="JavaScript1.2">8 T, |3 x# S! \! S7 `8 x
<!-- 改变下的字体的大小。颜色-->
3 _6 g6 f+ T  s7 S$ J1 M8 _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 X. H8 C- \" n0 k  avar hidetimer='';
% G0 @: J3 I1 d5 q8 B<!-- 改变下的弹跳速度-->+ E; a1 P. O! L  O) Q" \
var BallSpeed = 20;
$ {( T# x  l( d* Avar contentWidth;* D3 R6 M, o7 L$ M7 [) H( z: ^
var contentHeight;8 V! D/ K/ G* _8 d! d
var maxBallSpeed = 50;
9 E- o- L% J( v: c
' m8 U8 Z6 ^# B2 V& C/ R7 @( X; A* @9 ]4 e* c
var xMax;
2 y2 ^) }* o. n0 R2 ~+ Bvar yMax;
& g- x5 ?5 \" p) u0 I9 v# \var xPos = 0;
$ ~/ K  p6 o4 e" Dvar yPos = 0;6 V" `8 ~' r/ A% t8 q# i+ \% h
var xDir = 'right';8 K  F; r  {' _3 N
var yDir = 'down';
% L& J0 I# ?; M' _: gvar superballRunning = true;7 r# p; o3 A" |% ?- R; B0 B1 W
var tempBallSpeed;1 e7 M" G. a1 s% Z* }% }. H
var currentBallSrc;
4 Y- M/ ^) p+ J" R' R3 o' v( cvar newXDir;" K/ T0 d3 t1 `* N/ f$ y8 k* f& Q
var newYDir;$ @: q& J5 }4 k) z

8 P+ W% k$ E9 L: bfunction initializeBall() {
2 [; x( W" h( x; V1 u( A( Z' d0 f   if (document.all) {
& ?) K2 Q4 I3 y2 D0 Y  v      xMax = document.body.clientWidth
8 Z% L5 W" Y! z( t5 A1 ]      yMax = document.body.clientHeight
9 k/ W3 s$ b1 ?8 g0 U& O5 Z  j- w      document.all("supertext").style.visibility = "visible";$ Y# Y# |, v4 j; p, [
      contentWidth=supertext.offsetWidth5 R: f7 t' P8 u+ G$ n" U2 R9 G; A
      contentHeight=supertext.offsetHeight  m1 k$ C. ]8 n
      }! A, t. v; S; L  l8 U. K: y
   else if (document.layers) {
* Q4 M' b8 J; g4 W7 @/ [      xMax = window.innerWidth;
  A  Q' Y( h. |( z- ?      yMax = window.innerHeight;8 S$ I$ z$ l. u0 a: Q
      contentWidth=document.supertext.document.width
* p; G$ B2 D' N! Y- g4 b; N' o      contentHeight=document.supertext.document.height
- f7 o; u4 u' U% x% e; H      document.layers["supertext"].visibility = "show";3 @  k$ L- z; n- ~
      }: I; P- c+ e: m, b. p$ S
   setTimeout('moveBall()',400);/ k5 A) O/ W. T' g- w2 W
   if (hidetimer!='')
/ r0 T7 [' H$ [. X6 r6 X$ z- M   setTimeout("hidetext()",hidetimer), c( n3 e, v/ D
   }
- @7 @" U8 \8 f' G9 e; R( k8 ~2 o5 n. A" G5 ?) P/ p# J& r) c5 q
function moveBall() {- x' J. c% ^) f& U. X
   if (superballRunning == true) {6 {* }6 {: {( J" {
      calculatePosition();
: O& |# G$ ~8 \3 z% I      if (document.all) {
$ K' L5 d, R6 A2 b( T         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, j2 t) j8 l6 r' u         document.all("supertext").style.top = yPos + document.body.scrollTop;/ z! t: C' x4 \) Q/ T1 s! R' R
         }
9 L# H: f2 Y$ h  O8 Q) Q      else if (document.layers) {8 S$ D3 l# D6 J1 w( ^
         document.layers["supertext"].left = xPos + pageXOffset;+ {# W* ]/ e" l
         document.layers["supertext"].top = yPos + pageYOffset;
$ v! `) {; Z* o7 ~. y2 @         }% P' V. w; ?" ?  o& R+ D! ~
      animatetext=setTimeout('moveBall()',20);
6 n( y5 J0 V" s& A/ _, S      }) M4 @/ C0 A0 V! T% ^
   }
9 E1 o3 J2 }* E- }$ r: d& c7 p4 W
3 p& O% {+ `; K7 y# l, H; k6 i: tfunction calculatePosition() {
/ E6 ]# x& G! X5 R6 v" K   if (xDir == "right") {; Y  {( A, D7 B. C% b7 |5 ?
      if (xPos > (xMax - contentWidth - BallSpeed)) {# r4 E; A( T, y' p7 b; ]. l( n
         xDir = "left";
6 o+ @0 J# o' P0 Q0 G/ C2 V4 B) |8 m         }& [3 M7 I2 K7 B7 Z) o
      }
7 G3 g& a8 u+ T2 s0 A: ^& Z   else if (xDir == "left") {9 Q4 @& D5 x) u% q
      if (xPos < (0 + BallSpeed)) {
7 b& D0 X0 E' o$ Q" c         xDir = "right";
; g7 {1 q  @( t+ A& B5 l: [7 F         }- J% [8 ]8 Q. \. }& j" O# a3 ^2 A
      }
2 e5 U+ u8 j: }   if (yDir == "down") {
- G1 @; Y" p( E; {! b2 Q      if (yPos > (yMax - contentHeight - BallSpeed)) {
0 t$ q. J1 R9 Q+ N         yDir = "up";' L3 b! y# X  y, k8 \: U& X# c
         }( `3 i0 d/ X4 M, @
      }3 M+ g( t6 y4 q! Q1 F* G5 p
   else if (yDir == "up") {
- X3 O8 P* K6 t6 o% S5 l      if (yPos < (0 + BallSpeed)) {
- }$ k1 V: h$ O/ Q2 W         yDir = "down";
4 u; x* x- L. P         }
# n; D+ K; Y6 {" Y      }
5 j+ {6 G" G( K& ]   if (xDir == "right") {* \' q7 V' J/ F. v
      xPos = xPos + BallSpeed;/ K/ e/ z" d2 h7 a# J
      }$ N6 V/ s$ |' s! l  B
   else if (xDir == "left") {
: q7 N$ V6 M  K$ L9 A! U      xPos = xPos - BallSpeed;& M. z9 R5 Q) R" V0 f+ B
      }2 U+ [" G' y3 |+ [
   else {
5 `* T6 F, d( j' b& ~: }9 O      xPos = xPos;
; h9 ]5 ~" g: f3 \1 k4 _      }
6 R& \8 T( T! R2 y4 @0 ]& O   if (yDir == "down") {( U7 S8 a) S) Y
      yPos = yPos + BallSpeed;
: f* J& ^" d  T# Y% m      }" M& n" P; L6 S  z" ~, X
   else if (yDir == "up") {  A% ]- N! z0 H/ v9 j
      yPos = yPos - BallSpeed;
4 U. K& j; e* m- X# {" T$ m      }
. D( m0 ]5 n- q% }' [5 }8 v   else {
4 W* C" l( y& }. ]      yPos = yPos;' F$ s" U7 @3 r. t1 ?) h8 x: m
      }# y2 Q- M2 Y, C6 e/ B: w1 o
   }" v3 U' T% k& e) S8 e9 k; t: ?( _/ b

7 g1 G. \' @! S4 C1 \function hidetext(){
0 J. g1 \4 Z" W! y( gif (document.all)% i2 B& u7 c9 u+ N/ i) z& }9 x! Y
supertext.style.visibility="hidden"7 d; E$ w) z- L# f" {& B5 v
else if (document.layers)( M( c! P' Y# O" ]! r% o* z: Q
document.supertext.visibility="hide"
" w& Y7 @- e: a/ vclearTimeout(animatetext)
9 \  R4 P7 m& N. F7 `& u6 u}
2 @- {" Y! ~: @* @$ f% |# y: A. b9 m, n! O6 ~; Z
if (document.all||document.layers){8 X* q. f5 i+ X7 K( u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 N( z8 `" s$ ~0 V& j- Z' Rwindow.onload = initializeBall;
+ u/ k  h) R: a* fwindow.onresize = new Function("window.location.reload()");
7 J1 A; O$ R" L. e0 H& O}3 ]' F2 c, t) {8 R; a
% u% r1 k8 w4 q+ ]: [
</script>

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