返回列表 发帖

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

<style type="text/css">3 b/ E* d9 E# Y
#supertext {
$ K* D6 h6 q1 \: @% w- [& G" P: y# Aposition:absolute;
8 x/ N( O. `% \7 q7 Q# G. h/ _/ ~left:0;
6 A9 X& {( v- B3 {8 j7 p. l1 K9 rtop:0;# F5 u) g5 C! }( V; U) Z
visibility:hide;
6 ]& g3 O) W' U7 }1 K/ X% \$ Ovisibility:hidden;  K4 |  v3 n6 R" _
}4 i# P+ J+ q  e" e! x2 _
</style>
6 s& K9 u( W9 U% }" z0 ]<script language="JavaScript1.2">" m4 H( h( L7 }5 S
<!-- 改变下的字体的大小。颜色-->
6 e9 [( W8 D; n$ R( kvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 N3 J1 l6 W: _' h/ G% xvar hidetimer='';
( J0 c' }- A2 E1 I' @<!-- 改变下的弹跳速度-->" S% A9 c- O9 @0 N
var BallSpeed = 20;4 G4 H& b' B1 |1 M# U
var contentWidth;
5 w; s, Y1 _' i4 H/ X' jvar contentHeight;2 o2 k+ c7 t1 u6 f  c, `9 u/ K
var maxBallSpeed = 50;- ?+ h  |: J3 ~: T5 x9 a0 m  w

; b1 \' ~0 J# f: _: D+ y+ R- k$ v: n
var xMax;
6 @" i& `6 a/ v. s3 C( q/ y9 ^& s' }var yMax;+ E+ B9 C& {, n6 k% N8 [
var xPos = 0;2 u- `+ G0 r3 y! N
var yPos = 0;
7 r2 k) g1 f) mvar xDir = 'right';
  r% i3 o7 S6 x! V5 d3 A/ G. lvar yDir = 'down';
0 G- A+ H4 P& i# f/ e6 H1 rvar superballRunning = true;: L* p2 F7 m3 }) r! E
var tempBallSpeed;" ?1 D1 h" x5 V
var currentBallSrc;: R# {  ^2 v- z" k& `
var newXDir;6 t- T* D: S" Y
var newYDir;& ]8 U5 u& }; e3 H$ ]' h: H
  l5 M# J4 G7 u% }! f* {1 ?4 M
function initializeBall() {: X' J% _3 b7 Z# z( `% j* ?9 }
   if (document.all) {' Q7 t8 H3 u+ m1 \) k4 Y; l: C
      xMax = document.body.clientWidth
' i6 E7 L9 ~# f7 f, |      yMax = document.body.clientHeight
. M5 y# K& m9 T& }1 T* q- z      document.all("supertext").style.visibility = "visible";
  T: I3 D0 n* K' B; l- C' G      contentWidth=supertext.offsetWidth
! j+ D/ b7 Y8 d7 g2 K      contentHeight=supertext.offsetHeight" W* o) F; }  U- \
      }( N$ F- r) U% D$ d/ n4 F
   else if (document.layers) {
; P' R  x+ O2 _      xMax = window.innerWidth;
( i1 Q# i! B. ]* y      yMax = window.innerHeight;
+ D8 I$ f( Y0 w; G      contentWidth=document.supertext.document.width
! c* C; }  y8 C$ `2 k9 A      contentHeight=document.supertext.document.height& D" Z/ b& [, M) c$ e  h) c
      document.layers["supertext"].visibility = "show";! U4 ~% F. ^# Y: l+ k
      }
7 o; d7 w' H2 ~5 ~: a   setTimeout('moveBall()',400);
) S3 L& _6 G2 G! [9 w- D: I1 B3 f   if (hidetimer!='')% W. p4 a# c( V- E( ^6 L
   setTimeout("hidetext()",hidetimer)' v/ Q8 d  g; [" ^+ {
   }
) m, A5 r' m3 L/ ~8 x3 [6 A0 r. u0 O2 D" ^6 }) h2 s  J" W4 H7 M& J
function moveBall() {
0 [$ H- v6 ?9 f/ y; K7 Z   if (superballRunning == true) {
9 |+ h. y9 H. S$ T      calculatePosition();$ {5 ]  m  L& T% [0 N) L3 A
      if (document.all) {
. Y; X4 m# E6 W( j         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ t( e, p: E2 d( Y7 y* n+ }
         document.all("supertext").style.top = yPos + document.body.scrollTop;
2 U; p8 S1 p8 c  x+ J# r7 ^: r( e7 k         }* r2 K. o0 w9 c+ a9 R; M
      else if (document.layers) {
: {/ Q, a1 D( G8 D7 J' O/ \6 T/ U" S* d         document.layers["supertext"].left = xPos + pageXOffset;, R5 I/ H) n' l  X& s7 n" {) X; @
         document.layers["supertext"].top = yPos + pageYOffset;7 i4 T1 j3 N' W: x$ }- j7 z3 L
         }
- @0 j1 ^& v. d0 O2 Q, p8 G      animatetext=setTimeout('moveBall()',20);) e' @3 x1 ]: O5 G+ `( N
      }
; K5 M: ^) U* t* p   }  u3 ?; O. E! P" g
# b# s, Z( h% X+ p( |- h' u4 N) a
function calculatePosition() {& T0 O* ]1 s, c% y' Q. e$ y8 m
   if (xDir == "right") {
% Z+ i+ }, W7 T& B" U      if (xPos > (xMax - contentWidth - BallSpeed)) {! S, }7 ^: ^" s3 ]7 a+ O0 V
         xDir = "left";1 y" X5 p3 Q; M2 o4 x/ U
         }+ g# T4 V6 S0 M5 F& [
      }
