返回列表 发帖

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

<style type="text/css">' D) Y$ j0 `+ r. P
#supertext {! N( B0 N+ Q5 k: `8 k2 U3 L" Y1 p
position:absolute;
: Y9 Y% ~' E% h$ P& q9 Lleft:0;
) M. D* c, a$ D) i. Z8 Ytop:0;) @) q4 I# V6 X4 a
visibility:hide;
% r) E' R6 y" R) o: B, s- h( Zvisibility:hidden;  s* q5 Z8 W7 ?8 `2 n) X( L  M( j
}0 s0 w, {  }: K. Q7 S7 `
</style>4 q( v5 r1 T( A7 `' x& [/ X
<script language="JavaScript1.2">
, i" j9 H+ u0 y* G- D& B, v, y! O<!-- 改变下的字体的大小。颜色-->! \/ v( d, S, M' P! B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 H: D6 z- s: E2 G) v0 dvar hidetimer='';
, o' G$ L! P: y<!-- 改变下的弹跳速度-->2 C+ g& U1 f0 U- ^7 n3 f  i  h
var BallSpeed = 20;
! n. p" p% a+ Evar contentWidth;. B* c" J3 J* b3 R# H+ D, s
var contentHeight;
! U# W4 ^6 l0 {( F! `6 v& @; `var maxBallSpeed = 50;+ s5 [8 Q5 w4 K

0 o4 ?  `+ Q3 \7 s3 I) [7 P6 B2 y
var xMax;
) R& M! F( R2 q. k1 f# G+ L2 d6 rvar yMax;  Y0 h/ a% t$ i5 Q1 s/ x& o
var xPos = 0;% h+ Y/ Y2 \' v1 h
var yPos = 0;6 O+ t0 |$ h# @5 J
var xDir = 'right';
# d; O0 w& k/ T: h0 v3 d4 Z; Cvar yDir = 'down';  A# C9 ~7 H  h; z
var superballRunning = true;) C' x$ k  u- C6 v9 p; ?
var tempBallSpeed;
0 T5 Z: l9 v/ z" G* yvar currentBallSrc;
& x8 c9 i  b5 p5 Uvar newXDir;
% q  [5 J& d, r; Mvar newYDir;
/ P$ T" u% s, X' S# h; w9 s- p6 F/ f$ `( b
function initializeBall() {
& F! g4 I7 w" ?2 m5 `' F+ b" s   if (document.all) {9 x! `- j6 w. K2 Z
      xMax = document.body.clientWidth
7 k" U9 q# I& ^8 e& B" W# w: e      yMax = document.body.clientHeight/ [+ Y- d2 K. ?$ }8 V
      document.all("supertext").style.visibility = "visible";6 _; v* e( y9 M
      contentWidth=supertext.offsetWidth( |' t( V8 X# S
      contentHeight=supertext.offsetHeight0 E$ j7 ?. g, \  J0 E! Y; y
      }
  u- G( E3 X: s  O) c" W, L   else if (document.layers) {" X* m' B' r" d& Q  p0 g
      xMax = window.innerWidth;+ L  U9 ]; b9 A9 f: u8 }
      yMax = window.innerHeight;' l% L: a5 L( {5 H% ?' Y. H
      contentWidth=document.supertext.document.width" H( x- s3 u+ L8 X( A3 n
      contentHeight=document.supertext.document.height
8 W! j, _" y/ _      document.layers["supertext"].visibility = "show";
6 x- b  @3 v3 `% d# x4 y* M      }
4 k, B) N4 y' T4 {! s   setTimeout('moveBall()',400);, l( l8 x4 ^. `3 K
   if (hidetimer!='')& s' h* }1 o: F9 C, D6 D. U! {
   setTimeout("hidetext()",hidetimer)
+ q5 Q4 |; m7 g1 p% }   }
2 K3 X4 l& m& x$ ]7 m; V9 ~' {. P0 M, R0 h1 }$ j
function moveBall() {0 V6 ]2 L' u& F1 J' l# F/ t
   if (superballRunning == true) {- F" X# Q( Y! l! |* e# ~  i% a' u
      calculatePosition();+ R! [) n$ S/ s; ~. v- D/ e
      if (document.all) {" x2 e5 o0 Y* j/ j8 H6 w+ D! F
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" d: a' Y2 V$ C7 v. {* i6 d% t         document.all("supertext").style.top = yPos + document.body.scrollTop;7 n& R" j" R) X0 H) J1 |& e# C/ P
         }
* u. X6 q8 o# m! j4 {$ R# _$ \* K3 n      else if (document.layers) {9 k' r; A5 j% M+ X4 m
         document.layers["supertext"].left = xPos + pageXOffset;
+ y6 A7 K/ s& e- L) U* F5 t         document.layers["supertext"].top = yPos + pageYOffset;$ g9 T  {! j1 U  T. i" k
         }5 I% E1 \2 ^$ g
      animatetext=setTimeout('moveBall()',20);
