返回列表 发帖

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

<style type="text/css">
6 S. R' z7 r6 Q; k  J, W. a# q  o#supertext {
% W" V+ Y" H* g. o2 Vposition:absolute;3 g  j! v1 W% o
left:0;5 Y( D6 ~9 Z! P# l; p3 Y$ s$ U
top:0;
2 U& B& z! R+ G( F: c; ?' pvisibility:hide;
  O5 m0 B/ x1 ~* ~/ ]/ P0 d7 E( pvisibility:hidden;
) }4 K$ h/ J0 Y, ]! m+ R}8 W, z& |2 T; R( j( a) j
</style>( f6 B+ }! U0 X7 l: I* ?+ H: K4 c
<script language="JavaScript1.2">0 d; d! D. X4 [+ ?- Q% V$ H
<!-- 改变下的字体的大小。颜色-->' q0 ^' P2 `$ |+ s# R9 K3 P" g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 W/ n& }5 h/ u  }3 |' z% s6 I, S3 N
var hidetimer='';
, x% f- x. r1 u; H# [- ~<!-- 改变下的弹跳速度-->
/ E7 L: f, h% {. W, s6 w  H+ i0 avar BallSpeed = 20;
) E4 @* O$ e% Bvar contentWidth;  J) [6 w: }+ G! ?% H" {" Q
var contentHeight;
  w) [* f$ I! x2 H4 z  w, jvar maxBallSpeed = 50;
1 o7 ]8 {4 q9 A7 k3 u1 X6 V4 X  _9 u* M- P  N. x: e0 m" T: g

" m, r( {+ _% A' @( S. G2 y$ Evar xMax;
. c  N: `; K4 [9 R0 |0 K7 I0 ivar yMax;/ N) T$ }% {6 F8 B
var xPos = 0;
7 G% F/ N. {' g' A0 V& ^var yPos = 0;
( q& H: y$ x9 i9 Dvar xDir = 'right';
4 c9 W( a. V; h0 m% dvar yDir = 'down';. K4 J0 a6 y0 e% I( J& w" l
var superballRunning = true;
3 ^9 t5 n3 g8 b" m5 Jvar tempBallSpeed;, r; R) x0 ^) t* P0 v- u+ D* o
var currentBallSrc;
$ o& ^$ \* Z; b& l1 @+ T" Pvar newXDir;: B* B7 d. @. a9 q7 `
var newYDir;# M" L7 E, ]5 `

# I$ f  A. T7 ]* V5 J. }6 Pfunction initializeBall() {, L1 R: }: a& w9 q  d% w
   if (document.all) {
0 X- N8 V" o1 H, l# U( N3 F- {      xMax = document.body.clientWidth
! n" t8 G4 l: N      yMax = document.body.clientHeight* y5 V! T: b( M
      document.all("supertext").style.visibility = "visible";
6 G1 C' n( ]' r1 @, F$ y      contentWidth=supertext.offsetWidth% r( m$ r# f" A7 o. g3 u/ i* b1 K
      contentHeight=supertext.offsetHeight
2 i4 n/ P: \: c# l! h      }: X" H8 p( U+ ~
   else if (document.layers) {
7 b9 Z' r- q3 O1 i5 L      xMax = window.innerWidth;
6 d) @+ T+ D1 Q2 E- ^: T      yMax = window.innerHeight;1 P7 ?( k6 C" f# z# i8 L2 |5 b, S
      contentWidth=document.supertext.document.width
5 J+ K# G) Z4 F* @3 s6 q      contentHeight=document.supertext.document.height' [' h8 o) H3 N' _. B8 k
      document.layers["supertext"].visibility = "show";
& d/ B6 A( g9 \  \# }* |      }
& M& R/ S* k1 W% z" _1 a% u   setTimeout('moveBall()',400);0 i% U; T1 m, A2 d  `' A# R8 B
   if (hidetimer!='')
2 i# G7 g: u' `) }7 A   setTimeout("hidetext()",hidetimer)
/ O% ^1 a/ A! Y   }1 g. ~. g! A9 R: X5 X
3 r; ?4 S$ Q9 D( A! d8 Q* `8 U
function moveBall() {
. I6 g% T( L/ `! b- ]! a# {   if (superballRunning == true) {8 E2 p- v7 f& T% [0 Y
      calculatePosition();! v: O7 ~3 m4 }1 _1 R+ u, f1 S
      if (document.all) {
  }" o# @7 h/ Y& W& Y/ h* Q         document.all("supertext").style.left = xPos + document.body.scrollLeft;
& M, A! W; }! P         document.all("supertext").style.top = yPos + document.body.scrollTop;7 G8 x" Y  r7 B4 Z% n' \4 e
         }: k0 \/ u( w& X" K7 ]
      else if (document.layers) {) {/ W! h3 t' A7 `* q
         document.layers["supertext"].left = xPos + pageXOffset;8 ~& ~8 ?* W. T
         document.layers["supertext"].top = yPos + pageYOffset;7 ?5 Z1 }' W5 w7 V  q. |
         }
, E' f& x& K( m1 V& J      animatetext=setTimeout('moveBall()',20);
! s8 E7 ^; J% y8 [  M      }
3 Z: C& o6 t4 c/ X   }9 h1 X" O* T; T( X$ u8 J
( w- D, R7 I: z5 `% ?
function calculatePosition() {
) w2 h' z% g7 `7 ]% P: G1 ^   if (xDir == "right") {5 y5 p; d$ p& U( j
      if (xPos > (xMax - contentWidth - BallSpeed)) {
: V6 F& z5 D7 p: d3 _+ u3 Q         xDir = "left";
% b7 g* _' ?" n5 o6 y         }" a+ {6 Y  U! I5 T. t
      }+ s1 R2 b/ z$ U* u+ ?, h& _
   else if (xDir == "left") {
; C$ W) _$ n4 U0 x! ?: x; F6 l. {+ Q      if (xPos < (0 + BallSpeed)) {
! M# f$ v6 a2 c" q2 t3 j: q         xDir = "right";1 v  N" r) _& F& [5 M6 [1 E
         }: y1 ^9 d; m, K1 N
      }
4 m  I; o0 {! y; {! \$ d+ }! j   if (yDir == "down") {
' d7 W, |+ ~* _8 M6 }7 O1 H  O      if (yPos > (yMax - contentHeight - BallSpeed)) {0 v9 @) j8 N- t' }, l
         yDir = "up";1 J0 i  Q; B) F
         }0 y% p# o8 q' ^. z
      }
4 |  T$ Z9 @9 [$ J3 l& O   else if (yDir == "up") {; |7 {. l) K% O
      if (yPos < (0 + BallSpeed)) {8 i& e/ \' k  W- q. {4 l1 i
         yDir = "down";/ q9 |2 W, w3 A) z- t7 S8 H+ q
         }; f0 V5 A- X# J
      }
9 f% Q8 I* n) n" h! H   if (xDir == "right") {
- K' c6 o5 @3 H      xPos = xPos + BallSpeed;) q6 h6 Y9 c: m( A3 v$ K% y
      }, {2 ]3 w  z; O; x
   else if (xDir == "left") {
3 Y  M5 }* y" s1 V      xPos = xPos - BallSpeed;
. ]' g0 u4 ?" ^5 A! O      }
- a+ L* F9 e6 c6 E5 n* A" }   else {. \/ z7 S  k  F" A4 Q5 E  P
      xPos = xPos;
6 S% }7 S$ A" T: J  ^      }
% B6 P* S1 t& o5 h' u8 N7 P   if (yDir == "down") {
0 i$ r, \+ _4 Y- v7 M7 F      yPos = yPos + BallSpeed;2 l: r: Z9 _; m3 x* a1 u7 y7 @
      }- Q7 Z5 y. C# S
   else if (yDir == "up") {
1 C& ]8 o4 v  l+ G$ p# u- }- G      yPos = yPos - BallSpeed;& `2 N/ b/ Q; c6 H& r
      }! N# p9 d1 o4 w; j4 F' B4 Y
   else {
$ E8 U6 J7 O" _" a$ z2 ?& N1 @      yPos = yPos;! F* P) {& |; D( F" H9 S) y2 _
      }! L. Z$ {9 h; ~* H5 I- M- c( ^5 I
   }: Z0 z( D5 z1 Q0 \' v) T

* g: N  z* o8 `4 L1 k0 N6 `: {function hidetext(){
7 L. z3 I1 _) v# {* F# q4 V+ rif (document.all)
+ U) K1 p0 y3 L/ o* [supertext.style.visibility="hidden". U4 S" E9 W$ ^6 m
else if (document.layers): ?0 |0 \" e* Y+ D' N+ f* m
document.supertext.visibility="hide"$ ?8 F& z/ I9 O( ^( e) }
clearTimeout(animatetext)7 G' |" z2 T# d' _
}) O0 E$ a7 |2 a2 {* n7 l9 a

2 T! s; ^, g: G, ?8 ]* oif (document.all||document.layers){
9 ]# C! T8 V' B, [* r7 Edocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 d, ~! U; A* U( f- A! q  ~4 _window.onload = initializeBall;: m- {+ R" h9 R, ^, J) \
window.onresize = new Function("window.location.reload()");
$ c0 F9 f/ `7 ~% I4 f3 F- E, q# Z}; x$ O% P9 ?$ V$ ?. X! a4 D

2 d+ M4 V, N7 b$ T% V0 {</script>

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