获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">  Z4 r* |) T. Q) Y5 b- H! H
#supertext {
9 ?9 s2 ?. H, Z% z& A/ R8 _6 Bposition:absolute;* y7 e& ^& d. n9 e6 R
left:0;
; O" l9 _$ V# k9 A0 Stop:0;
+ R7 u  s) U% C( I0 t% L& W9 Evisibility:hide;5 A/ `/ r* h' p; \3 r1 x" `
visibility:hidden;
& g7 v0 m5 Y5 w3 E+ Q}
  w* @: z0 g' h0 [! b' k</style>
; x& ]7 d* X1 T, D<script language="JavaScript1.2">
! i( m* S0 }( J<!-- 改变下的字体的大小。颜色-->
$ s2 A; H4 P' y$ D4 Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# F+ z& ]- B4 evar hidetimer='';
, T5 u' p6 O  `2 u' J' D<!-- 改变下的弹跳速度-->
, l$ ]$ ?! N! J6 |0 b" c& Rvar BallSpeed = 20;
/ a( W4 @3 g0 \' E, b! Lvar contentWidth;/ U7 u9 g& K6 X9 H! h/ H7 }3 |5 e
var contentHeight;
6 w' e0 o7 U3 I1 o5 ovar maxBallSpeed = 50;) T! C" b, E' w" x. O
; v; K! _- W( B3 N
6 s5 g3 n, g. D4 a
var xMax;
' v+ ~2 `$ w/ U7 V8 ovar yMax;
: K+ O. B5 {% t5 T4 a$ hvar xPos = 0;
* u  n4 b3 L- s* O5 S3 wvar yPos = 0;
& t( c, S9 S' g; x1 rvar xDir = 'right';
/ @# c3 W8 I) B6 c( kvar yDir = 'down';
* N/ N# J, D1 k- [. ]var superballRunning = true;
" U3 `6 E, z, n2 f; C; |, U7 rvar tempBallSpeed;7 [3 Y) ^& b0 r
var currentBallSrc;8 f- y- B5 G; g- v$ T8 k% H
var newXDir;
7 {4 B1 i( |6 C" q8 Y, l1 jvar newYDir;3 E2 ^8 O. W% D
2 u, X5 D/ |; Q' a) C6 g
function initializeBall() {: {- a. C% i) N  R6 u: a
   if (document.all) {; ]3 E3 \8 ?! D; e* ?9 u
      xMax = document.body.clientWidth
2 V  X- \- I1 C: ^# ~, |' M      yMax = document.body.clientHeight
( S9 T2 g( ~; i& F7 y      document.all("supertext").style.visibility = "visible";
) J6 C0 `( _- ]! f7 b4 I      contentWidth=supertext.offsetWidth! v( s/ F# H3 d9 r7 L, v$ G- ]
      contentHeight=supertext.offsetHeight# I+ L+ l& k4 @1 f
      }
" L3 W. y( [9 I, s8 }   else if (document.layers) {
/ Y# A9 j+ O$ W: o      xMax = window.innerWidth;& ]2 {+ x4 Z' O+ O8 u
      yMax = window.innerHeight;7 t( s% D& K6 ~6 X: ^
      contentWidth=document.supertext.document.width
* _/ i# T9 T4 t: |5 w7 K      contentHeight=document.supertext.document.height
8 e) R/ b% f4 Q" Y( `4 v4 J      document.layers["supertext"].visibility = "show";/ k) u6 i9 V/ L" J
      }
: q( u, \! R1 s) r0 J1 q   setTimeout('moveBall()',400);5 q6 o+ ~7 G  l, r' Z
   if (hidetimer!=''): X- O5 @4 }- U  A) O$ j2 n
   setTimeout("hidetext()",hidetimer)
4 j9 S- y# A; n7 A7 M4 x) _   }/ L5 O( ]- @6 o4 p2 ?

/ f6 Y9 M" W% C- d8 p! R: |function moveBall() {8 L, M+ r# o) g
   if (superballRunning == true) {0 D; d$ |! |( k% V; E
      calculatePosition();
, ]. E+ r% n* G8 q      if (document.all) {' k1 {- n. N/ |- r
         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 V, N1 {8 a  S, R, E
         document.all("supertext").style.top = yPos + document.body.scrollTop;
& @  s9 o  A2 j7 q+ \, R         }3 Z- N) v) j! h' y2 d1 p6 _' \
      else if (document.layers) {9 A- a+ i4 k' y4 z: D/ [7 P$ Q
         document.layers["supertext"].left = xPos + pageXOffset;
/ s4 r" g" L& C5 s9 W         document.layers["supertext"].top = yPos + pageYOffset;! W1 T  `, `9 f  `
         }
, @2 U8 k" ~- W) f# I3 H* L      animatetext=setTimeout('moveBall()',20);
' R- |" D9 G% \& a1 H' G      }
& b" F% U, J* S/ M. z& d/ X   }- z) b' F9 R- F$ {

, t& h9 z& I7 W4 ?9 Z) Z9 N9 B. dfunction calculatePosition() {: r/ m. ?0 i) [7 |) ~* S; n: @
   if (xDir == "right") {
9 c& X9 k6 N4 K$ ?- G/ Y& D      if (xPos > (xMax - contentWidth - BallSpeed)) {" ^+ T: o2 ]/ D: j( S( Z8 B
         xDir = "left";
, @8 d+ k* B) h3 m! _. _) K         }  ?. s( S( ]* Q: V2 w, h9 H, c
      }
5 K; N, {# r. s4 G, ~   else if (xDir == "left") {# b* w8 V  U: q6 N
      if (xPos < (0 + BallSpeed)) {
  S  y6 T! r. w) \9 v9 W3 V, I         xDir = "right";2 K6 |1 Y, {+ D$ A5 u
         }
0 _' P2 F" H6 a) D      }
  x6 u9 g8 V8 @; f1 ~7 K! H   if (yDir == "down") {+ W* ?9 A5 B) Q0 n$ {
      if (yPos > (yMax - contentHeight - BallSpeed)) {
% d7 Z5 I$ _/ ]/ j5 J         yDir = "up";
4 i4 X2 [' u; Y: l         }
5 K8 a+ q0 o% L. w) R      }" t2 o1 V2 E) d. Y+ l7 P; l! L
   else if (yDir == "up") {
: ?6 v+ Z6 N& n5 G      if (yPos < (0 + BallSpeed)) {
) P8 b% ~; m; D4 K         yDir = "down";+ B# q$ A+ [6 q. r
         }
  [# e% X" [2 k6 m) I      }. k* m  {; g/ Z( j$ F5 S
   if (xDir == "right") {
/ J6 ~9 U1 Y3 ^0 a      xPos = xPos + BallSpeed;9 l2 P) V5 S4 E4 i
      }
4 O3 r' X$ w- S8 D  G) ]+ ~   else if (xDir == "left") {0 E8 d; o% ^1 M: T# [
      xPos = xPos - BallSpeed;  z% j6 _5 l3 V% B, H. L8 ?
      }
: n6 Z0 c5 ]" ^: D8 Q* l   else {
* R8 d* v% j( ~, v' X2 Z$ ~9 Y      xPos = xPos;
/ y! L4 c; i, I' @% k) I      }
/ ?5 d- h. b4 f% N2 V3 q* @   if (yDir == "down") {
& w: O) Z! y( v      yPos = yPos + BallSpeed;& Z  e/ v  p) Q1 m9 Z8 z
      }
( h6 a$ L# K* ?; `! T& ]7 y4 M   else if (yDir == "up") {
. O, W, L8 K2 r& a7 u  R, @  M; I! J      yPos = yPos - BallSpeed;
6 C: z7 I0 w  @+ G* g  K      }( z  O4 I2 w; L' }& a
   else {1 v  S7 G! S$ J. Z3 H$ H, e! h
      yPos = yPos;4 D) q1 Z! N; h; b
      }
# _# a2 q, m* }' j9 v   }4 k6 j* L* T! N

  j% e$ C+ N0 p: k/ |function hidetext(){( W* ~5 x4 i& J+ O4 z) @* n- T1 B, o
if (document.all)
# n) p! \+ k4 I. isupertext.style.visibility="hidden": \/ |8 I: W$ d6 i& y
else if (document.layers)+ k7 V6 q7 y- w+ @: m
document.supertext.visibility="hide": ~/ S" J# h' a9 N1 b& G
clearTimeout(animatetext)
7 Y; q. J9 |" }3 ]8 {) r! y& I}. I( T- v& |" _1 m+ S

: s) _( a1 g/ ^) jif (document.all||document.layers){( W& R: u6 {8 W* N7 Q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ X$ Y% F& n' A" {# V$ {; [' \window.onload = initializeBall;
3 V% y+ G8 U& L3 {, _( R' cwindow.onresize = new Function("window.location.reload()");
/ g9 L- |3 X0 |; ^9 G}
6 D/ K$ {: i9 }2 F8 ^. d0 t
1 O  b+ A( \( I0 N; n1 K) y</script>

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