返回列表 发帖

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

<style type="text/css">
, A- W7 h4 V( @% k, c- t; F#supertext {
& C& g0 M9 i5 h- _; h: q* G( i8 P4 i$ pposition:absolute;6 d% [) s* d- Q$ ]  M7 P5 K
left:0;2 a6 r, Y3 f" S  K& m: q! t  _
top:0;& e# R9 m( T( J. O, `3 F
visibility:hide;
+ @; N) P7 @8 Evisibility:hidden;  c! I* h  g$ |& Y8 n- y. T
}
. ]) d$ U2 ~# g0 Q  p4 b- {</style>% _/ Y* R2 {: D- D* m* }
<script language="JavaScript1.2">& l6 V8 y# C4 D
<!-- 改变下的字体的大小。颜色-->
' T. s* }: \0 _) A. t( `* o+ Mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 Z/ q8 o/ M4 z( ~. T( _var hidetimer='';/ f5 N% r& `- R+ K4 S
<!-- 改变下的弹跳速度-->+ W1 B) f% j8 {& r
var BallSpeed = 20;
" y& h- J4 W' ~5 f8 }8 X0 I9 m( bvar contentWidth;* ?0 Q0 L% p7 R% Z) s; C0 s* d
var contentHeight;
9 W& m  B- y  E. ^$ b5 H# }1 gvar maxBallSpeed = 50;0 B) x% v' Z% h6 D" G$ ]
6 F. W  Y# e+ v* q  e: [# l' n
% H) \: G: X3 g' c9 [. I0 q
var xMax;( v& Y( e& Y' y7 u7 B  f6 C
var yMax;
6 B; h( C- @8 V  z) Q* f, w- pvar xPos = 0;
6 B$ X( u  s: a0 W% a% g1 V  nvar yPos = 0;0 l4 H9 s( D! C. D* q
var xDir = 'right';3 b3 b$ h7 o" b- u, ^& R* J
var yDir = 'down';
* P: @: y: l$ P% @+ hvar superballRunning = true;% Z/ ~8 |  I. j' _% [- G# Q+ {& w( o
var tempBallSpeed;0 a: C( H1 ?3 ~, B( w
var currentBallSrc;$ H0 D8 T/ {/ E) G6 U9 ]8 T& S$ A' G
var newXDir;, t/ ~3 [' \+ ~9 g0 g0 k2 g# W
var newYDir;7 [1 t$ C& R8 I0 x3 K6 j2 ?
) D. E! z: o8 v( B
function initializeBall() {6 p9 o8 D: k6 q% F. P! j3 n4 i
   if (document.all) {$ H' y( k9 c0 X( o: ]- N
      xMax = document.body.clientWidth
0 O- z8 |% ^, j: z7 f      yMax = document.body.clientHeight6 V+ F7 P- h: N( ?
      document.all("supertext").style.visibility = "visible";% q. R- M; q9 B2 p8 r7 r
      contentWidth=supertext.offsetWidth8 P* W) U. ]; h' K* }
      contentHeight=supertext.offsetHeight/ b! _7 k! p, A+ k+ R) c
      }3 O3 K& W$ q) J+ M9 h
   else if (document.layers) {2 s  S* a  G: f# [/ T
      xMax = window.innerWidth;
- }0 g/ _( f: x, c/ A      yMax = window.innerHeight;* s9 j5 k6 b# }" e0 q0 m
      contentWidth=document.supertext.document.width2 C" ?, L$ ?0 o/ x
      contentHeight=document.supertext.document.height
8 \- i9 I' }# ]  W; V$ c      document.layers["supertext"].visibility = "show";
. U. x( `2 {3 A      }: N1 _% s9 \6 ^1 ]! V/ Q* t! S
   setTimeout('moveBall()',400);- W8 j) V0 U& [  B9 o1 [" u
   if (hidetimer!='')6 [1 H: V7 b1 ~9 W, S: k: g- V
   setTimeout("hidetext()",hidetimer)
: |# Y# ~, q% E! _% D* H) j" g   }# P# T5 P. D5 I

+ l/ R: b, A1 H5 M9 Vfunction moveBall() {( L8 y# j9 g: L2 z8 I  v9 a
   if (superballRunning == true) {( ~9 {1 A/ _, a! s/ C( q' s/ o
      calculatePosition();
' k4 i' u( {& _' F0 N9 l) e6 U0 h; _* ]      if (document.all) {
) Y0 a" y3 y2 c) ]; L$ w0 ^         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" W! w/ T4 F" T         document.all("supertext").style.top = yPos + document.body.scrollTop;5 R( E9 G5 |! N
         }
# W1 W& Y1 d  {$ L( M& g: M      else if (document.layers) {' w3 r& a1 B! j) \3 D5 F
         document.layers["supertext"].left = xPos + pageXOffset;6 A5 d. C1 v: l
         document.layers["supertext"].top = yPos + pageYOffset;
) J8 y0 E- O/ K% A4 Q/ J4 s         }
3 Y) @3 x# ?9 y% n; r6 P' Y      animatetext=setTimeout('moveBall()',20);* e; A: v' q( \  C( ~, s
      }+ H+ [; f# l9 a! h6 R
   }5 K8 q2 Y) X7 W! {

( u1 o$ }/ X* ]function calculatePosition() {
0 X/ F8 y9 u; ^: u) m   if (xDir == "right") {( F6 s( {; x- T2 x) H
      if (xPos > (xMax - contentWidth - BallSpeed)) {0 Y! x3 q/ H3 r1 u. ^) C4 m6 ^
         xDir = "left";% Y& J9 u: |. O* h2 t5 ]/ H
         }* E9 k' o* @7 r6 ?0 z
      }
  i. M& O* G* o( E- L9 E   else if (xDir == "left") {: L( ~% ]  C9 r# L
      if (xPos < (0 + BallSpeed)) {6 Q# Z' W6 s3 J% ]( z/ D$ _: Q6 B" A
         xDir = "right";
0 ?% h" U& p* a9 }( e! j7 c" M         }4 e$ p% ]7 a/ v
      }
# j6 Q8 H3 t8 R   if (yDir == "down") {$ b! `$ `1 K/ N- b% u4 `) C
      if (yPos > (yMax - contentHeight - BallSpeed)) {. R' ]/ w, }* e! N4 r( A
         yDir = "up";
0 ^; r- B1 M' B: K) V! Q" @, R         }
. v$ k* a2 ?, e8 L      }
  T- e/ Y+ F9 B: P8 o: e+ y   else if (yDir == "up") {/ l/ X" E) D% `! V
      if (yPos < (0 + BallSpeed)) {; l$ ^7 _) {0 W' l7 d
         yDir = "down";
; H# q2 s- m) \2 z$ n8 y" J; B         }
, k  t+ y: m1 N4 r# U7 l      }  s6 |. @; i9 u  Y
   if (xDir == "right") {
; K4 y( ~# Q8 X7 b+ ?  N      xPos = xPos + BallSpeed;
$ z6 \9 y+ J& m- |2 N0 G      }
* D4 ~. k& i. W* @8 v+ Y+ a   else if (xDir == "left") {8 P9 O- s5 ~. [9 I2 L5 K
      xPos = xPos - BallSpeed;7 @- F) ?0 T: P% b6 K
      }
0 c, I+ i' S2 t+ W$ X$ e( i   else {* U; K! h9 w$ m0 X' r
      xPos = xPos;- @' S0 s( _, x3 f  ~
      }
* z; C! v( j  I' R   if (yDir == "down") {
) J9 D# _/ l+ H      yPos = yPos + BallSpeed;( g+ i8 K- \4 W) D$ h% t; S
      }4 G' \5 W) ~3 V* e8 c
   else if (yDir == "up") {6 E+ i! ^9 m4 B& u
      yPos = yPos - BallSpeed;2 S/ C# F2 g( H
      }
# F3 w* \% |, M  O$ T   else {
9 h% z' M# w1 [: U/ Z! T- N: T  W      yPos = yPos;' M* g: b5 I1 q7 F2 ?
      }
0 f0 ^% G6 O7 |" }" X   }; R$ C; @6 U3 S

0 Y6 S) N# \" ], T; `function hidetext(){
+ d/ K0 ~8 Y: }if (document.all)* `8 A/ t) O4 L  I
supertext.style.visibility="hidden"
+ |8 {1 E: X1 [2 telse if (document.layers)
0 P" R& u0 b/ t1 v" ~document.supertext.visibility="hide", U4 L1 X$ O/ W
clearTimeout(animatetext)7 C, M' ^. I% {) i8 }
}
* b) I* u" D  J1 ^" j" w5 X  o5 [4 |8 z7 ]3 |: ~& o
if (document.all||document.layers){
. M2 Q1 P# N0 m' d1 p. jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% c% X1 {- k' w$ u
window.onload = initializeBall;
  Q$ t2 `6 Y$ bwindow.onresize = new Function("window.location.reload()");7 E! C" R6 m: l- Z- O
}. O( {+ s1 l2 w  ]
0 b# T4 `2 e0 g+ h# r/ a
</script>

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