返回列表 发帖

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

<style type="text/css">( @* @8 L& D- I/ Q5 c$ _! ?
#supertext {
2 Q: q0 K1 s6 o( d5 d: @  t) `7 Dposition:absolute;
1 I; [2 @7 N% n  `$ Dleft:0;
3 Y6 g! ~$ V6 h. X, Ztop:0;
, T( V7 Y7 V: h8 Evisibility:hide;
+ ]) T; i. v" d9 Cvisibility:hidden;+ C  p$ ?5 M2 F+ ?" ~9 a  q5 P2 B
}
9 F. [: g8 M$ r) o  u/ `</style>3 G: q% i8 Y9 v# d- R
<script language="JavaScript1.2">  J; Y  u+ z+ i, k2 \( U
<!-- 改变下的字体的大小。颜色-->
! G7 D, g+ r- t# _3 O8 gvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" ?, D* t! I5 n, M8 T4 Z( evar hidetimer='';
* L1 T  U# x( ^# _4 }<!-- 改变下的弹跳速度-->
' e  g+ C+ F; G3 z$ j  jvar BallSpeed = 20;
; x: R: j# L* Y2 O8 avar contentWidth;; v/ o- j% \  \' S+ d
var contentHeight;" n) u) z6 @0 J7 C
var maxBallSpeed = 50;0 X, Q% ^( l( f) ]
# V3 ^( L* |% {  d; v3 V

8 J/ W0 n1 ]: \  e! m( b# }; i1 Uvar xMax;
9 U0 K* k; t: B! i3 Hvar yMax;7 _* F9 w9 U/ F6 k% l' U
var xPos = 0;
: z  B) u& r. X' @$ dvar yPos = 0;$ [5 n- G) V6 Z+ L$ S. W3 ]! B) p7 a9 Y
var xDir = 'right';+ |  w8 p. h  q% w" Z+ P
var yDir = 'down';
/ I5 j5 {0 }" \2 L( ^3 }" m8 zvar superballRunning = true;4 }5 K: b9 x. s3 @) Z# z
var tempBallSpeed;
( T, Q1 J3 J7 r6 dvar currentBallSrc;1 D7 j6 F; u" I& E" y4 v* b' f) V
var newXDir;
5 \1 e/ j# b0 P& \7 [7 |var newYDir;! D0 ?$ S7 k; e' K

7 H" g9 i) m, |1 b$ C+ ~- j* K- jfunction initializeBall() {
) P, k$ i$ ]/ F" U! r   if (document.all) {
$ Y/ D) ~8 e( l* _      xMax = document.body.clientWidth/ R! ^/ t" O- X$ F. e+ S
      yMax = document.body.clientHeight
8 q( g* n! F. U" @* W, A0 a! n      document.all("supertext").style.visibility = "visible";
5 l8 `" V! V1 g. \! _      contentWidth=supertext.offsetWidth3 N+ R- b# g. g2 h" d# x" g
      contentHeight=supertext.offsetHeight
5 ?- T* Q  a. n7 w      }
( S& f, ]: l/ c0 W! B' R   else if (document.layers) {) V9 P  e, i% X8 f+ G
      xMax = window.innerWidth;
! m5 _4 X' D6 u; E      yMax = window.innerHeight;
  D; f% |. S# Y, t# E( d  ?5 B      contentWidth=document.supertext.document.width, _" L/ a: `. L2 d4 m1 b7 x
      contentHeight=document.supertext.document.height* j/ q) b" w: e0 M  T* o1 n
      document.layers["supertext"].visibility = "show";+ k% `0 u. v0 z  d" V
      }: Y* u; Z1 a! c8 I% q8 l3 q
   setTimeout('moveBall()',400);4 ~+ r' K4 q3 k! W. K2 c
   if (hidetimer!='')
# P: \% @3 `% Y2 Q   setTimeout("hidetext()",hidetimer)3 f( p7 n/ d1 [4 r
   }" d- K- R$ l$ ]1 V2 J+ L
& D3 {$ J$ o6 K' e; \7 z: |
function moveBall() {( p) @0 S* [6 s, L6 e( B
   if (superballRunning == true) {
- J/ k- w: y, h' ]      calculatePosition();- n+ Z0 m0 s/ u; d* p; F
      if (document.all) {
, D0 M2 W8 ]$ e9 o5 N5 c         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; c& u7 a5 ?) ~. {0 M  G         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 F# @- d" O1 [' {9 n3 |         }
$ D# O/ J. _0 @2 u4 n5 J: l& ~      else if (document.layers) {3 b: f1 V. l: \0 q' s
         document.layers["supertext"].left = xPos + pageXOffset;
; U; M( w& u1 B3 j3 u         document.layers["supertext"].top = yPos + pageYOffset;
9 {6 U/ \3 x. M  }: I2 v         }
1 M/ j( k8 @. n' @' J2 }      animatetext=setTimeout('moveBall()',20);
& W; M: U; P1 |. Z5 r1 ^& u      }
/ c5 b, Y3 t( ~3 t2 v: }   }
! w+ O5 d2 w% m) M" T! O8 X/ X. d8 s, f2 D) i- g
function calculatePosition() {
* e3 E6 ?! K- O) j  ]   if (xDir == "right") {* w. C  C" o6 E( o. g; F
      if (xPos > (xMax - contentWidth - BallSpeed)) {
& b/ R9 I4 Q( T         xDir = "left";
9 R2 N) U) l: B5 X' B         }
& R- ]. u- Y. B      }* u. V1 i& g4 v& n
   else if (xDir == "left") {0 X, ]( N& l  O
      if (xPos < (0 + BallSpeed)) {
+ T- m, B/ s4 w/ X: j5 t         xDir = "right";8 k, Q9 \; _5 ]% }  k4 Z
         }0 n! W; s3 p: T
      }