' K; F0 U* m1 ~- I! B      }7 g# M) U7 A$ i
   }
1 O. ]% V; `5 I. {
0 w# ^, c8 r  k, P9 a. K4 [function calculatePosition() {
0 _2 Y0 B$ _7 @2 d  a( R  Z   if (xDir == "right") {2 ?$ @) w% @1 V) y
      if (xPos > (xMax - contentWidth - BallSpeed)) {1 I8 `3 n4 K2 ^( c' N+ o/ A
         xDir = "left";9 v  w+ m' Y1 v. ^; V
         }& p' [# i2 C& l; P
      }
$ @. }" z5 z, M) n: R- ]   else if (xDir == "left") {
0 \" e+ n0 a' ^( k. a      if (xPos < (0 + BallSpeed)) {2 j% u( _' T3 b3 X% M5 n5 j
         xDir = "right";
; E9 O7 s+ d- h( s) V' m) q' C* {         }
2 b. r9 }3 A+ `3 _" x/ @: J      }
" S( ?7 ?; G5 T$ l3 e- W4 j. {# E   if (yDir == "down") {) X1 u) c. A5 Y, @
      if (yPos > (yMax - contentHeight - BallSpeed)) {
! Q- |3 q. _/ |) z% M3 l) a         yDir = "up";8 D5 v6 O2 b. h8 E  |3 O
         }6 Y# j6 {; a9 C
      }
; g  t2 f) M- \  y  e! ^   else if (yDir == "up") {
  Z7 ^! @! O% Y, p      if (yPos < (0 + BallSpeed)) {
6 G2 n. A/ q' m7 b         yDir = "down";
( e7 W9 T3 v, ~2 p" t! t, ^         }
, V5 f* r& X) q" }      }
) f4 V, o. m5 j, k6 U   if (xDir == "right") {
! Y# u# Z9 d" v      xPos = xPos + BallSpeed;
# |; K) h2 S* {1 {7 x  ^/ u      }
0 p- N! h: r$ Z: W. g0 j2 D/ M; O; u   else if (xDir == "left") {) o2 ]5 S5 b- e  d  X0 n
      xPos = xPos - BallSpeed;
5 P: ^1 d% b! z5 R+ u) {. j  e; F& Q      }+ x- r. F+ b* y7 N
   else {
+ R6 H& |( u% |' x+ X: w      xPos = xPos;9 e, _  J+ W1 W; w! z
      }+ L3 {, H" s1 T# l* z( v
   if (yDir == "down") {
' R0 c$ W* G+ ~) v      yPos = yPos + BallSpeed;
! v2 n% @; w1 u  \* t% Z      }
: G+ H( F4 C' B$ F   else if (yDir == "up") {0 o1 l$ H7 C. L
      yPos = yPos - BallSpeed;$ I+ G  [5 ~# C. ~5 V/ N
      }2 I; u* w' G1 M# n4 Y+ c7 Z
   else {
. v9 I* f/ I  s) I3 u9 N$ L      yPos = yPos;
' A' a( c9 W$ b- |      }! g6 x" O2 r; V7 n/ `. M
   }
" x' g0 c  \% Q% W' w" D. Z# Q; K% k+ M1 ~& x" S
function hidetext(){) z7 R  c' ~/ T- l
if (document.all)( i3 p) |) o6 _* W, t7 |
supertext.style.visibility="hidden"$ D# U$ L# n; z
else if (document.layers)
  W( s4 p" |. m& vdocument.supertext.visibility="hide"
# O% S: F6 T8 ?7 u" \" @clearTimeout(animatetext)
& M8 o" V1 l3 A2 t9 x}
4 r5 |* O* j' h* N* X
3 w/ V" [' Q* e( j( yif (document.all||document.layers){
4 d1 v( c; K+ idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 h0 \$ _. c* F$ G* t
window.onload = initializeBall;
9 q$ f( q! i# f; Awindow.onresize = new Function("window.location.reload()");: k1 L5 L  @  l2 v; S' L# ~5 t3 h1 Q
}
) G# i7 o' b  I0 @% K. f8 N7 d1 s* T
4 R! L  Y7 j/ l5 s& o- v</script>

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