返回列表 发帖

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

<style type="text/css">
6 I7 L, x4 D( S+ T#supertext {
5 L/ F2 t( x2 B3 G( d7 bposition:absolute;
1 t$ o6 A7 D$ z" }5 }) d4 }left:0;5 k& H" Z8 H0 r
top:0;& }+ M# u/ i. E. t" j: ?
visibility:hide;, ]9 u5 |7 L! d' @5 n: I; G, _
visibility:hidden;/ I6 O% h, q3 b% u
}
2 C) l, i" M, _: U( L$ f7 e) K</style>
5 l7 x0 W7 M7 g: N<script language="JavaScript1.2">
. w9 K  l6 h; p6 x6 C<!-- 改变下的字体的大小。颜色-->" F6 o% h1 f" ?, v% L( v
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 K/ f9 l7 j  u- c! Zvar hidetimer='';
/ \/ G5 a4 I$ t$ x" }% Q$ W* v<!-- 改变下的弹跳速度-->7 t7 j* c4 J# `7 x
var BallSpeed = 20;7 H0 Q. `$ V: h6 d" X6 M
var contentWidth;4 k* {* k. N, F/ F6 f1 y
var contentHeight;
' Z# h4 M: Y7 L* V* Ovar maxBallSpeed = 50;
: Q; J; w+ \& F/ h8 K. `, n0 _, ?) H' g' r

9 q, I7 Z, W$ }: U6 avar xMax;
4 m: U/ k% b) P; K/ ?# [var yMax;
; E/ o6 \4 C% I0 o6 y  Y8 svar xPos = 0;
* R- P. N- S$ A. e2 v4 f, Nvar yPos = 0;
9 U! d  ?7 b# M3 I# V& nvar xDir = 'right';$ n7 B' o9 U5 `9 e2 j% X2 j6 G# ^% e
var yDir = 'down';: f' N5 o9 }2 K1 K% @" r) j
var superballRunning = true;
/ }- M' X6 s7 R. S- h% S. S5 kvar tempBallSpeed;
* |, I3 o8 D* k. ?" p8 h; k/ [var currentBallSrc;
) V/ q1 ~0 z7 _! fvar newXDir;* ^8 N0 I8 k3 o3 t' t9 c: f
var newYDir;
  Y% L; O# K8 p) g6 K
