返回列表 发帖

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

<style type="text/css">
# q$ n# ]6 x, L" ~# I$ W#supertext {! G4 V2 K: C9 Q1 {/ q2 v
position:absolute;' G' e. n/ A+ v" m. R( @* a8 N( T
left:0;
4 a: }; e7 K7 `) Utop:0;
, d' W0 h. M" I+ Jvisibility:hide;
) a  n+ X2 M, j) A/ |, z2 {" Wvisibility:hidden;
# y& i! z: t! W- {2 o9 S: @) Y6 P}
1 U+ |' S9 `' |' [& \4 [: T</style>
- M7 y8 z. i* b+ ]8 Z2 F! b<script language="JavaScript1.2">- X6 V  T1 \' V- e
<!-- 改变下的字体的大小。颜色-->
, F+ x3 \- ^6 `$ Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ `) D- w( m! Y* |; y1 i- I# Nvar hidetimer='';5 H) n  {; S, j( [! n
<!-- 改变下的弹跳速度-->
# H7 I1 E0 f) e$ f4 tvar BallSpeed = 20;% F) @! B" X& P1 g  j
var contentWidth;0 r' g# D8 n6 |# J( B6 x8 v" `
var contentHeight;
# b9 U" ~. x3 j  ~* g# avar maxBallSpeed = 50;
3 j$ q$ c9 e. F, ~& y# q8 p
& a8 x" X" ]4 O& e3 V- A0 A" X& K6 q* s: o/ B1 ^+ ]! Q$ f- x( W
var xMax;6 I4 o" I# P8 C5 `( A% Z' R
var yMax;+ {8 G. ?+ D# X, A9 P* a4 D. U& }4 N3 h6 L
var xPos = 0;
" v2 n1 {6 I( f2 j9 v( T) Kvar yPos = 0;! a8 f! j' o7 h- i
var xDir = 'right';
% K, m" m8 e9 e9 E; f1 [var yDir = 'down';
1 o2 S! U& |3 s9 y- X/ `3 gvar superballRunning = true;( P% ]# r0 m/ s7 {8 E
var tempBallSpeed;
$ e% b, l8 J, cvar currentBallSrc;
4 ~# b3 @& D$ Y. q* Rvar newXDir;* H6 b4 L2 W% B! n
var newYDir;* ^9 e0 b; K, N; s

4 G  [  ~' w" l( ?function initializeBall() {
" G  R; D; o0 {% ?4 a1 |& j3 C   if (document.all) {
+ ?, o/ `- W; j' C8 Q  w: d      xMax = document.body.clientWidth
0 g2 ?+ |" L5 \3 @4 ~      yMax = document.body.clientHeight* w1 Y" y1 L: `4 q) X/ d
      document.all("supertext").style.visibility = "visible";
$ w- D4 L$ H% W. t      contentWidth=supertext.offsetWidth
1 W0 {* [6 i7 `: W! r" P9 [      contentHeight=supertext.offsetHeight9 Q" K3 _* K) H& W. ^
      }
