返回列表 发帖

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

<style type="text/css">8 G, c# V# T- _8 I4 d& e: Y5 V
#supertext {6 Q5 y5 ?+ B  {' B6 v
position:absolute;
5 o4 J3 V0 D6 {7 Tleft:0;! {7 ]% Z7 w/ B# u2 _
top:0;/ \* u7 F% X5 n8 T$ w4 ~
visibility:hide;
% R8 Z8 v% h; d" Y& H  r( Cvisibility:hidden;
3 f: i' s# ^2 _. _2 I+ Q; q  a}
9 h1 \+ z7 l6 e' ~</style>
! Y9 |' N0 N; o, k$ I<script language="JavaScript1.2">
) M7 c$ ?* B  X. f7 g% G; V) |<!-- 改变下的字体的大小。颜色-->
2 {& V) {% ]+ n+ qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" W. n. J0 r3 `6 j$ U' p5 j4 a4 W0 b2 ovar hidetimer='';
! r- n$ q! Y" r<!-- 改变下的弹跳速度-->
3 n1 @/ `' H  H* z  xvar BallSpeed = 20;
/ W% P; W8 [# C7 E) ^; Hvar contentWidth;
) r3 s; @. O, ovar contentHeight;; K- ?2 g1 `; ^
var maxBallSpeed = 50;
% r1 @* @$ X# h% T( \- }. O; N7 B1 q% g6 o5 ]/ O3 M
: D4 ^6 f7 P0 |7 h: t% b: h- T
var xMax;
3 l# Q6 C1 m3 P% b; qvar yMax;& z( D0 O& n, \
var xPos = 0;
  E' K/ K  T3 s/ D- Cvar yPos = 0;
. `) m6 L8 S% ~: z. \) Y8 Vvar xDir = 'right';+ k# S' u! e- a5 P
var yDir = 'down';
+ f: d* U) ]# P1 \) a- r" Z! kvar superballRunning = true;
+ Q0 F9 b/ t& i- q' G! _var tempBallSpeed;# \  K  i* h2 a9 Y' B0 U' h
var currentBallSrc;
! M7 J9 k( }, wvar newXDir;- [0 k/ w+ m8 V' I
var newYDir;( t0 @9 c7 [: W% s' p+ b( ]  j/ `

5 L/ |0 T; ~! Y' Rfunction initializeBall() {$ q( |: o. O1 Q! B3 h; U1 c
   if (document.all) {
! C) i5 E6 h/ J, k+ _      xMax = document.body.clientWidth3 v( f5 }8 G: p+ S# q
      yMax = document.body.clientHeight