1 j) ?, N4 e$ a: l" xfunction initializeBall() {! {+ Z) R3 ~; d% i, d! q" T
   if (document.all) {
. H- x, s/ d7 ^9 L  [, Q9 H      xMax = document.body.clientWidth  B9 j. d  t+ j- U4 H
      yMax = document.body.clientHeight
) T# I3 {4 H4 r3 C8 @      document.all("supertext").style.visibility = "visible";
7 I7 v9 v$ ]+ X" d! n5 `3 c      contentWidth=supertext.offsetWidth
) h1 I& |7 ^- [' B/ v      contentHeight=supertext.offsetHeight
  |1 P% y/ u7 q      }' {+ L1 }! F% V3 g6 Z& t
   else if (document.layers) {
- k" |$ m/ s8 g      xMax = window.innerWidth;
* n7 v7 Q+ l3 L$ L1 S$ u      yMax = window.innerHeight;
7 S  Q# Y1 Q) P      contentWidth=document.supertext.document.width7 Y$ s2 W$ B6 H& h* S, p
      contentHeight=document.supertext.document.height
( L( H6 J! A8 J: A      document.layers["supertext"].visibility = "show";* w" f+ H: |) f
      }
) t! B" ~% K9 P. y5 I4 y, z3 `   setTimeout('moveBall()',400);" d' G% ]( }8 m) j1 }( l8 A
   if (hidetimer!='')5 f2 Y0 l2 o( n2 d. n. T9 T2 R: s
   setTimeout("hidetext()",hidetimer)8 J8 l" a; r- f$ F
   }& A9 H3 t, w3 [3 O7 T0 ^

: i# N' q. v4 W$ G- z. K4 a7 vfunction moveBall() {
, H+ c: n1 S# m# \   if (superballRunning == true) {
! b: o) ?/ p- p      calculatePosition();; J( z9 q1 ], M0 K% G% I
      if (document.all) {
" j2 E0 U6 ?, P+ ~& ]3 \         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- e3 J. w# |* ?/ C3 T# z$ p         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ Z4 b0 h0 f# w8 ?' n: {4 a: z         }8 A5 U9 Q2 s1 W
      else if (document.layers) {6 S- l" V1 z6 E9 g
         document.layers["supertext"].left = xPos + pageXOffset;- w) x( G) ?: i% _2 q
         document.layers["supertext"].top = yPos + pageYOffset;$ H0 z0 w  A, N# M! y% m4 |
         }, W* N$ ^# |1 D4 K# y3 y
      animatetext=setTimeout('moveBall()',20);  h/ k5 o4 E5 f( _$ r" @
      }
' G+ K5 Q5 |* U2 t0 z   }
3 w7 ?- F# s3 N  |0 b1 ^: F
. z) s- Q( U$ ]function calculatePosition() {
7 ]- w- s  ?! G, u   if (xDir == "right") {
9 f8 _& |% g8 z: v7 [      if (xPos > (xMax - contentWidth - BallSpeed)) {/ d( l- S5 Y. B5 ^$ S  t7 s
         xDir = "left";
: D  f5 }* t: q         }2 R* @% X# A7 Q, `: q
      }. @/ A% I7 L0 r' l0 c
   else if (xDir == "left") {
: N% n7 g% h+ ?$ j      if (xPos < (0 + BallSpeed)) {1 y; P3 b0 m. S5 ?
         xDir = "right";
. D# k" L: k: p5 b; ^         }# W* M& S' }& n  y
      }
' u  p8 M/ E, R   if (yDir == "down") {- q! z' w3 o+ g8 |0 Y+ _+ {' Y9 I4 t
      if (yPos > (yMax - contentHeight - BallSpeed)) {8 a+ {9 Y1 u* s5 v& k
         yDir = "up";1 E( a- b' w" K, C) b
         }
9 ]% Q' V2 @& s$ S( R& t      }( B9 H. @" x- Y
   else if (yDir == "up") {4 d2 ]  k1 Q% [  Z8 V
      if (yPos < (0 + BallSpeed)) {
# g( w7 e& d1 c! M. N7 \5 y         yDir = "down";* m- ^0 p6 Y. a6 X! w: N* u
         }+ _2 x. ~4 Y& [* d
      }
, O* `& i) p/ @/ n/ w  Q: E   if (xDir == "right") {
5 w$ u, a% U' k, s/ u      xPos = xPos + BallSpeed;2 y- Y+ d% U5 Q. @0 y
      }, k1 s* ], S5 D8 y2 m/ G+ Q5 n# {6 _$ f: G
   else if (xDir == "left") {0 [0 u( V+ H! @  Y; `) q
      xPos = xPos - BallSpeed;
" ?6 w+ [3 \) ^2 }      }
% I/ x; j/ q4 W8 I' H  @2 P  U6 Z4 s   else {
5 J3 ?5 l4 ^; [4 Q  N. |      xPos = xPos;
% u* B% t  ~1 B7 x      }; \7 V/ E: }1 m3 \& a) d- j
   if (yDir == "down") {. C) t: k9 _0 D, N6 F2 j
      yPos = yPos + BallSpeed;; |& `6 C2 ?+ H' b8 b' x
      }
" d5 [) n9 k. Z5 Z9 R   else if (yDir == "up") {
% F7 Y7 H3 z; H2 Z      yPos = yPos - BallSpeed;
$ ~. q( L3 [0 l2 w/ G5 Q      }9 ]) g2 K2 b2 p) k% ^& S
   else {  Q: K' B6 ^' O% E# {$ H  F
      yPos = yPos;
) @, ?% f/ H! h0 S% J      }+ K, R. {0 C$ ~2 h0 {' T0 C; Y) O
   }
5 c9 O5 I2 H2 o/ N4 P
1 a: y" |0 R6 rfunction hidetext(){
. D/ A8 |8 ^0 r4 q2 \6 O& V' x! bif (document.all)( A/ i0 {* O6 }7 l& v1 O% W
supertext.style.visibility="hidden"! g: Y5 F5 d  e1 H* d0 l- D0 t
else if (document.layers)# b+ F$ q" y8 p0 ?- }! |% ^
document.supertext.visibility="hide"! D8 y) ]" o. j" h: H: S
clearTimeout(animatetext)  g2 s- x7 s9 q) k
}9 e/ H& p3 O+ y" g9 N4 {, \9 Z
9 }& R, P! W, F# {# k1 a$ n
if (document.all||document.layers){
% H. q# u$ X! E$ adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; ~6 B- [7 s5 n9 L# ^$ ?, g! hwindow.onload = initializeBall;8 m  ?7 s% w: W) H+ j
window.onresize = new Function("window.location.reload()");. Z! M& W9 T; J- I7 _7 c# j
}
  _3 l2 f: S" [& I) X
  z6 x$ `4 X: F" Z- o  ]. Y' Q</script>

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