获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
, ]7 s, c% a. S: M8 y9 q# q4 ~#supertext {
  R9 T5 D/ o6 U+ _" `: {8 H) U7 |) J" Mposition:absolute;# Z# P) J- T' t; f+ ~( s7 [% z+ j- \
left:0;
, s1 x2 [8 S* r$ O5 Wtop:0;
' \' W( p/ ?7 v$ _: {visibility:hide;7 m! M, p* I$ H" _! o* w- p
visibility:hidden;) x' w, S, M5 a) q2 _9 ?
}
5 L* B2 w7 K; N5 l- y, j9 N# ], f</style>3 T- X& E7 z. c: C; D
<script language="JavaScript1.2">
8 ^7 g/ k  w& {3 ^, S- r2 o<!-- 改变下的字体的大小。颜色-->2 s/ K0 S" Z6 ]. R+ I
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 u4 [1 R5 N8 u$ D, h# B0 r5 R
var hidetimer='';
! S$ A- M, D+ b0 c% k<!-- 改变下的弹跳速度-->8 S/ `. w0 Q! q9 j0 b8 ]3 C$ n
var BallSpeed = 20;6 M/ e; J0 }9 t7 ~
var contentWidth;9 U6 k- N: e7 @* a
var contentHeight;+ Q& a. _1 ]- z5 r" W7 y
var maxBallSpeed = 50;& B8 L+ M0 e& T) n
# U9 k$ [! Y3 T. Z2 U

! f) ]- \4 h& Gvar xMax;- s. s) X* }/ J, J0 @+ Y- {
var yMax;4 ^7 S$ k1 c3 O* j
var xPos = 0;
  f, x3 R: v" S5 |var yPos = 0;
0 d7 u( j1 W) {( g) `7 tvar xDir = 'right';1 R- N: d7 A4 g4 n/ y  g; b& b  |
var yDir = 'down';% h' o9 q+ K# n3 x/ `1 R5 g9 B
var superballRunning = true;' y. {, A. }7 `3 P) C2 U$ Y/ V. W
var tempBallSpeed;
/ K4 j' y  O0 L$ B4 svar currentBallSrc;) M) r0 ~$ s9 y0 v. k1 f
var newXDir;* U7 ~; ?, N1 J3 }
var newYDir;' L" X0 t7 t3 x* f1 W# {

/ c) q( t9 P0 N  e/ Ifunction initializeBall() {
1 _4 T+ o3 i% M5 j9 y1 J   if (document.all) {
% R; W1 B( a/ \% ^1 Y; g; f      xMax = document.body.clientWidth
' e6 y6 E* I( n6 W2 r8 F# C# Q0 \      yMax = document.body.clientHeight
& S4 c! j) u9 o      document.all("supertext").style.visibility = "visible";" {) w% I8 L, T, V; o
      contentWidth=supertext.offsetWidth
' g. P: y1 P% p' Y; d: {* L      contentHeight=supertext.offsetHeight+ x5 R. w! @) O
      }
( ^( P% Z* e5 C& {5 C   else if (document.layers) {: V! a& I& i9 G  F5 \- w
      xMax = window.innerWidth;
' K  L8 y; p# \! B      yMax = window.innerHeight;
4 R: S' u% z, |7 d) A      contentWidth=document.supertext.document.width) D: x( t, r1 Z6 o$ _
      contentHeight=document.supertext.document.height
: f+ m' l  ~1 x( \5 o0 \      document.layers["supertext"].visibility = "show";0 V9 T  P( g4 h# y. I
      }
+ a# @3 }& `% U   setTimeout('moveBall()',400);
$ Y& ]. T4 C2 X0 q8 k" U: t   if (hidetimer!='')
4 L9 A7 n# V+ \  u5 g! j0 `/ p& ~& S   setTimeout("hidetext()",hidetimer)" t3 m+ v( P3 W* ~7 D% M
   }& ^5 ?6 E! i* _7 W: u9 ^
# \' s6 H/ n. E% i7 b" g3 o
function moveBall() {
) e& O* `+ G) s. T+ Y5 `% D3 c   if (superballRunning == true) {
0 Q. U- r6 c* `4 d; a1 O      calculatePosition();5 C5 Q. g) b; d, B2 v3 h/ Q
      if (document.all) {
5 d. D) ?2 n; s1 e: ~% ]         document.all("supertext").style.left = xPos + document.body.scrollLeft;8 W# L( `4 A! K& `4 q" e2 c5 E
         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 K8 E; b3 @8 Z# f/ H         }' X1 X: W- Y9 H& R
      else if (document.layers) {9 j6 F, f6 C) \2 e
         document.layers["supertext"].left = xPos + pageXOffset;5 Q5 o- e1 Y; A5 `, W
         document.layers["supertext"].top = yPos + pageYOffset;
! g2 K4 T2 l9 e         }  h* }& F) T& ]# l% ^3 K6 _+ G
      animatetext=setTimeout('moveBall()',20);
