返回列表 发帖

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

<style type="text/css"># a0 m0 `: K; i6 j& e0 K% d% E1 T
#supertext {
# j) S& K6 V" s% R* J+ g1 ?$ Xposition:absolute;
* {/ q: r  S% w7 c; |left:0;4 L0 V5 i" E% y! Y  e
top:0;
* V7 k8 D. y0 E; m9 Y- D* i+ Ovisibility:hide;
' H+ _- t0 I9 t  o, B+ O3 vvisibility:hidden;
" J" b& o4 e9 F5 ^: K}
* A' ^2 a! J0 z8 M$ s- ]</style>: k  @$ Y8 T. G2 f) [! D  B( \; F
<script language="JavaScript1.2">' X  a  y  l: Z0 x2 D
<!-- 改变下的字体的大小。颜色-->
/ g$ M" K  e9 z/ Q4 H* l; jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 Y" X. k( |4 g: i, Pvar hidetimer='';, ?7 }  U* ~6 K9 ]) ]3 B* D5 i
<!-- 改变下的弹跳速度-->
' F2 ?5 l- t. d1 Q' M! Ivar BallSpeed = 20;
! U( Y/ Y) b) o! ?+ Bvar contentWidth;1 u2 g! K+ b# J$ X* f3 J
var contentHeight;
$ ]" S( G+ X- \# qvar maxBallSpeed = 50;6 @4 x: @  c9 z) O$ T; @

9 T* ?4 R/ m* f% \! k
8 w6 ]+ S  O2 m; {* s) `- m. h; b+ |var xMax;
) v  ~: U% c! \- h5 w! ?6 e/ hvar yMax;
* p9 Q8 @) n, E  t# Yvar xPos = 0;
" P: i& s1 m% h7 Mvar yPos = 0;+ x: {( [! ^3 d$ ?) ]
var xDir = 'right';
0 s) f! T+ c% k2 ]" q* rvar yDir = 'down';* m9 R: C( F" `& q% j. B
var superballRunning = true;
$ G2 I/ o% j1 z/ v. o! Vvar tempBallSpeed;
+ {+ \+ G' g. Bvar currentBallSrc;
8 k  H6 p4 {( ?+ N  ~  fvar newXDir;% p9 X, N# A8 _
var newYDir;
9 @" D" R+ t: N7 X* L7 K+ M# O
7 F1 B8 J+ v! @4 Jfunction initializeBall() {
6 z( r  ~  X* @" a' p' h" I/ V4 j   if (document.all) {
0 B# a2 D7 ^. u" x3 E; K      xMax = document.body.clientWidth
! I* D. f- T9 q/ N& P      yMax = document.body.clientHeight/ D1 \5 D1 I' ?/ s5 r6 I' F( d! O# N
      document.all("supertext").style.visibility = "visible";: a# h0 S& _; ~1 O: \) ^
      contentWidth=supertext.offsetWidth, U( ?1 w( ]8 M1 {# K
      contentHeight=supertext.offsetHeight. s5 U0 t- V& S6 y9 a
      }
5 Y: i( A7 H' n3 q3 A3 E$ }( C   else if (document.layers) {
0 o7 V: N8 R' x1 \      xMax = window.innerWidth;
- k1 g5 W" n& w, G) K1 D0 t      yMax = window.innerHeight;
0 W/ R7 C4 w4 i' @+ Z( M" }      contentWidth=document.supertext.document.width
& p$ G9 q. k1 }* b      contentHeight=document.supertext.document.height
1 O5 C2 U  Q0 I) M  U$ I, H  F9 b      document.layers["supertext"].visibility = "show";/ u2 @1 u, Y. J: n# _
      }
* D* \! y% m9 ?   setTimeout('moveBall()',400);: h" c" V1 j0 J1 u; [- o- Z6 D
   if (hidetimer!='')/ Q) M, h* p& a1 n
   setTimeout("hidetext()",hidetimer)
, Y1 o4 U& `3 J' i( `9 ]   }* f5 u. v1 S. l8 {" i- ]9 K

5 s2 D( E; o! H% g+ Qfunction moveBall() {6 r& q4 ]' C( f' W" V1 V
   if (superballRunning == true) {* `, G; h0 X# z: r+ G! d: F  y3 ]. I
      calculatePosition();
% x+ I: o4 J: g      if (document.all) {
2 b) M, M# P( T, v! W2 b) u         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; R+ s  R+ h1 g2 T7 r' w$ y- o         document.all("supertext").style.top = yPos + document.body.scrollTop;& E! T3 A) [2 [+ I  `- W6 N" p3 ~
         }+ C8 k) x5 Q. d
      else if (document.layers) {- |6 ?: B4 J4 f4 m
         document.layers["supertext"].left = xPos + pageXOffset;# X+ T& \) i0 }# |1 r! U5 U" D" X
         document.layers["supertext"].top = yPos + pageYOffset;2 O( P* u" V  u4 b- z
         }
. m3 \2 m: k* ?2 O* }+ |      animatetext=setTimeout('moveBall()',20);' v0 O1 H; K, _9 J
      }0 v  Z- h+ ]" H
   }) |2 K' m5 A/ b- ~+ j
) h$ l. `8 e1 i' Q# h9 T
function calculatePosition() {7 o9 l7 Q3 q; j3 `8 l1 I" `
   if (xDir == "right") {2 }  b: G" V, T6 U9 v
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' L5 Q! F+ `. V0 x5 s9 j7 ~         xDir = "left";
& s5 j6 w+ J, W" _9 }9 R3 }         }6 c7 w; C! I' N3 k" k5 s2 x& n$ ~
      }