. @0 ^, F: U8 x% {7 y  [   else if (document.layers) {. i2 t2 V( _* ]/ d
      xMax = window.innerWidth;
9 |0 @9 i  i2 R/ y3 d      yMax = window.innerHeight;
, i& [: L5 }6 O% T      contentWidth=document.supertext.document.width% w' h% l% g/ f* d
      contentHeight=document.supertext.document.height6 z  l; `  T4 F0 P
      document.layers["supertext"].visibility = "show";
1 @, E* @+ ]) N9 T& a6 X5 g/ M      }/ u+ c3 H$ X# F5 ~9 k. O
   setTimeout('moveBall()',400);' h; |1 m8 L: X) H9 k$ \. P
   if (hidetimer!='')9 r; y4 r2 ]2 F1 `; c# r3 `
   setTimeout("hidetext()",hidetimer)
( D8 P6 b3 l+ Z& K4 p   }
6 ^/ b. y/ i6 o8 @1 @- ]0 [% w/ l4 S, ~; _3 m
function moveBall() {
$ Q* x" @1 i; K- @& ~5 T   if (superballRunning == true) {' s9 I7 U# y$ c8 D3 _" h
      calculatePosition();% A/ T% h( Q% d. L7 V
      if (document.all) {1 O* l9 O4 \, i% C$ Q) @% V) R
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  V0 k- L" c/ i/ P% o/ }2 g         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 K' G: y/ @2 @: [$ `         }
+ V3 u( V" D1 W( s$ l$ {" @" S# Z, [) o      else if (document.layers) {+ d7 V% D+ B. m0 m4 ?# b
         document.layers["supertext"].left = xPos + pageXOffset;
% W4 \- c$ ~" j/ G% q         document.layers["supertext"].top = yPos + pageYOffset;  m: n2 R. L& |$ M
         }( ?) Y1 E4 ?# N; Y" r
      animatetext=setTimeout('moveBall()',20);
; P& [: q% H, P5 n, p. o  F2 {0 g      }& g3 p  S8 c1 q8 c- w  |/ v! V
   }2 R4 p) w# E& v* a( u9 H' M6 N
1 [, C- l0 {9 f) \# z4 L# V. M" n
function calculatePosition() {
; f0 u! O* J. s3 E2 @; O7 R7 h   if (xDir == "right") {
1 G. ~0 p* h. z/ V, c: t* S      if (xPos > (xMax - contentWidth - BallSpeed)) {
/ g5 r" [' O1 O# S7 c         xDir = "left";8 y6 v# |' d7 D3 W+ l
         }/ ?' Q' J- w0 r# j" c3 i$ y
      }
3 b7 p. G7 V: e$ U& ?0 Q& @   else if (xDir == "left") {% {  ?' a: F4 v/ @2 j9 Q8 g4 d( I
      if (xPos < (0 + BallSpeed)) {5 Z  M1 M* e3 |5 c  A  P
         xDir = "right";& _* r1 `$ `2 a& A" U& I
         }, ^. o7 B$ u0 |
      }
( H; G. I0 T: H  F3 i   if (yDir == "down") {4 L; ~# h2 T. G
      if (yPos > (yMax - contentHeight - BallSpeed)) {3 W3 l  d2 z3 ]) `1 r" Y, h/ H
         yDir = "up";
' _; y% l! X4 [4 c& E         }
) B; O/ U& N9 K# R      }6 _, S4 d. _& b& ]5 }
   else if (yDir == "up") {
- p: h0 h, b+ s      if (yPos < (0 + BallSpeed)) {
' r( U" a( a. B         yDir = "down";
1 Q' S0 {; W# v" s+ d  V         }% i3 O. u  o) V- \2 D7 M2 G" ?* T
      }  V* b& y" |  z6 h$ Y+ \: y
   if (xDir == "right") {
% a6 O' @  h  z  R: u( X5 |2 E2 w      xPos = xPos + BallSpeed;
3 ]/ g0 C% i) F  ^      }2 I5 q6 X3 \" Y
   else if (xDir == "left") {9 @7 H. u/ Z7 ~
      xPos = xPos - BallSpeed;
; s4 Y  Y6 }* Q9 ?8 ~. Q* d      }4 Z8 o: x! y$ s. v) H
   else {
2 T: M* o( L0 h: I) V      xPos = xPos;
  L3 ^) d( k3 {, C+ C" X      }6 C3 X$ P' y; L+ g7 ]$ n4 _
   if (yDir == "down") {- t6 N* a' L0 i/ Z$ v( f
      yPos = yPos + BallSpeed;
8 @3 o: c" j% E& l' g3 w; B2 c      }, [% ]1 }: r. t1 q% @
   else if (yDir == "up") {
* u5 a! _$ |  e2 Y8 a2 g! f      yPos = yPos - BallSpeed;
1 G* Y' d4 A* d' ^, Z0 A  ]      }8 ]" y+ U% @7 R
   else {2 f; N: N8 u+ m4 z' J+ ^& w
      yPos = yPos;
. P& O- ]; @2 @8 R% Y# P      }: D8 S: S2 T% k+ Z' A% }
   }
9 T/ r) B! p+ z- T% `% P9 F7 C+ I3 M) ~* K
function hidetext(){! Z; F7 e" J- D* i7 n
if (document.all)
+ x2 @4 n5 D* \) }( a# N, Xsupertext.style.visibility="hidden"
. Y% ]2 `2 z+ G" _. Belse if (document.layers)
8 n8 m2 B0 @; }& [! o' Z) ]. X7 \5 l7 @document.supertext.visibility="hide"
- ^8 d. r( o3 V: H6 n  z4 fclearTimeout(animatetext)8 c, z# F# J( S. M, |
}
) ]8 V3 D- B, [1 ^% J  e; ]$ d: a( t% P
if (document.all||document.layers){$ s' B/ I: _9 M' T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 k% Q; n' c% Q" [7 t! @window.onload = initializeBall;1 x3 [. s9 Q4 p) a3 Z0 U
window.onresize = new Function("window.location.reload()");
& j% u2 M. x! J4 z2 ~}
" d$ a) r* e% D3 M! @$ N# P  c% x
; J' ^) N" \; b0 T- K</script>

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