返回列表 发帖

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

<style type="text/css">
8 r  C- i* p! j9 c" `  h& c2 j#supertext {/ @' k6 G/ X. q) b
position:absolute;9 _9 K% z2 g: l; w0 S
left:0;
. W, H2 y4 R) Ztop:0;
2 D6 \- z' k: ]& A" O% f8 @' ovisibility:hide;
! N2 v. s1 B4 v$ [visibility:hidden;
& l- C8 F, F* F& @6 O}
" ]& v* {6 K7 o" Z$ E* s# g</style>7 ^$ @- |/ N+ J2 E2 X0 f1 T7 D( m
<script language="JavaScript1.2">
. s, G' ~: k1 ?, y/ B. m1 a8 B<!-- 改变下的字体的大小。颜色--># Z+ A0 g; P# A) d- ?/ A4 r( r
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
! r. H7 Y5 m# e6 [! jvar hidetimer='';. h) Y, L0 d& o+ Y+ f
<!-- 改变下的弹跳速度-->
$ v* @2 h7 r3 w% ~6 w* p; s7 `var BallSpeed = 20;! u2 Q4 B/ f0 x) Z) y- j- I' T
var contentWidth;+ y  K( f0 b; Z4 M' ^* a
var contentHeight;+ V* |! e$ h6 y3 n- [- \
var maxBallSpeed = 50;
' W0 b% e2 I: X! P9 V" ^  t- G$ B+ \: |/ D6 c8 v1 v  @7 X
7 P3 A1 g3 w# R0 u, o6 q4 ~6 ]
var xMax;6 ~. C9 x2 {# y  G0 a7 m
var yMax;; h/ p# E# ^, S$ S
var xPos = 0;
, {, K1 N, h" m: Jvar yPos = 0;8 J* q9 V1 z( N
var xDir = 'right';
2 ~5 d5 }' n, avar yDir = 'down';
2 N/ a+ C1 Q& qvar superballRunning = true;  c( l2 [0 {4 r$ i6 @8 |
var tempBallSpeed;
4 L' Z9 Z* d$ P+ d9 dvar currentBallSrc;4 U3 I/ W1 L4 b. o
var newXDir;5 n' k0 _$ J1 ]4 n9 @2 n; A
var newYDir;
3 x) W0 {* J0 ]% P# p* `; }# {* \' t; B
function initializeBall() {2 h2 J/ p( ?, Q5 H4 O# J
   if (document.all) {/ \& m  a0 j: a7 b& I
      xMax = document.body.clientWidth: l) \8 h1 v) e
      yMax = document.body.clientHeight
& D/ M4 X. Y6 y6 Z1 Q      document.all("supertext").style.visibility = "visible";- h8 \. p: @3 j4 R% O+ u- Q
      contentWidth=supertext.offsetWidth  C# Y4 ^% t0 ~' p8 n% {- J
      contentHeight=supertext.offsetHeight
0 T0 p# j( j) \& [      }
+ ]1 F" g4 o3 T* b3 }7 T8 s! y8 ]   else if (document.layers) {$ B* K: b3 O4 e' g7 x- ~
      xMax = window.innerWidth;- h& x6 ?" Q- V5 f& k' G  x/ @
      yMax = window.innerHeight;
/ z+ g5 C. ~' G7 \5 e/ t! K* ^      contentWidth=document.supertext.document.width, l, B: X6 s  E
      contentHeight=document.supertext.document.height# G3 f5 z- e8 v4 q+ Z
      document.layers["supertext"].visibility = "show";
% U' }0 X4 f$ d9 o3 ?2 n7 L      }3 K( X7 P4 ~* e' l1 R% v) @
   setTimeout('moveBall()',400);
4 e4 X6 A8 a- u& Y% O5 E5 [   if (hidetimer!='')
+ @: N0 V' A! l# @5 p" ]   setTimeout("hidetext()",hidetimer)1 Y1 i6 b9 I( S: `; w4 r
   }
