返回列表 发帖

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

<style type="text/css">
) ?) t% `7 [, W#supertext {1 p4 A3 a* c1 z( P* D# S, d9 X
position:absolute;, ~5 d/ z! q" p/ a8 F: y
left:0;
, G+ t' r$ o' ~4 b1 D5 vtop:0;
( H0 b( S, u+ }! I) }6 h0 xvisibility:hide;
) s; s, y( b3 ~3 X0 T# Z- `) Pvisibility:hidden;- @- ~5 \  h! T1 W4 k7 ?5 {
}
0 n) T( @  I5 |( G8 _</style>! P; w) p' f/ ~; E' f* ?* j
<script language="JavaScript1.2">
  @; H  r- Q( K<!-- 改变下的字体的大小。颜色-->
( `1 O, j7 y0 J; D( }% qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'- @/ U' a7 A. |, u) N/ L" E
var hidetimer='';6 f5 Z% r  |' M, o
<!-- 改变下的弹跳速度-->
9 B7 F* |) h9 ~/ w, ~. ~var BallSpeed = 20;
0 g# w$ T/ Q! m4 u8 yvar contentWidth;
& ?, W* p) ~) C) ]! T5 M" gvar contentHeight;
7 S: S& x( P7 Q& n' l9 r3 bvar maxBallSpeed = 50;  l8 r7 {0 ?+ R- y
' A0 @' p/ ^' |3 S9 Y; Q" |

7 o4 _; U1 ?! F3 Svar xMax;* a1 F( p) O+ I$ {6 q/ \" Z3 N; Q
var yMax;
9 z; F9 f+ j2 l/ pvar xPos = 0;- D3 Q9 n2 M+ T# R' U
var yPos = 0;) r* U5 Y! s  k6 L6 P1 N
var xDir = 'right';
" n# `$ K* f. t6 x9 zvar yDir = 'down';. n7 J5 L( v" s! X: ]
var superballRunning = true;' p# z- D4 t% p! s: h
var tempBallSpeed;
! x) O/ F; u# A% n. Zvar currentBallSrc;" I4 Y9 Y$ {4 T& g  }- x0 \
var newXDir;
. Y; q( z6 w* b, z, Nvar newYDir;; x& t) i$ V* E( A
4 g  H- j* a, P4 y# G6 V3 |+ h
function initializeBall() {
5 E  t7 g( r. Q) E% j9 E   if (document.all) {. ]% a  k; P1 s8 T
      xMax = document.body.clientWidth; v) E( L- v; `+ M
      yMax = document.body.clientHeight
& [% z* Y7 f+ w6 j: B4 z      document.all("supertext").style.visibility = "visible";; r5 M3 q* D9 D
      contentWidth=supertext.offsetWidth
; Z- E; n/ G. y) r) c* Y% {      contentHeight=supertext.offsetHeight
6 h0 ~7 X+ g8 h. D' u$ l$ I      }. m* I" M! {- Z& O: B8 W+ V$ R
   else if (document.layers) {
( D2 _, n2 O# r5 _1 T: z7 _* L& u      xMax = window.innerWidth;9 x: H8 E( I' P3 \
      yMax = window.innerHeight;
9 R- U+ ~! k' w4 ~4 A* t+ ~      contentWidth=document.supertext.document.width! k* _: w, y: k; t" V, f
      contentHeight=document.supertext.document.height" |! d( T/ V8 G# g
      document.layers["supertext"].visibility = "show";
' x6 n; Q" X+ ^0 P      }. b. P' X0 M% z- T* S9 H4 V
   setTimeout('moveBall()',400);
. v' V8 D1 i: d1 T   if (hidetimer!='')
3 p8 p3 t0 U+ C1 t  I9 d   setTimeout("hidetext()",hidetimer)
  y; T! g* q4 H% Q, O2 U   }6 c- G, g1 Y$ N( t5 B6 Z4 }1 i

; Q* V! E5 N* x5 W: Ifunction moveBall() {1 P7 l! f( V3 B- r& y+ R5 w
   if (superballRunning == true) {, u& w: [4 z! D6 I$ _: u
      calculatePosition();0 _- O  I7 w( q3 S; M$ M; V7 |
      if (document.all) {
5 E3 U. S4 m4 n         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% u! d+ u  {* d, A& T. f         document.all("supertext").style.top = yPos + document.body.scrollTop;# O4 t/ N" c+ p2 }, |) W; B" B1 x
         }' _: X% C( e9 O; O3 U: W7 l
      else if (document.layers) {
% V) H0 b' {  l( ^5 Z6 Z" n         document.layers["supertext"].left = xPos + pageXOffset;+ p# U3 `4 r" R+ W7 W. p
         document.layers["supertext"].top = yPos + pageYOffset;( i/ y: `: g/ P' [
         }  y. }- g9 O4 p
      animatetext=setTimeout('moveBall()',20);0 c. V9 n/ B0 m) A7 m4 z
      }6 O$ ]& L: x' f3 w% ?
   }
; m; X8 Q3 [: l$ a6 e1 P" Q3 z" k( C2 Y/ E  h
function calculatePosition() {, o( b2 v  T8 P+ a" [, C  O+ {
   if (xDir == "right") {9 f: F; G7 i- n) Z/ @5 G
      if (xPos > (xMax - contentWidth - BallSpeed)) {) h0 c! Y% n! X6 z# A2 g+ F
         xDir = "left";
5 u- _! C. ?  i         }% T# f7 F: H, U4 }# z3 {
      }' E# S: r% N/ }  ~
   else if (xDir == "left") {; C8 T4 t& o' l! ^, S% U6 D
      if (xPos < (0 + BallSpeed)) {
" H5 q; s" u/ l& s1 z         xDir = "right";) l; Z- f: O0 y
         }
6 h3 Z7 L9 Y. P1 x/ I0 t4 u, s      }4 O& h- ^: w) g/ @# O5 |% m
   if (yDir == "down") {
+ `! `, Y. J: @! X4 d# C      if (yPos > (yMax - contentHeight - BallSpeed)) {
8 z9 X7 U. _% U- m7 C5 g8 @         yDir = "up";/ _9 U2 q6 @6 w3 g& S0 V
         }
7 l! I! c) Y- y# ~      }
0 o$ s( y4 h8 @$ z9 x0 C* u7 }7 ^   else if (yDir == "up") {
* r  S! d* R! x/ E" f: a8 M% p      if (yPos < (0 + BallSpeed)) {3 s, Q4 }8 E( x8 N6 l
         yDir = "down";
6 g7 o) x* b) d! h  W         }
% `$ S2 z2 W! d6 g1 H( U' E+ M      }0 e" B+ R, S& t! x' U$ Z
   if (xDir == "right") {) @1 D6 y- B8 z  k3 j; l8 X) R
      xPos = xPos + BallSpeed;4 ?# ?& F  r7 R! o1 k
      }
( J7 f) b; q+ b+ c! w- u4 O1 j   else if (xDir == "left") {, S: Y0 r; ^0 h7 M& P
      xPos = xPos - BallSpeed;+ h) L8 A- S* s6 Q* A
      }+ _( G9 M; u/ M. \8 `$ A- B
   else {
  q+ F2 B* u* p' {; m      xPos = xPos;# C! R! |' o: f& g; U2 z
      }
8 `/ O# t0 G( v2 D% x   if (yDir == "down") {
% T5 l# y$ X6 `) V6 M! s      yPos = yPos + BallSpeed;$ Z6 d( A1 z& c5 E+ Q
      }/ Q7 [3 H9 x% c4 A) p
   else if (yDir == "up") {
* K& ^( D% Q# A5 X- V! o      yPos = yPos - BallSpeed;
0 H, j# ?* W, \# G( |      }  V3 k- o1 O) F! e# h% @' Y
   else {
( S  U1 i# A9 e      yPos = yPos;  c5 H' L' Y# `/ J5 K
      }
6 E2 R8 d( C# {! ^( _   }$ b% ~* P& x5 e+ j  k
( }( _' z  p( ~) Q: u4 H
function hidetext(){
9 h% I% V8 d/ s" ^  n( ?% \0 fif (document.all)
$ C) N2 B- b- Q2 \; m& Esupertext.style.visibility="hidden"! _) u$ D" x7 u( ~. W+ J
else if (document.layers)
, h: T2 n% m3 a9 \document.supertext.visibility="hide"7 k4 \) l! ]- m& W3 G. i5 P+ O
clearTimeout(animatetext)" L' R% B4 e; Z4 ]) M7 E( L
}
! |, Y& d, U% }7 \& D
/ k' m0 F, @  r7 o5 Sif (document.all||document.layers){
6 q; f: X6 w. _1 M% K( C2 ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% x2 I; \8 A2 Awindow.onload = initializeBall;
0 x5 H+ B( K2 p3 _, Vwindow.onresize = new Function("window.location.reload()");
$ @" p( A' }) J, D) a}
/ s) l+ g! g" Q1 b6 @  a0 h8 y( |$ {
+ s( y8 e' H" a7 W</script>

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