- m2 _- V+ t! n/ M) S% o   else if (xDir == "left") {
! F. }- `) v" n  B      if (xPos < (0 + BallSpeed)) {- P% `7 @2 w7 y  {9 b
         xDir = "right";
& M) B% s3 b! }- F         }9 y! ^3 k6 ^! J* J
      }
( z1 P0 U  A% {: w8 S% |# {   if (yDir == "down") {
+ }4 M* R1 \2 ?      if (yPos > (yMax - contentHeight - BallSpeed)) {0 P/ H: M6 U  r/ s
         yDir = "up";# R  U+ D" D" ^' }7 ]. K
         }
/ G/ x4 G, x1 N  T* b      }: E: v# {1 l' t: p( `9 U& ^( G! o
   else if (yDir == "up") {
* G" p0 L* e& |* e* N  l9 ^8 B      if (yPos < (0 + BallSpeed)) {
) r4 G) x3 L1 D/ U         yDir = "down";+ w1 d0 z+ s* @# S( C) v
         }- U% n- {, H) P+ Y
      }5 P- W- q8 e: I
   if (xDir == "right") {  w8 E( m% s- i' h, ?/ w$ p' j6 H: F1 n
      xPos = xPos + BallSpeed;+ x, m( t! C1 c+ Z2 V: ?7 k
      }
2 e, i4 |. l/ {+ j- ?0 k. I   else if (xDir == "left") {7 M" x. u0 t( p8 |6 e; k
      xPos = xPos - BallSpeed;
& [. p9 J) F6 p1 U+ a* ]8 Y6 a. ^      }
6 u5 B4 Z% J# [7 U  u   else {
& T8 }, i* s+ U8 S# k8 c      xPos = xPos;/ ]9 z" P( K: S) j  H% e" O
      }
  G" J8 }& y. y3 @8 Q" y   if (yDir == "down") {7 ?: R; r8 f+ z6 Y- ]4 l$ p
      yPos = yPos + BallSpeed;& K% E. V/ ^9 C: Y) G' {
      }
9 r+ S' \) F5 a6 n  c& f0 C   else if (yDir == "up") {' O4 A5 t0 q6 _9 h4 _* S- w3 ~+ H/ _. p
      yPos = yPos - BallSpeed;: F& g& Y. _( V: L8 l6 E! K
      }2 y- A' i3 y/ x0 }! }  V( w
   else {
- \% T' x: N% _* H, K" Z* a      yPos = yPos;
. i2 v6 f9 x, W$ ?  E. `      }
+ G" t1 H% ?. k. B$ S9 s7 p   }: i2 o$ w+ M/ y- X, |8 \4 j
# R: z' c" g# r/ E  D% @
function hidetext(){, n5 L# U: n8 F& }3 @
if (document.all)
" @: O  {' H' ^4 g7 n9 jsupertext.style.visibility="hidden"
* ~- p2 x* Y2 K, aelse if (document.layers): `8 C: W$ C1 [% m" E
document.supertext.visibility="hide"
" }+ M& L4 g7 A. T4 k  UclearTimeout(animatetext)
5 V2 [( G0 @! B2 `) }7 M+ x3 e0 F}, i% Z" O: }$ q" t2 u, f
9 v1 z1 y8 t2 Q; K7 g# b
if (document.all||document.layers){. G- W& f- z( F: {3 E1 e
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" A1 {, H: z- T# e5 f' \: O7 q" Xwindow.onload = initializeBall;
6 d. h5 X* \. V5 k) y0 C) L4 uwindow.onresize = new Function("window.location.reload()");' e& q7 k9 }( s3 W6 t6 H' N
}
4 L( ?+ ?1 {( h- O, @0 i/ O; s/ H( f9 Z$ z2 c8 H2 S  [
</script>

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