返回列表 发帖

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

<style type="text/css">% |( ?& ]) P: x% f! @
#supertext {
, Y! `/ V% @+ t; Bposition:absolute;  T+ |& X  Z4 w% P! H- A0 X  p
left:0;0 t5 z4 I1 K+ q5 `* k
top:0;
, ^3 c' p- L; g. q, a* n8 cvisibility:hide;$ Z$ ]- |3 O/ y- _
visibility:hidden;+ g* E# D4 y: P9 y7 I0 F! ^2 ]" |
}# \- ~  |8 z' {6 Y: G/ ^
</style>
2 N6 z8 q% c  A- J$ d/ f<script language="JavaScript1.2">8 ?9 r% V# C+ O' S) [# V
<!-- 改变下的字体的大小。颜色-->9 Z  ]. X$ F" w/ ~
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 b; b' {0 Y1 U" H& kvar hidetimer='';& G5 b4 U9 g$ q( i: N8 n
<!-- 改变下的弹跳速度-->
+ Q" r* Y2 m8 Lvar BallSpeed = 20;
4 Q+ {" m2 D# @' _9 nvar contentWidth;
7 b! A, m+ `' D+ D& N3 Xvar contentHeight;
* D" r' i( s, s3 nvar maxBallSpeed = 50;
' Y( k. V+ ?7 t0 O" V1 b+ C
2 w6 a9 H5 T5 [4 O8 x& o* v- {# X0 h- i4 ]7 r. h/ o% q8 a" u( A
var xMax;) g0 M4 R5 u0 D9 n8 ?9 k
var yMax;
) o7 j5 j7 R5 K) Q! m; {+ Ivar xPos = 0;2 l5 q6 y( L  t4 M0 E
var yPos = 0;
/ N- d( J; j  g, Y, q+ xvar xDir = 'right';
9 f3 s3 V1 C' v) W1 Q6 b/ Q3 Mvar yDir = 'down';4 t* Z  H0 [! M# X+ f
var superballRunning = true;
4 h  ]/ R- S' l% c9 Vvar tempBallSpeed;1 m3 |7 b, F  m9 ~
var currentBallSrc;& i- `- {3 [; E; P
var newXDir;
# m! y: l$ A1 H$ K9 k+ w! Hvar newYDir;, \6 e7 T0 w& M1 I/ P& X  u" K4 F
3 N/ ^* M  }! V8 L/ h( E
function initializeBall() {
4 k8 Y7 d# V1 C  a3 a   if (document.all) {+ @; V1 b( S7 b' F. c, l" f8 i
      xMax = document.body.clientWidth  u( U% H9 y* Y+ d4 l/ e
      yMax = document.body.clientHeight
* f  u. E( S# B# k      document.all("supertext").style.visibility = "visible";
9 _! h# ?% x2 o( O7 A. k6 g. ~      contentWidth=supertext.offsetWidth1 a! u4 q* N2 s
      contentHeight=supertext.offsetHeight7 D. f3 ?& t) T3 `( F+ A4 U
      }! k' a4 x1 ~6 y/ p. v$ }+ f
   else if (document.layers) {
/ v( u& }8 K# j9 ]( M      xMax = window.innerWidth;
; Z+ s: k1 q8 W& j$ @9 m) @      yMax = window.innerHeight;
2 n0 M" b' |, r" T/ Z/ S1 H      contentWidth=document.supertext.document.width7 o6 w* J. ~/ N7 ~
      contentHeight=document.supertext.document.height8 R7 ~0 M1 B0 i! v4 n
      document.layers["supertext"].visibility = "show";/ V- ?: [6 b  I
      }
$ j0 L9 q: m" X5 Q7 [9 s: n   setTimeout('moveBall()',400);
% r  E9 ?( |: A7 e/ u$ b; j& J   if (hidetimer!='')  m# ~0 D( g, L2 w# x2 r
   setTimeout("hidetext()",hidetimer)
  G( `1 g/ v, m/ z6 v6 L   }5 l$ [( L" f4 y

  W1 `/ J5 ?; \9 }  cfunction moveBall() {' E" S% L+ p. T! Q% f- a
   if (superballRunning == true) {
- f! w! x" c! o) c4 m) x3 @" u      calculatePosition();
" @, Q' H+ M! {) ^1 r- Q9 N) y      if (document.all) {) e; ~0 q, h' k, Y
         document.all("supertext").style.left = xPos + document.body.scrollLeft;& Z) T" z9 T7 \6 M
         document.all("supertext").style.top = yPos + document.body.scrollTop;
; r$ O) ]. v* w0 D         }
( z  e- B5 h5 v+ m      else if (document.layers) {
. j, q0 L; E- b* C         document.layers["supertext"].left = xPos + pageXOffset;
# Q3 l" s: o) {) k         document.layers["supertext"].top = yPos + pageYOffset;8 ?$ Z" {- K3 f9 E; }) _- G
         }
7 |# L9 P1 O1 J' A" A$ F0 t1 f      animatetext=setTimeout('moveBall()',20);& H3 {: m5 }4 B9 `$ s$ j$ W0 d
      }7 J& `' r2 |1 ?# I5 z) t6 z) r
   }
" x: E6 P5 O" t% S2 _
3 \$ c: _* H  }& b' Sfunction calculatePosition() {
: u/ p2 h3 E. a8 e1 h, \- d   if (xDir == "right") {9 M: f5 O& U! x' u3 G
      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ B0 N1 l6 V: G5 b, M         xDir = "left";3 n2 o5 h7 ~" z1 h" Y1 _1 C  y% p
         }
& |6 `. y4 [  A6 u* \8 M      }/ o% W1 b6 f7 N9 z- U' b9 ?
   else if (xDir == "left") {
( ]! w- f  j4 ^      if (xPos < (0 + BallSpeed)) {+ Z$ U/ \; \0 b- M5 m
         xDir = "right";
9 ]. k" N* _0 Z/ o. P# @         }, J( g, t+ X* x) J6 n2 ~/ Q
      }
& o- \: \. ^* K+ Q   if (yDir == "down") {- g0 e! ?9 c6 W4 s7 H: k& E) d$ r
      if (yPos > (yMax - contentHeight - BallSpeed)) {; w, e# D; s$ |( P1 U
         yDir = "up";/ F( N: T$ H3 F7 z6 y5 M5 X1 T, `* r
         }$ r$ i( f; s. B. X' E  o. C" \
      }0 k, P" y* y' ~! B9 P
   else if (yDir == "up") {; a( M( b4 c% C) @* k0 p
      if (yPos < (0 + BallSpeed)) {, S+ x7 e) i) J+ K' u1 ~5 _
         yDir = "down";
5 a9 M9 v3 O4 X- K         }
4 }: l  ]- K# g* v      }2 C0 F* p' k+ j, [
   if (xDir == "right") {$ Y6 w, T9 v1 g: Z0 W2 p( ^
      xPos = xPos + BallSpeed;5 V, z2 e# r. F, ?
      }
4 V9 U, u7 p2 G$ w   else if (xDir == "left") {
8 y& N0 d! S6 Y4 j" L0 j      xPos = xPos - BallSpeed;* \8 b  K! d8 R- K: n2 D( T  C
      }8 _  g& D* {  X
   else {
) o: N# U' U" P3 i8 A* C* v      xPos = xPos;
! |6 A0 h5 }+ E6 b9 |      }1 u3 F# t  u5 E+ R# b' k) w
   if (yDir == "down") {
0 ~% C- }* f$ M5 E      yPos = yPos + BallSpeed;
+ ~7 W2 W$ a( @0 {# c      }
+ h: }7 M, P. N, ?   else if (yDir == "up") {; C1 x( a' p/ C5 h% W: e
      yPos = yPos - BallSpeed;
' L" X- d/ Q1 ~9 O' D& A5 w      }
+ I% ~; K4 J; ?+ ?% G7 z& C9 J: {   else {  X0 _( x4 a' q) y' o
      yPos = yPos;
1 ~4 a7 _% y* x% ?      }
: }" A8 x7 I! \# K( }   }
) J5 E8 Q& K  l& z8 h3 r$ [5 U( n/ v2 G: [( r) z: i
function hidetext(){
3 J; E" y' [6 d( U" J2 {& eif (document.all)
7 b# {) N% N9 P1 E5 {supertext.style.visibility="hidden"
4 o, s! g+ g4 T4 m$ J: ]# a- Belse if (document.layers)
& I& c' h* o9 vdocument.supertext.visibility="hide"
1 X  ]5 ]8 o  i+ C8 \( {( qclearTimeout(animatetext)
9 z/ _  X3 Q. ^% y( c3 k}9 b9 E4 a6 Q  X
2 q" S: @, r7 z3 q& h# A7 A# T  R
if (document.all||document.layers){
- j6 X2 ?8 @4 tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
- D" W9 S4 D. L- H% k6 jwindow.onload = initializeBall;$ u- c2 [0 V; D8 Z9 z
window.onresize = new Function("window.location.reload()");) F( |' I7 ~& y" G; ]" C6 o% h
}
# b& }% D( {: N9 Y+ \
, s/ [- v1 `3 T! h" |9 i</script>

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