返回列表 发帖

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

<style type="text/css">
7 b( f3 R% C* r( G- L9 o# {" Q+ B#supertext {
' M% @- P$ g4 a' ^8 J' vposition:absolute;# H  n' a1 f  U/ h$ t; ?
left:0;
3 m) J6 w8 L2 l, Jtop:0;
6 Y" }/ p* ~( M2 M" A) hvisibility:hide;
! N( D; D7 x# ~" N0 o/ l1 ^( |visibility:hidden;' q& B$ Q2 d3 r% h. Q
}( E/ [  i& K  A" F6 p/ \
</style>
- c3 H0 o) r* ^% p# ?<script language="JavaScript1.2">
# J. u( M7 U, @5 n  `<!-- 改变下的字体的大小。颜色-->& k/ I" s; \9 r5 H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 l2 y$ a) x8 _. ~# Evar hidetimer='';
6 C2 N. ]. |0 a0 n4 z9 j6 g6 N<!-- 改变下的弹跳速度-->: H: U: u, V1 g4 ]+ [0 K
var BallSpeed = 20;
6 v8 f' F3 y, P# ~' ~var contentWidth;
; X$ ]5 f1 b# `- U9 I0 Y; rvar contentHeight;
1 t8 n2 K1 k$ x$ J/ X$ Pvar maxBallSpeed = 50;: o2 u0 J" O) R/ a( v7 R* V  Y
3 C( c! ?( V' f( ^

, b" G4 H3 @1 ?  ]7 Q, @" ovar xMax;# v& d9 G' \0 M4 X" d0 P; Y
var yMax;/ Q9 P* z4 v- Q" K' h0 W7 a
var xPos = 0;) J1 Q7 U* r6 n( }. w+ N+ P
var yPos = 0;- b/ P8 Z: w: |; t- }$ v& O
var xDir = 'right';4 j. F$ T) L. X  S/ _% v4 P. F
var yDir = 'down';, e3 w, A: h  b& l$ q1 S6 X
var superballRunning = true;
! N- Z) @% \2 q5 W, O3 h  Jvar tempBallSpeed;
9 L3 F7 v' L8 C1 d8 O" ?0 ~8 Cvar currentBallSrc;
- P) Z/ ]& e3 F% Rvar newXDir;) _% U  O/ U3 ~' f# L
var newYDir;/ e+ _( B1 ]+ Z" U! a( Y/ @

