返回列表 发帖

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

<style type="text/css">! O  x4 @: X/ f
#supertext {4 E: M% `& g1 h0 y) _" n; K- k
position:absolute;
2 i$ a: r  K# k$ V7 M& k/ j. ileft:0;
, f9 K3 L1 p" ^$ n/ ltop:0;
9 c$ U% a3 t$ S- u; g! H# Kvisibility:hide;
" d; M# z( O- M& G" S! I" L6 svisibility:hidden;
! Z6 E9 y* p+ T. I6 E1 F% I6 B}& |+ \: A3 l  K7 ~
</style>
) a4 x: G+ y) b# D<script language="JavaScript1.2">
2 O" D3 l( z4 J. a<!-- 改变下的字体的大小。颜色-->5 s$ S% g  y  [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 N1 S* e8 _, Q( G; B! |4 E
var hidetimer='';, [' t& u  e7 t
<!-- 改变下的弹跳速度-->
& f$ J& ]- K+ F1 V( q) Wvar BallSpeed = 20;: l; O$ T9 W0 w( B# B. H- M0 R2 p
var contentWidth;
9 t/ I0 t/ }1 u/ U$ u" _( Jvar contentHeight;
! t. w5 T+ l* Svar maxBallSpeed = 50;
5 h/ c. n' i$ ^, H9 O  e1 _5 c: Y. i4 m, J0 `0 d
- j" F8 G: R6 S7 M5 E- d
var xMax;
; ]7 \: f% w5 J- u# vvar yMax;
  @& b5 `& B1 K, ~var xPos = 0;
' H/ w* n* F! V% B. Pvar yPos = 0;
5 G! E5 R% h; R2 O7 N& _var xDir = 'right';
/ F, b) @- U! xvar yDir = 'down';
- g$ J' M& i& g3 F8 ]' kvar superballRunning = true;% [1 a8 q9 b& X
var tempBallSpeed;
: k5 x" u: ~4 n/ \var currentBallSrc;
3 e) b( ~! j9 \var newXDir;
( \- l- w% a  i. j6 x4 evar newYDir;
0 Q0 Y( g8 }8 y3 L% g
5 O  v; h8 E5 W' H  Ifunction initializeBall() {
4 k. R; a; j2 ?   if (document.all) {
0 D8 g: t- t( M0 h9 X8 B0 G. P2 W      xMax = document.body.clientWidth# b3 _7 Q2 Y" o6 B6 k. c
      yMax = document.body.clientHeight  s4 n% G& w+ u  p6 Q& N
      document.all("supertext").style.visibility = "visible";
8 e+ u+ v+ m3 _      contentWidth=supertext.offsetWidth
8 K- ]* h& p* ~      contentHeight=supertext.offsetHeight+ l$ }( ~( l" R) p- F
      }9 A/ {# ^/ l& t% M4 a
   else if (document.layers) {8 [& {3 Z' A0 v
      xMax = window.innerWidth;1 r8 b* ]; ?: N4 P) h
      yMax = window.innerHeight;$ y8 _9 i2 w+ L  e5 B. D( Z
      contentWidth=document.supertext.document.width
% K1 d( Y$ f$ p. @! [      contentHeight=document.supertext.document.height4 P( J, z3 J. z3 G& f. v) {% Z
      document.layers["supertext"].visibility = "show";
) J" _0 Q1 I# ^  s0 x      }( G4 i  q" I& t3 x1 P& f1 ^
   setTimeout('moveBall()',400);( d1 r& l# t  T; S* H1 I
   if (hidetimer!='')7 d+ E5 e& X: J" X2 d$ z2 k
   setTimeout("hidetext()",hidetimer)
: ~  }/ ~7 u1 ?3 r. A   }4 u7 v  x/ n; Y! ]/ d+ z

% M7 H0 T- Y6 K7 ^8 U$ T  zfunction moveBall() {; q9 A$ _$ l6 J' l+ F
   if (superballRunning == true) {
; x/ H$ `( V! `/ E      calculatePosition();
5 |. R7 I& ~- ?* P      if (document.all) {
/ q: c0 X& `, d; @8 I% E         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 |" K! u4 E+ W/ i2 J7 V' b         document.all("supertext").style.top = yPos + document.body.scrollTop;9 a* b/ g/ O( V% X
         }) P& K7 F9 e3 x
      else if (document.layers) {
4 B% W3 y3 d! W0 T. f& R         document.layers["supertext"].left = xPos + pageXOffset;
' }7 @4 K1 L4 h8 `# [2 G         document.layers["supertext"].top = yPos + pageYOffset;
/ D" g* e7 t0 \; |) ]         }1 d9 J# B0 _: {! Q  ^: \
      animatetext=setTimeout('moveBall()',20);: H( c! c7 U6 J4 v
      }) a' Z* _2 z1 I! I' E
   }8 L+ \7 |0 P4 m5 q" \4 S