$ @0 U, o6 X$ P7 p; W8 H   else if (xDir == "left") {
/ }9 e0 K, W0 B0 Q/ B4 b      if (xPos < (0 + BallSpeed)) {+ }5 n7 E2 y" T  T1 ^
         xDir = "right";
' ~9 l4 f; T4 \         }" c0 F! d' B! l
      }9 [3 f4 N" @9 L" R  Z5 \
   if (yDir == "down") {% [* s) d8 i0 j+ p, q/ v9 f; l/ I
      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ H. L+ d7 b) U! |$ R5 u" |         yDir = "up";
1 B  z; u5 j" ~. ]8 `0 p0 Y6 \         }7 n& Q5 ?# Z3 m/ _, V) c
      }) ?* O3 b" J5 w2 \1 Z0 \
   else if (yDir == "up") {4 p4 o: O6 B( b, E1 s
      if (yPos < (0 + BallSpeed)) {
+ T5 M2 @6 ^0 `8 g' ^         yDir = "down";/ w/ d( c, \3 b; d3 M' ~( q- t
         }- i8 i. p5 k; ~7 a' X: ?
      }
7 g3 P1 b& W  U% @% J   if (xDir == "right") {: w7 W* n! p) ^4 z# w6 D
      xPos = xPos + BallSpeed;
! k0 t2 G4 j9 C% h0 B- L2 |! i: y      }, o. w& D( F; G* g$ v* ^
   else if (xDir == "left") {8 L0 n% ~: j" r
      xPos = xPos - BallSpeed;) F) a2 {! t/ n: m5 ]* c
      }3 Q: M4 I/ r. ]/ F1 r$ Q# P2 j
   else {
$ P5 M& u* q* u/ e& ^1 u7 V6 {9 w- M      xPos = xPos;
& T! y) F1 V! H! k1 V5 l  |      }: x/ |" \0 i9 i, F  X
   if (yDir == "down") {* o, a3 P. m$ j- @+ S0 W
      yPos = yPos + BallSpeed;$ w8 L9 y0 d5 a  U" v' _% T
      }
3 s' M  ^* b% a- ^   else if (yDir == "up") {
0 D5 w/ p7 r- \9 j$ k; s- d9 K      yPos = yPos - BallSpeed;: I& Y$ P/ ^7 ]& \# c
      }8 o/ V. y- R# x# ]+ M
   else {/ J4 K) a7 `* _( c4 z1 h8 H8 m9 D
      yPos = yPos;7 S* o; G; I% S6 W7 y/ u9 Z
      }" t/ C, i& t5 u5 y6 ]4 V. |
   }
% P+ A2 J0 I. K% T- i3 E& C' H; [
/ g' Z/ p$ j0 \: Y8 dfunction hidetext(){
* h5 m$ @. S, E8 Nif (document.all)! \- i$ e$ }. X# ~8 _# g7 \8 y# t, _
supertext.style.visibility="hidden"
8 o8 s/ o0 J$ c' qelse if (document.layers). \2 [8 s8 k5 h( Q
document.supertext.visibility="hide"3 y! T! T; s7 @/ j! F3 |. Q
clearTimeout(animatetext)
6 r! {* i7 T) `1 K}" `, b0 j1 ^, i: v0 \* J7 L+ b5 s
) o# F+ Q$ A. }+ v3 Y$ @: e* ~+ }
if (document.all||document.layers){8 |$ h1 P3 R0 h# y1 t8 l; J
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 l" s3 O  q+ \8 K
window.onload = initializeBall;
1 I. o2 h2 v/ J5 D. v4 C6 Y5 dwindow.onresize = new Function("window.location.reload()");
* O# `, u  K3 \: X0 |}5 s- `9 s6 g- {, H$ P0 ?4 |# V9 u5 p
* Y+ I- R' K/ J3 n( u
</script>

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