+ P* K3 O0 D% p7 ~$ D  U      document.all("supertext").style.visibility = "visible";
8 }& u! {9 R% E* j! z* r2 i+ Z      contentWidth=supertext.offsetWidth
* I$ Y2 @+ P  v4 v* n6 r! j4 O      contentHeight=supertext.offsetHeight
# c1 ?" n$ {( B      }% ~$ X, o  _: R6 K
   else if (document.layers) {; r1 \# G3 I% |3 l+ z& d. G3 t
      xMax = window.innerWidth;
& z5 H/ {/ n- L4 ~1 c      yMax = window.innerHeight;8 i4 m+ T6 R9 C8 W: r+ R9 `( G( F$ G
      contentWidth=document.supertext.document.width. \5 L! g+ \3 ~0 H' Y+ K% @
      contentHeight=document.supertext.document.height
# Y6 ^3 Q( Y0 ]; j4 r9 L      document.layers["supertext"].visibility = "show";% z* @1 S! m2 ]5 _) n) ~# b
      }7 W+ Z- ~2 W- [, j: T. t/ p3 e
   setTimeout('moveBall()',400);
  \8 j& T5 V: O   if (hidetimer!='')4 s& N+ X1 t: ^* [
   setTimeout("hidetext()",hidetimer), i8 I# u3 l% Y3 f4 T
   }; s7 ]. A1 o2 G. L) e2 Z
0 k: M$ v2 d0 V) D$ F. V, r+ a0 a
function moveBall() {
! G& D4 P3 E! r" e   if (superballRunning == true) {. c7 C) F0 x; N
      calculatePosition();
, G  U% L9 b$ F' m; q: y      if (document.all) {
5 D! J% B" a7 i; R$ T         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 c2 g) C9 t6 b( P0 [3 g% V
         document.all("supertext").style.top = yPos + document.body.scrollTop;
+ c8 a! _. o' N' H         }2 Q0 q% v5 ]9 ~6 S
      else if (document.layers) {  {, t. z! t4 k3 K4 D/ o3 R: b
         document.layers["supertext"].left = xPos + pageXOffset;% Y4 M& p; j% y# m5 O
         document.layers["supertext"].top = yPos + pageYOffset;
) P6 \2 {0 l" |         }
: L- o3 n2 ~( a$ e, V$ o      animatetext=setTimeout('moveBall()',20);
# H9 i0 o# f2 q- _2 w: z% \      }
( X0 g  I% r9 R   }/ Y4 i$ D! _# \
( l4 e& E* r( e6 |8 m- v
function calculatePosition() {) S4 E3 T; r2 H7 Q
   if (xDir == "right") {
4 T! T# e. x! Q# ^$ i      if (xPos > (xMax - contentWidth - BallSpeed)) {3 z. c2 ]; A0 q
         xDir = "left";
  ]1 ?4 D( S9 H/ C1 g8 S         }/ C  Q2 P  v9 k( T# [
      }
; c1 a% S/ }& v( f, \6 Q8 C   else if (xDir == "left") {6 j$ k9 ?& u( c4 ^/ r5 L6 h
      if (xPos < (0 + BallSpeed)) {) G1 P9 h' O- [8 @& e9 _# s9 S
         xDir = "right";* Z; N/ \$ Y5 a
         }
! @& H  i5 G+ q5 Z/ ^3 [      }
! e; c% o; C, g3 Y) }   if (yDir == "down") {6 V; M# m3 J) E0 M6 B) y2 }: D
      if (yPos > (yMax - contentHeight - BallSpeed)) {' a, c+ t+ ?; c' q, C7 z
         yDir = "up";
+ G- ~2 Z8 |5 T7 i1 [' y         }
. l- e" W- P. \% z7 G: m. i      }
* u, k6 V( w9 t9 u! }) H- K  X   else if (yDir == "up") {
7 s* Z$ H/ X0 k1 |! p      if (yPos < (0 + BallSpeed)) {  q- d% H. u) V& A& O
         yDir = "down";
2 X1 l9 d; J1 e         }  f  K2 f* p& J3 m; R
      }9 ^, f* n: [0 H5 x& T+ ~3 W  F' b
   if (xDir == "right") {2 m; w, r5 e/ R  Q8 s4 K; x
      xPos = xPos + BallSpeed;. k" O5 f- }( w5 ]- C
      }( ^$ H( ~0 ^# h
   else if (xDir == "left") {, G! u$ \, C- i  m5 F# M5 a
      xPos = xPos - BallSpeed;
9 P. l& p$ N; G( J; L  J      }, n" r+ _! Z/ b: @! H: c: l
   else {
# W! s4 E. C& _6 g1 s- v      xPos = xPos;& b0 J: v$ W/ C4 x+ ]
      }, l* o7 }  }. q' i
   if (yDir == "down") {
) K2 S# a* i7 c/ H" q      yPos = yPos + BallSpeed;# ^; X8 ?0 r' w2 a5 [1 S5 s
      }- ^4 i/ V7 n( Z- m( V2 \2 M
   else if (yDir == "up") {
- h8 S" b# b8 U' V3 q1 W* g      yPos = yPos - BallSpeed;
* Q1 o; b: `: F4 }      }, m' C' ?$ U" G$ R9 u) [
   else {
% F+ L  X, }3 g, A      yPos = yPos;% f% a* h5 T  G: s; B# B% u% Z
      }
) M1 z& ~% T7 n; q5 q   }1 k! j% I) e# b  {, y  S8 G

& E5 \4 [/ R* S+ q4 o# sfunction hidetext(){
6 x; H5 l4 ?& e1 j6 Aif (document.all)
  K6 T, W. ]9 o5 |: ?1 asupertext.style.visibility="hidden"
+ I8 W; t  u% telse if (document.layers)
, p* v6 s& l1 y0 M, cdocument.supertext.visibility="hide"
  q- w! j) y+ ^/ z8 {clearTimeout(animatetext)
. t$ c+ x1 N( E* Q* R' F}9 a0 M0 O+ ]4 R! u
  E4 L( D: @, I6 E) ^* B1 g7 u
if (document.all||document.layers){: _! V4 \: T& u  ]4 {# |7 y/ d( b
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ \1 P- A/ B) B$ }/ M4 k7 E5 N
window.onload = initializeBall;$ m' y" `; k9 L* o" T  _) M  \
window.onresize = new Function("window.location.reload()");
# U: G+ Z( a' H5 c% K+ Q, @}0 m4 x( O3 a$ n1 \4 V
( \* W2 B  a: g3 p8 E; p
</script>

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