/ E. m  D/ r8 l, \      }( ^2 |, j0 \. V9 _
   }. P8 g" D4 \, f5 ]; s/ \* j2 U
% w, L& O: ^. Y4 C3 w
function calculatePosition() {4 c9 F$ N5 |" G$ o
   if (xDir == "right") {! c1 V$ @3 |. q) t
      if (xPos > (xMax - contentWidth - BallSpeed)) {
% U6 d3 i, d8 B& o         xDir = "left";
# l  c1 H" Z/ N' g& q1 G5 ^         }5 [; l7 \: l& y0 u, F$ r
      }( U: @& b" i9 d( f2 u1 S3 A
   else if (xDir == "left") {7 f, d+ z* O0 k2 g' C3 n8 E
      if (xPos < (0 + BallSpeed)) {
* C- V* c' m( O0 E1 r& G' A8 h         xDir = "right";* ]" P( Y" N# c' t* r
         }
9 F( H0 S7 _: ~- W* d( s) ~      }
6 T5 E$ A& z( E5 k   if (yDir == "down") {' e, m$ b! Q7 a* F
      if (yPos > (yMax - contentHeight - BallSpeed)) {$ n* p1 Z9 e4 O0 ^1 Y  F
         yDir = "up";. W7 d2 o- k$ l3 G# y
         }
5 E, Q+ }6 K% f) {      }+ w3 T* \3 G  n; }: E, x! S
   else if (yDir == "up") {
8 Q$ d7 Y: F2 v0 J' n5 `" r      if (yPos < (0 + BallSpeed)) {
' p; o8 x6 i( Z  @         yDir = "down";- U# ]- L7 F& G- g
         }9 k# \0 ~, s0 Z8 q
      }
6 u* \- I( @) s- O/ _7 w   if (xDir == "right") {
, E' t/ V1 l3 m! o! z1 v      xPos = xPos + BallSpeed;
7 y7 t( S. _- K1 H: e/ o      }
! b2 e  o/ J( ~9 V   else if (xDir == "left") {
3 c2 n3 X' Q$ c6 D4 y, v      xPos = xPos - BallSpeed;% |. @! q& r2 O* m  ^
      }
. K6 ~3 K& }7 R& I1 k% e. c   else {) y' N3 L8 J; E* G8 n
      xPos = xPos;
( Y+ G% x% u+ Z6 b9 c: @      }
9 x9 a. i: M! B9 _& g   if (yDir == "down") {% |/ }  m7 f9 v9 Q
      yPos = yPos + BallSpeed;
9 f& U9 E. |, u2 D: g6 f# J      }* J7 _, f; i1 j: X+ {7 }
   else if (yDir == "up") {
/ {7 x' N. l$ u. [. l      yPos = yPos - BallSpeed;& G9 Z6 N4 }9 F- M4 R0 x
      }
: A0 M5 k) c( H0 p7 j   else {
/ I; u: {. k$ M: v      yPos = yPos;
5 G7 J6 b$ w  A2 g" R8 D$ \      }" V6 {4 u  T. `2 r
   }
* c& a6 L- z# G/ _) A9 p# d7 J$ Z! A* f. V% s
function hidetext(){* a8 |; M3 O% [: d" q
if (document.all)
! z2 U- X% h5 q" @/ jsupertext.style.visibility="hidden"
% \7 U2 B5 q6 |- }/ felse if (document.layers)
0 Y' `' `7 `4 L% j, |: Ddocument.supertext.visibility="hide"; s5 d) |  c7 N  Z
clearTimeout(animatetext)3 r( @) o4 h& A
}
0 Q  r9 {6 H7 J- M
6 p. |4 ^- K2 g1 _* nif (document.all||document.layers){; P5 n+ B/ D* r4 T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ U- D% u. v8 ^4 \- J+ \window.onload = initializeBall;
3 ^- F  [7 A$ y3 Kwindow.onresize = new Function("window.location.reload()");) B$ h. c9 `, K  d- i- C4 s
}( c7 }' f0 k2 ^: b# c  W, m: J
6 j  k1 o; E# d  i& h$ y
</script>

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