返回列表 发帖

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

<style type="text/css">0 j, ?; M& D7 w
#supertext {; E5 ]: G8 u. t: b
position:absolute;
( c9 p+ q2 V6 N! U, U: Fleft:0;4 ?: T: J5 m7 k) i) U5 S: x1 \+ M
top:0;
  X0 q: j, Q) K2 S2 |1 c# `visibility:hide;
' ]" K4 a1 }) q, P7 n8 Qvisibility:hidden;( g3 L) f% B3 u. r) h/ T
}1 l; q4 }$ p. ^: E, b) r
</style>
# b: o# _0 R& l7 ]2 ?# F8 J<script language="JavaScript1.2">/ s& H: M: k9 T
<!-- 改变下的字体的大小。颜色-->$ m3 x" S9 i, g( R; k. K  C7 f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; y5 [& s9 o! R8 ~1 Y: Z2 Tvar hidetimer='';- A& |# D# U  [
<!-- 改变下的弹跳速度-->
- C* C7 z/ ]# B/ ivar BallSpeed = 20;
/ ~% d: C" b' o4 Uvar contentWidth;, B6 f  u0 Y6 M+ y9 @+ n
var contentHeight;: X7 p( \' ]: h1 \. G. P5 s
var maxBallSpeed = 50;  Y: B4 t4 r: `  v
) ]/ [$ T  j+ Y# V

2 p1 i, P  ~! N4 [. Uvar xMax;
0 L- ~, E% K8 E# Y: A( I0 z) }var yMax;+ p/ P+ c: f) b, ?5 @8 \
var xPos = 0;
7 S: ^% L0 F. c1 t2 D3 |- {var yPos = 0;
% n* ^* Q: @0 ^3 k- C& Xvar xDir = 'right';2 ?/ Q" ?0 m2 g8 ^5 Q+ v0 t8 p
var yDir = 'down';# s% z& ]+ x) X6 Q4 Q8 W
var superballRunning = true;
7 v1 D$ @7 k5 L0 u" kvar tempBallSpeed;
" {9 S9 V9 s5 N: b, X- Avar currentBallSrc;& A6 S. k# C. W+ s4 u# ^
var newXDir;
3 g+ E' v- q1 u- p) c4 t& @var newYDir;( s8 e9 Q+ ~3 C

) ~: N" q# i6 lfunction initializeBall() {
& {5 I4 C5 G8 o5 Y5 A   if (document.all) {( K4 N1 D. a9 R
      xMax = document.body.clientWidth
5 }6 S4 }3 h& ?) q      yMax = document.body.clientHeight9 e4 g4 E7 Y7 Y. Z
      document.all("supertext").style.visibility = "visible";
# F; V. {3 F4 i1 b8 C! [. G      contentWidth=supertext.offsetWidth
) T+ u5 s- Y! Q. I      contentHeight=supertext.offsetHeight1 }9 @4 R# B$ y* C  ]
      }! a) k% b  h  T
   else if (document.layers) {% z: o1 H" H/ J8 n
      xMax = window.innerWidth;
- b9 U8 }) K5 Y9 T4 Q+ t2 D7 E9 I      yMax = window.innerHeight;
6 _! ^3 |. _$ K3 n1 o! B+ g+ s. X      contentWidth=document.supertext.document.width7 g0 o- b) c8 D/ R5 \7 h
      contentHeight=document.supertext.document.height6 a' l: b& n7 o2 S1 s9 m' d
      document.layers["supertext"].visibility = "show";
2 X5 M0 U. t0 t* |% R3 Y      }
, ~3 M+ s1 U( P6 W   setTimeout('moveBall()',400);
4 |7 e  E! Y" h+ r5 w   if (hidetimer!='')* k* V! m' f( [4 Q$ w% V
   setTimeout("hidetext()",hidetimer)" z2 v$ r# ?' v. @
   }/ N& C1 K" @# s
8 z% T- K: f5 s4 X- G) D- v
function moveBall() {; X+ f6 f. M! s7 u: ^: l
   if (superballRunning == true) {
/ S: C  w9 b/ D' e3 X      calculatePosition();
$ o0 \6 h: [: u4 m: ]      if (document.all) {
9 b1 Y4 w( B2 O# h         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. }9 ~- \3 o9 h9 N" x' N! \         document.all("supertext").style.top = yPos + document.body.scrollTop;5 R7 o% {9 g' K) I0 y1 N
         }
, f1 b. D3 C5 f/ X! q      else if (document.layers) {3 R4 g' O3 J0 v- M8 n
         document.layers["supertext"].left = xPos + pageXOffset;
- q3 p: X% F( M         document.layers["supertext"].top = yPos + pageYOffset;* I0 q7 T5 N, X( v5 ]
         }
1 V& h/ N8 K3 `, B% `      animatetext=setTimeout('moveBall()',20);
. O: u, @) e& K/ P$ k  I      }
. T9 I  Y! l0 b! Y# `" h3 _   }7 r" _/ \" X9 y" Z' N" A) a

! g& \+ P- i) {9 t: Ufunction calculatePosition() {
- A- [1 \% |* i6 x   if (xDir == "right") {0 j" d  Y8 f* o
      if (xPos > (xMax - contentWidth - BallSpeed)) {2 r' |; S* v- P2 j& f* m. I3 C  |
         xDir = "left";
* {8 L1 T% r! S; b" `2 V, O         }% h; `1 }4 A- c. S
      }6 V3 W* l; G1 c
   else if (xDir == "left") {
, U* l6 s+ G0 `+ d      if (xPos < (0 + BallSpeed)) {" V4 L; A* |% A, v" m7 s
         xDir = "right";
' G) Y* {8 e) U         }
8 L2 y/ ~( s. e& Y  T5 f      }* B( Q* l! o/ O1 V
   if (yDir == "down") {, A( A9 D9 C/ |8 I9 f% t% n
      if (yPos > (yMax - contentHeight - BallSpeed)) {
: F" J6 ?# K, G4 _         yDir = "up";1 a4 l5 A4 M- B6 t
         }
* n4 c& l2 N, |! E5 W5 G3 [      }
/ q+ s/ N8 ]! j2 ?8 q   else if (yDir == "up") {
$ f( x( t3 \+ {% `2 i      if (yPos < (0 + BallSpeed)) {% I, O& r7 G# f4 ^! ~4 ^3 l; Y
         yDir = "down";0 e7 @5 n" Q. x5 @
         }
" p+ x/ d( T: a. {, ^      }# Q+ m( J! p8 T# I
   if (xDir == "right") {) u  s9 R; x+ r' i, P; l& J: m" R
      xPos = xPos + BallSpeed;% f1 h% R1 @! F5 J1 Z7 F
      }  U/ S: `5 z/ h5 s$ {4 v
   else if (xDir == "left") {: P; u- v0 D, L( r
      xPos = xPos - BallSpeed;
# h& v6 l+ j$ c! @7 }/ s      }
7 C4 U4 O+ z8 _3 t. t   else {
% q/ y4 K4 u$ j8 _      xPos = xPos;
& V! R/ Z. M# K) @' d$ y9 n      }
  B0 Y; H$ n, {1 b: U: @* I   if (yDir == "down") {
; _4 j# I1 t5 q7 V. T0 {- ]- J      yPos = yPos + BallSpeed;- H+ w, k# s& y2 E* g
      }
/ r- S. n* U) X' h1 z   else if (yDir == "up") {- o. e5 G; }  R* g
      yPos = yPos - BallSpeed;  L. J% V5 S; Z. I5 F
      }
9 p1 F( ]5 }! P   else {! h, ?$ m7 ^, t6 d" i9 i+ }
      yPos = yPos;  M# {) \! w" l. R+ _* a
      }
. R' I# Y2 \# t   }  b# z/ c; D6 |# J0 a4 H
2 s, L5 R. x8 `4 N* E
function hidetext(){
" q# j9 ~6 w: J; ^$ k1 Dif (document.all)
: j, E9 @2 h/ C* ]. P, w+ u1 L9 Usupertext.style.visibility="hidden"+ w- [9 Y' P! K4 C4 |3 i+ E
else if (document.layers)
. t+ @1 u# ^0 Z- N6 ddocument.supertext.visibility="hide"
& D3 k1 [8 M# ~2 sclearTimeout(animatetext)0 b, k7 o; i# g" |$ z
}* E* Q1 W6 l+ W# }0 D! U) o
7 o- U% K; V; \9 }4 s
if (document.all||document.layers){
/ n. W# r$ F3 ^) p( x8 Vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" Z0 B% d6 U/ e; {" z/ r
window.onload = initializeBall;
/ \) @) F- _2 p6 O5 y( H5 c- fwindow.onresize = new Function("window.location.reload()");4 J6 e+ _3 t) k: h5 N( M
}$ b, @1 d& f  Q3 `) N

+ c$ `- x2 j& ]4 \1 i! B</script>

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