: H) ?2 a( N6 ]- j) _  [/ [function initializeBall() {8 s' N8 ]2 k, J" J1 U' z% X+ p
   if (document.all) {
9 a7 }3 S  ~) r6 I9 V  e0 n5 M      xMax = document.body.clientWidth
  B. r* z7 x. _! E) O& m4 a      yMax = document.body.clientHeight% {1 s# K# t- f% i8 H0 A
      document.all("supertext").style.visibility = "visible";
* N7 B  P8 `% ~! u! c5 |      contentWidth=supertext.offsetWidth- M8 y$ Z2 l# D1 h) A: d
      contentHeight=supertext.offsetHeight
- b3 M. \& F, f& z8 G/ {      }
) Z! o2 L& o3 o* t   else if (document.layers) {
6 `4 E4 Q  `6 A* s( r! V' i1 `( k0 f      xMax = window.innerWidth;! M. G" F& [$ f4 U( Y. E
      yMax = window.innerHeight;
4 D0 Q  l! L) S# y* G) c" |* U8 ?$ r      contentWidth=document.supertext.document.width) H+ o& p/ r! O3 }
      contentHeight=document.supertext.document.height
* E& @7 w' x0 x, L- z% v      document.layers["supertext"].visibility = "show";
- y: n* K7 x4 d, E% U  U6 A      }( k) P+ I8 X/ g! d7 d0 _! N! X& k
   setTimeout('moveBall()',400);
3 v' h% B- }  T   if (hidetimer!='')$ j/ d) s, F/ ?& n# }
   setTimeout("hidetext()",hidetimer)
0 r% [$ ?3 w1 f- t" n( S; g   }
8 }0 k/ I- \$ F% ~: t& j7 `6 g% z( J/ e" F% `; E' ?+ X$ d' a
function moveBall() {
( M. v+ u, }5 o# v  y* u; m   if (superballRunning == true) {$ f( _! ?7 x' R. O2 R4 {% I& m( c
      calculatePosition();
; _1 D/ D2 B6 H& [( i+ T! d* {      if (document.all) {
% a0 ?$ B  r8 Z! k         document.all("supertext").style.left = xPos + document.body.scrollLeft;# }" @7 G8 P0 H+ U5 `# _2 H) Z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
* P2 x" j# P/ `& R         }
: [7 i" \" v( ~" G8 |/ w, y      else if (document.layers) {
1 Z) g5 s: b1 S3 P6 {8 W5 C         document.layers["supertext"].left = xPos + pageXOffset;  Z4 e+ i8 g  u! _
         document.layers["supertext"].top = yPos + pageYOffset;
3 Z5 j6 p# Z# P5 ]4 A0 u4 P5 C1 I2 n         }; _, ]0 Y/ k) {
      animatetext=setTimeout('moveBall()',20);
" e3 F: U6 \- A: D& X) t      }
* N7 S6 C; \4 l; ?   }
$ z2 K1 Y$ L7 o3 O8 \+ G& d# p7 ~7 H7 y2 a' v+ w
function calculatePosition() {
1 O2 F! A5 H. ^5 ?6 v1 H- r3 ?% }   if (xDir == "right") {# N0 k  p7 m1 }4 W# z! G+ g
      if (xPos > (xMax - contentWidth - BallSpeed)) {! T* S) y+ Q9 U% _7 T
         xDir = "left";
# P: d3 p4 K& R7 [         }
+ H. O0 O5 s) p9 x+ ~      }- {/ |" {; j! O: ]! y3 f
   else if (xDir == "left") {4 {, K' M5 T1 d2 _: i( F! m  a" Y
      if (xPos < (0 + BallSpeed)) {3 U* V- @/ v( |6 B  J( Q; e
         xDir = "right";. J3 ~& k2 k: H/ X& H" ~/ w
         }
# S% u2 e8 ~9 P* V      }
/ y0 x+ B# a: Y. ^, x   if (yDir == "down") {" c" ~7 A  l1 L7 j, I+ I  v& w
      if (yPos > (yMax - contentHeight - BallSpeed)) {) i% ^, Q9 h1 A. h7 f7 \8 D! d3 G# p
         yDir = "up";
' z4 o' ]+ C; k' U         }6 P( J* |7 ~. g5 H* a# \
      }
8 G) z7 [. P; k  i   else if (yDir == "up") {
4 a8 u  Q# E4 g, E- O      if (yPos < (0 + BallSpeed)) {8 N* O8 q$ m& Z8 S# h
         yDir = "down";) S% o: [8 P  k1 m9 t
         }
+ z, E" ^& w8 s' G      }& T6 R) k, k4 Z1 e
   if (xDir == "right") {
4 L& ~) D; |3 m$ {$ ^, U/ j      xPos = xPos + BallSpeed;
8 b) a4 [5 _$ r% e      }+ h+ c' ~! S6 P& v
   else if (xDir == "left") {0 i  O" S6 x$ P# c0 N) b
      xPos = xPos - BallSpeed;
$ ~4 M4 V8 z- e5 j+ J      }) A3 ~* H9 l0 B; {! Z2 R+ u
   else {) K, F5 f) G, h# H* I2 w' q" ]
      xPos = xPos;
) k5 b/ z- E8 b: A3 b8 e      }1 b; k5 m9 u: o7 Z9 o. J
   if (yDir == "down") {
" ?1 F7 a5 X6 e" o7 W      yPos = yPos + BallSpeed;
. p# @' @+ }! x1 `5 b      }
. H1 a3 x1 T  c/ T7 I; C5 y% [9 f   else if (yDir == "up") {3 ^8 ?1 W# }) _  O
      yPos = yPos - BallSpeed;
* J. Z6 w/ |9 L6 O      }
3 S+ S: k/ C& V   else {
& q# H2 r/ ~6 Y! l      yPos = yPos;
# \# L" J- I+ l7 G0 _0 ]# `) g      }; a* ^1 v2 c- W6 W9 }& m; S
   }
+ S4 Y0 z1 }* z2 R3 `7 d% I2 N; B
5 V( n; p# P$ a1 f4 w* g2 Cfunction hidetext(){7 h( x) N5 P! a
if (document.all)
- A5 j; k; }; ^- o* osupertext.style.visibility="hidden"
' R' n( J* I5 D) ^. g7 b7 Y1 Uelse if (document.layers)
- R% F' G4 }4 Z- F% X* idocument.supertext.visibility="hide"
  ?* K0 O$ f3 A5 f* b/ w( nclearTimeout(animatetext)
; c9 r& P1 z5 a4 T) O8 O9 ~" ?}( ~- }. ~# d, Q4 W- ^( ^  M
$ n' v. ]9 {% \7 l, D% @; \
if (document.all||document.layers){5 H- X- V* k( N
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')! e/ F; @% P! J1 {
window.onload = initializeBall;) i3 U$ E, ~5 O' b9 v
window.onresize = new Function("window.location.reload()");4 I' a( O3 C. k/ I
}
$ a; E& b* e# Y7 D) {3 [0 _6 ?  y* h) G+ Z) ?9 J8 X
</script>

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