返回列表 发帖

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

<style type="text/css">) Z: X- {6 F& X; W5 A  B
#supertext {
$ t, X* G% ]  f3 ?  g1 e5 j  Eposition:absolute;
' Q. l( r1 q1 {2 t/ ?" }3 [4 Dleft:0;
. ^1 M( o  i) u; B9 S! B) vtop:0;0 J- c5 O- r9 U) s6 X' r
visibility:hide;  {3 n3 K, \$ W8 w* f) m3 ]% x
visibility:hidden;
  b& b$ }! z$ ~9 J  n}2 T1 J9 h3 s" f4 c% u: U
</style>
, q$ Y  F4 ~  T2 }8 R<script language="JavaScript1.2">
) [6 M- T) u/ J: _<!-- 改变下的字体的大小。颜色-->
& r( O: w% I" L  J0 [  ]$ ?' Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( N9 s1 j6 `0 r/ X' kvar hidetimer='';
! p  `+ h$ s  M/ M<!-- 改变下的弹跳速度-->- h' K! s4 d. s& S& |" C# x2 _. y
var BallSpeed = 20;) O1 j& t& L- R$ J
var contentWidth;
3 A% ]& C% c* p0 T' W& U4 |3 _var contentHeight;
3 T7 B1 Y+ C+ N; gvar maxBallSpeed = 50;
) _9 m6 j- t7 U: s' L8 e
2 h5 f1 G: x1 F. D) X
' u6 p8 {' T$ l- Ovar xMax;
# ~& f. c/ `/ x( u! x) Lvar yMax;' \- t3 U, y) \2 }4 I; u
var xPos = 0;
; z3 M" U3 Z' |2 n: v" \: ]& yvar yPos = 0;4 Q6 Z9 d! A$ V3 S( s, [
var xDir = 'right';8 x- I* \. j; D3 W
var yDir = 'down';# [! |5 W7 I+ e, a' W
var superballRunning = true;
% A( W6 W. m( \' ?* yvar tempBallSpeed;$ F9 i: p. T9 C& {7 I6 ?' T( B$ q
var currentBallSrc;3 V9 S9 t) p% I/ n  {* G
var newXDir;4 V: W( v# i' ]! C0 X
var newYDir;
$ a$ X* v+ g9 I2 o- n9 ]- S
$ x/ B& J" ^1 M2 |8 \4 [; v& nfunction initializeBall() {' y8 R: ~* B3 [  i; D. s! j5 E
   if (document.all) {% L) F# G8 u% D* B+ z4 L7 g
      xMax = document.body.clientWidth
2 R/ u' `7 y$ ^8 h' k  W      yMax = document.body.clientHeight) X3 J3 R8 E! _% i' @
      document.all("supertext").style.visibility = "visible";! v. l8 y: L+ n9 l0 m! ~# x  a
      contentWidth=supertext.offsetWidth
- h& @& f% z6 R      contentHeight=supertext.offsetHeight
2 v2 ^8 t9 W. }4 y- {! O      }
- z5 L5 J, M. O   else if (document.layers) {4 R7 l/ L4 u- s2 S' f9 g
      xMax = window.innerWidth;6 h' \/ }& s2 I2 k' b7 O
      yMax = window.innerHeight;( W& v, E3 F% \9 y' q; }% x* [
      contentWidth=document.supertext.document.width
# ^# J: y  C+ c6 p& B  ]9 T/ U      contentHeight=document.supertext.document.height% T8 e2 K8 E$ T- G  x
      document.layers["supertext"].visibility = "show";* f& |/ p" c$ Q% x( M5 D
      }
1 V" m1 C' W+ i3 f% K   setTimeout('moveBall()',400);
3 n! |! O6 ]8 _/ b% `   if (hidetimer!='')
! U5 E& M" T/ Y" Q1 j1 @   setTimeout("hidetext()",hidetimer)
0 {' g4 p& B1 w/ Z+ X. y# B   }
7 i/ y# \7 a. q1 N1 H9 O$ @$ U. w* B! g
function moveBall() {, C5 b% f. T7 ]1 o# j. {
   if (superballRunning == true) {6 a4 R% s7 o1 e. v+ ]0 j6 p
      calculatePosition();
. p* F$ N% e* V7 l* ^      if (document.all) {
6 q( K; x6 Z& L' b" T" d: ]5 n         document.all("supertext").style.left = xPos + document.body.scrollLeft;' _! D# Q' }: F8 p& l; j
         document.all("supertext").style.top = yPos + document.body.scrollTop;
" v3 V2 n2 z" H! b, z         }' _0 A2 k# D+ h" G
      else if (document.layers) {
: u' S# j( D  h         document.layers["supertext"].left = xPos + pageXOffset;8 q; K3 B' x$ b; c+ y
         document.layers["supertext"].top = yPos + pageYOffset;
, j0 d+ y$ _: R* V& j; ?         }0 b& u6 E6 C8 A. A* ]' |
      animatetext=setTimeout('moveBall()',20);6 {8 N, j4 W* R% a' b
      }9 u. J' \. o/ i" q
   }, a$ H' d, [5 L/ l) Q4 v) R
4 B) l7 F' ~) a' U: g8 j
function calculatePosition() {
, o- ?, E/ e* L' u1 _! Z5 R   if (xDir == "right") {
) J+ Y3 h3 k6 \" q      if (xPos > (xMax - contentWidth - BallSpeed)) {0 z0 P/ _% w% \2 x, J
         xDir = "left";' z' \& R, `& Z. F
         }5 b4 g4 J; F" ?' W- S) D
      }
( U1 J8 M! a6 @' |, M+ X   else if (xDir == "left") {% q0 M3 ]: l- [. u
      if (xPos < (0 + BallSpeed)) {
7 W, B  S! z7 z: U. _2 @$ c         xDir = "right";9 _! m2 Z+ Y  R4 w
         }
; z- n* v6 e2 k8 ?6 s! \# L      }5 ?" F* [& Y! ^6 T+ S: f
   if (yDir == "down") {' R+ W6 @# `- j) v9 H8 w
      if (yPos > (yMax - contentHeight - BallSpeed)) {
& k4 Z/ p8 Q7 d; f         yDir = "up";) O5 F8 {  g+ u
         }8 R6 O1 h1 h8 {9 Q
      }
* t0 T0 C& @1 C" G   else if (yDir == "up") {- P; E+ X5 ~; x; h8 f
      if (yPos < (0 + BallSpeed)) {+ q. g8 m3 g, `0 ~
         yDir = "down";  t0 U1 C, B1 d/ Q' d
         }& Q" {0 O; g* d7 @$ n+ J5 C  |
      }, }0 J" o  Y8 D9 j( L7 L, G
   if (xDir == "right") {
( D! `0 A( U  O2 C. H4 x5 Y      xPos = xPos + BallSpeed;
; l# u; E9 W! I2 E& J      }$ e7 I8 @$ Y* e" r
   else if (xDir == "left") {
5 C2 W8 m3 }5 v5 J. t/ m& D      xPos = xPos - BallSpeed;/ b% g/ ?1 U! X# _. ?* V
      }
% `3 o" u. S0 L. v9 L   else {4 |, s/ G8 o* T* I  l1 F$ P+ c  y
      xPos = xPos;2 X. Q- c3 v2 ~7 u/ o6 j+ r( Y
      }
4 t( p2 Q& @7 L  h7 a9 Q   if (yDir == "down") {
0 \, W) \8 D9 ?; p3 Y      yPos = yPos + BallSpeed;
3 e) C. o. d+ p" E2 Q; D1 v. Y( {      }
8 s5 p* q! j' i4 K6 R* @   else if (yDir == "up") {, q7 t- d$ L9 l1 A- A6 Y
      yPos = yPos - BallSpeed;
5 C  x+ Z0 F: E# H& z7 @/ Q& X      }, y2 ~% O: V& d
   else {
6 d# p; h2 n6 O% ^      yPos = yPos;
1 C* S" I! F& y, e3 H* A: \+ E      }% ?) o+ f! D0 V. g
   }
; j& ]) e0 n% B% v5 H/ s) p
9 T/ T; t$ \2 c3 {+ ffunction hidetext(){
( r5 i0 y% G* e/ m5 E' }( Y* gif (document.all)
* l  L& f9 B  w. f& t1 `" ^supertext.style.visibility="hidden"
5 r. h, {6 q3 H' H5 G  d3 belse if (document.layers)
" j9 R& u) q" f, q5 y$ E6 S& Pdocument.supertext.visibility="hide"
0 t1 g- n6 m; J) x% n% QclearTimeout(animatetext)
0 s( S, u) ~1 d. g# }$ B% ~7 M9 U}
3 M! L; M( ]6 S# b& N3 K
6 S4 c  n: h6 V, W( D: G. Nif (document.all||document.layers){% m, k% h# S1 s4 z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')) M" M/ n1 e$ ~
window.onload = initializeBall;5 d% B. d: @" f. ^* Z, Y
window.onresize = new Function("window.location.reload()");* z6 {# f" n+ B* [7 M) l' D
}
8 @( j' H9 o2 p2 \& q  W, ]- S
1 G/ d5 I' o6 z3 G</script>

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