, ^9 m+ H/ h8 R  a9 _   if (yDir == "down") {
! ?8 V, ?$ [  |. d& F9 ^      if (yPos > (yMax - contentHeight - BallSpeed)) {$ F, p3 i9 b$ a# B4 j' `. b
         yDir = "up";- N; u( ~8 P9 F( {8 c
         }' o. a8 g' ~* d/ N
      }
; t* y) o& O! f( {   else if (yDir == "up") {
  q* g: I  f% T$ d+ T7 Z0 w3 Y$ e8 G1 D      if (yPos < (0 + BallSpeed)) {
# P; I9 T* Y/ G1 i- a3 T; o         yDir = "down";3 z" {+ F! `' S2 ^
         }
$ e2 _# X- F& A- f# _      }: O& Z) P) P. O6 {5 V0 @
   if (xDir == "right") {, [2 t0 {! M! i. }3 y' |
      xPos = xPos + BallSpeed;
5 c, l/ j+ e! z1 P! x; g6 {+ V      }. T5 W8 E" |4 w9 r' Y# k
   else if (xDir == "left") {
( _1 l( m5 i3 m: ~. [+ D; B# D$ T      xPos = xPos - BallSpeed;
' J: M& _& G- V& ]( s      }
1 L& Z' W6 K+ e" @% M8 p  V   else {
; P+ c$ b! y1 e* ]( `      xPos = xPos;
  ]0 ?( `" V. R! f3 X  n4 e      }
- F0 U9 {9 g1 k7 Y  v& N   if (yDir == "down") {
" d2 v# F% A9 c% a      yPos = yPos + BallSpeed;
8 Y8 Z2 i4 s1 ^      }' u/ m4 f3 a6 H: U0 T& d; t0 ]
   else if (yDir == "up") {1 k4 I$ F" }- |# t1 Q7 o+ A
      yPos = yPos - BallSpeed;
) A" Y: {9 G9 S; {: H- S+ s      }( ?9 p4 D. G1 x7 ]$ ]- u
   else {: S8 x* F. y$ Z9 M
      yPos = yPos;
* T6 Z) r3 w9 b8 l      }
& i$ V2 z3 \; \2 @: X. H& [" r   }$ V% x9 y1 h) g$ k2 e

5 ~' t7 |0 {2 Kfunction hidetext(){
- G, F8 x: W3 c& Y. Bif (document.all)) L" l4 i3 H* E% k4 V
supertext.style.visibility="hidden"
& v% @, k2 p5 @' Y+ W  melse if (document.layers)
( N: F) o  ], o, U# \8 P% r0 F9 kdocument.supertext.visibility="hide"1 @- ~% a$ C& b6 H
clearTimeout(animatetext)
$ T/ m- [. N3 V}0 k( M9 H0 H5 n$ w$ [: ]4 x- v; F$ ?
3 M4 u9 G  X5 C- B: y5 {
if (document.all||document.layers){
8 M. c9 |9 [% u+ s; F0 a4 Idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' z3 \1 q3 _( J- o- j
window.onload = initializeBall;
& Z! U' \0 ]! [window.onresize = new Function("window.location.reload()");
7 A5 n' k5 W( R3 w( u4 C0 p}
/ r( g0 ]. W" Y2 t' V
. k5 e, C% s5 B! u</script>

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