5 A5 T0 m, N" j# |6 p- kfunction calculatePosition() {
5 T3 l1 i, V9 \: }& {0 v   if (xDir == "right") {
3 a+ g0 [& J5 A  M      if (xPos > (xMax - contentWidth - BallSpeed)) {
. Z# E- k$ n7 n         xDir = "left";
7 U" W6 C+ k4 z6 R         }
, x2 A7 r5 U$ k1 B      }
8 M" M5 X, ~, x7 L0 Q6 B' P3 P   else if (xDir == "left") {& ^) k! O+ a, u$ |% v7 F
      if (xPos < (0 + BallSpeed)) {4 ~8 F9 H2 n, P7 q6 }
         xDir = "right";/ p" M$ }. j% l1 J1 v$ o
         }
. V# S  @' [, k3 @2 |& u      }0 k; T1 z& T( w- g4 {  y
   if (yDir == "down") {
* `' [7 {: n+ Y  c/ |7 b8 |      if (yPos > (yMax - contentHeight - BallSpeed)) {+ J4 M8 ]8 L& U4 J( J. ?
         yDir = "up";* w) K: Q7 j! U- j
         }2 V. ~5 B1 |2 c) X: V
      }0 j7 p5 i& v! a+ P6 i" K$ r- g
   else if (yDir == "up") {
7 q) _# i" G! c. j, p7 p      if (yPos < (0 + BallSpeed)) {3 {2 A7 V# G6 ]7 [% f6 U* b* Y+ a: e
         yDir = "down";
1 ~/ K' s; E' L9 t/ h         }4 D! N1 ^/ @: q2 a) `
      }; @0 P! Y& l" J! m8 r% K8 k
   if (xDir == "right") {) Q1 i. x/ E/ ^) N
      xPos = xPos + BallSpeed;* |" F2 J1 x7 ~  B6 k' \
      }
' y' o/ o' e4 A- |: ]9 n0 X3 \3 a   else if (xDir == "left") {; [- q# V% J+ V' i6 F. a/ F, z/ N6 X
      xPos = xPos - BallSpeed;
' S, Z5 E+ b; L. L6 v5 ]( J      }8 n* C: I; T0 B7 }: P9 L
   else {7 g6 s- E8 w* T) d
      xPos = xPos;7 ]2 ?9 C0 O+ o. n: n
      }  F5 T! k  H& n$ ~
   if (yDir == "down") {
, p$ M. A1 j! t; P2 ~% ^% ^      yPos = yPos + BallSpeed;
; V( H$ e, D1 }& S/ \# L; \# E      }) g. d% C% L: y
   else if (yDir == "up") {( i+ ?. h& ^) C
      yPos = yPos - BallSpeed;* {9 R& y  [0 C; Q7 F$ Y; a
      }8 N. P, W+ [% B3 q# m- J+ b' Q
   else {
5 u/ Y  B6 d0 a/ `8 O& p7 O      yPos = yPos;/ ^9 ]* o' o6 I. k& E& q9 b
      }( G* d( P+ M7 f9 T% q
   }
& _& s( V. k8 L
5 X; \6 @2 s: Z7 @$ n7 I7 Q) nfunction hidetext(){
0 s8 F9 v" n% w/ D9 @if (document.all)
6 s2 l. `6 b  V) asupertext.style.visibility="hidden". B, L% b4 @3 u4 m
else if (document.layers). d' n" _% V2 v3 s% m6 K; i! s" |0 c
document.supertext.visibility="hide"
. P  U0 [7 v) o  [, bclearTimeout(animatetext)
( t! _9 b* {  u3 ^}6 S7 N3 y5 A7 m! t. ?4 D
4 M! y, G# E- B$ R8 Z$ l
if (document.all||document.layers){6 r8 G4 S1 R9 W# k3 [) j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 h- i- v( b- J3 T/ s
window.onload = initializeBall;
% t5 H) \2 W0 ]window.onresize = new Function("window.location.reload()");
" `7 Z5 {5 R; j1 R( C7 X}3 J$ U3 D& }- i$ X. g

( J( d; z0 G# L4 _</script>

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