- _' I5 r( u! B5 x6 w/ a* `4 Z; m, a, D# i
function moveBall() {
7 O& V, D6 |& n   if (superballRunning == true) {
! l$ E, z" o9 D- |      calculatePosition();
- q2 X. x. L* A: S. O' L2 }. @      if (document.all) {
& m7 e+ q) l  g) c0 f4 h         document.all("supertext").style.left = xPos + document.body.scrollLeft;  w9 T, F1 c  R8 V) z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
' j8 ], _3 w3 i) k( m         }* Y) m2 o9 }  j3 r/ N
      else if (document.layers) {7 A* V+ w0 W) P$ `% K* J* E
         document.layers["supertext"].left = xPos + pageXOffset;$ Y1 y: V3 k9 ?  _, V
         document.layers["supertext"].top = yPos + pageYOffset;. o9 x+ v( ^  l) c  F6 h
         }+ ~6 ]* A( N) Q, o& s4 d+ d  Q
      animatetext=setTimeout('moveBall()',20);
# j1 v3 N6 h9 K  e6 c0 c      }
3 }5 `& N6 L5 ], @9 a, E   }
8 D1 ?! l" E  E6 ?/ m9 |  d8 K
5 U5 D! H* M% ?function calculatePosition() {) U3 C, v+ N) R( x! }' Q! |
   if (xDir == "right") {
7 x2 K& T1 M/ _7 v2 B      if (xPos > (xMax - contentWidth - BallSpeed)) {
) a: b4 p' M5 z; C         xDir = "left";+ Q; a& j% V8 ?1 |3 x! e7 B
         }. U- n! @$ K  J: a  @
      }
+ c- o/ T8 ]0 }4 S   else if (xDir == "left") {- Y1 P1 s% c+ V& x- |5 [
      if (xPos < (0 + BallSpeed)) {
. C2 n# |+ Z7 p3 L" p* t! R         xDir = "right";4 h( M3 O( V- E1 O, a( g
         }
+ Y5 z& M4 d  J      }
4 V$ s8 d4 U  c" G3 I   if (yDir == "down") {
+ S4 L: J: q( L: F/ b% o. t      if (yPos > (yMax - contentHeight - BallSpeed)) {* ~) f; |9 ?3 ^
         yDir = "up";: @: v/ ]9 X; F8 W/ e$ v) W+ j
         }
6 J* k* Z$ M  }  N) f3 I: Z      }
1 t/ `4 z( L/ v$ }  V3 x   else if (yDir == "up") {+ u0 r( B: T0 Q1 s, u3 r
      if (yPos < (0 + BallSpeed)) {( w2 n  {. b1 g
         yDir = "down";3 N# f6 N7 b- ^6 ^! x4 d4 [! f* e4 u
         }
/ m; J0 L4 A  G      }& F* j$ M) _7 s, S
   if (xDir == "right") {% R! ?/ C# j. B; x# ~7 q2 ]$ T
      xPos = xPos + BallSpeed;- P6 {- l- d; L. h7 T
      }
3 z0 `" K/ P7 E5 R   else if (xDir == "left") {4 L; n+ F/ G' F. k% a- [3 W' R
      xPos = xPos - BallSpeed;
0 @( s$ f5 S2 n: z4 S' x- u      }
- V$ v# z; A9 ^/ j4 Y% |3 C   else {: v" \, L% i* i) a
      xPos = xPos;
6 o! }( G' U; [; U) t% U% N; w1 h) m      }& R/ ?, a+ q' S# A% {" a/ t
   if (yDir == "down") {$ ~; r' U8 Z* V  [
      yPos = yPos + BallSpeed;
# M6 ^% R' }) p: l+ u0 b      }
* o: E0 a; v8 m   else if (yDir == "up") {" q& M, H( B- `2 [5 h
      yPos = yPos - BallSpeed;' |5 T2 }0 R! W
      }) Y% T3 m+ w& t
   else {1 K+ _1 e% Z* ]3 U
      yPos = yPos;. d# j4 p" F# p2 [* e7 L6 Z
      }. O, W7 k% d1 b- a! `: p. v
   }
( T5 L$ C' R( J' j) h( F! @# o) W& E# i+ v
function hidetext(){
, @5 J- x4 k  [- Lif (document.all). F$ D  w: |! S+ n* h$ u; V
supertext.style.visibility="hidden"* w. I1 m' h8 l6 m, J7 @
else if (document.layers)
% ?; F- t. k+ d9 M' q2 d$ udocument.supertext.visibility="hide"6 {3 c. ]0 k9 e) A, V, @2 F5 D
clearTimeout(animatetext), S( q) m0 {; v  q
}% X8 T% U4 I$ `: R4 V
$ y# J3 ]+ d0 Y$ D: p0 T0 w9 `* j
if (document.all||document.layers){
8 }2 E/ Z& o8 @- _4 Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), ^: S) o) L5 O: `* J! [3 w+ @
window.onload = initializeBall;; i0 n  t8 D8 o/ M% F
window.onresize = new Function("window.location.reload()");
8 Q0 y+ \7 N8 w; C}  I- b9 N# S7 N( N
4 q7 w. s1 w& S
</script>

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