返回列表 发帖

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

<style type="text/css">6 O% A' Z4 p7 y6 s
#supertext {
, ]2 L$ e/ O  X+ qposition:absolute;2 [# |1 G. U0 E" s; o. G$ k
left:0;
& E# x/ r5 W7 U) f- Wtop:0;$ k% N0 u8 L2 g7 Y$ R4 k
visibility:hide;
; i3 J4 b* p8 l$ Pvisibility:hidden;
4 J4 P% ^& P" d. t7 q6 V+ }}
2 I7 q3 Y: G# A</style>
1 S1 M6 V* {" U7 V6 n; i<script language="JavaScript1.2">7 w" I& _' t" q- C! V7 H3 D
<!-- 改变下的字体的大小。颜色-->4 B4 i8 i6 x, p, E) f6 ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# j$ j4 ^+ ]+ V) H! F2 F% e
var hidetimer='';- E2 d# a6 U3 `, X2 V
<!-- 改变下的弹跳速度-->3 b" E" o% G  Y9 J1 ?# u5 i
var BallSpeed = 20;
# U& w$ q3 l- I1 m9 c8 g9 s7 rvar contentWidth;2 u( r+ x, B3 \, Y
var contentHeight;( e( T* P) q; p" c) Z) C
var maxBallSpeed = 50;7 \7 s. U0 E! k. e1 I& M& e' m

; A; b2 M9 i; B3 I  n# _9 |2 i* M5 k7 B. N" I* W3 M& A
var xMax;
' _4 E* g5 t. L; [: i$ D' Mvar yMax;4 D2 I/ U$ s1 n1 u
var xPos = 0;
- Z5 K  g9 k# _var yPos = 0;! W- l/ d# o) K1 d5 c  n5 e% f, D
var xDir = 'right';% L: }1 U8 y' M3 ^$ O$ c) P
var yDir = 'down';
1 ^5 f+ H, i/ A3 D6 Ovar superballRunning = true;
+ y) {$ `, s$ V  W* Svar tempBallSpeed;
; |/ @0 }1 ~# Pvar currentBallSrc;
8 t4 T$ A$ t+ j, Y; xvar newXDir;
% J- e8 w! N. B4 M' f. N# uvar newYDir;$ M" |+ S( p/ @' E7 ~! c8 Y  @

6 ~8 E6 a& z8 I+ {function initializeBall() {
  P9 ^. n1 @/ V& }3 o& j   if (document.all) {# e" x5 }& P/ m" {- d" F3 j, \, r
      xMax = document.body.clientWidth
9 ]2 L2 {6 K) `1 }$ k      yMax = document.body.clientHeight
% b) ?# w/ d+ h( v& f( }" o6 E; Z      document.all("supertext").style.visibility = "visible";& m5 Q3 L5 a; J& M
      contentWidth=supertext.offsetWidth7 V9 ^* @2 S) v9 }- [& M$ T: J2 b/ Q
      contentHeight=supertext.offsetHeight& J4 n/ Y& Y! H& s6 n9 l
      }
# F2 f% |$ j& Y4 g/ K   else if (document.layers) {  c8 A- t9 Q6 j
      xMax = window.innerWidth;
" l5 p$ q5 R: ~4 F      yMax = window.innerHeight;
5 Y: L4 c* S9 s3 n( _      contentWidth=document.supertext.document.width# ~. b+ Z$ c% ~8 P1 `: o
      contentHeight=document.supertext.document.height& X/ Q7 o: n: e' I8 u2 l
      document.layers["supertext"].visibility = "show";
9 D/ S- k+ X( h8 W. E      }
, Z+ b$ @* K: W, N& f0 h! d   setTimeout('moveBall()',400);
% D$ p* u8 J5 Z! m   if (hidetimer!='')
% C+ D' W6 D! l9 r2 `3 c* r   setTimeout("hidetext()",hidetimer)
7 W& o& Q3 _9 \6 v6 o9 o   }
* K  k' l& Y8 B1 b0 ]
5 @; a% _; R, r) ^, Wfunction moveBall() {; t1 A2 o& [; q. s2 Q. K
   if (superballRunning == true) {6 E. ?2 g: T/ C. W  f
      calculatePosition();
/ z. u, z7 C6 a" W6 p      if (document.all) {; d; }4 o# ]- N4 j% E* _
         document.all("supertext").style.left = xPos + document.body.scrollLeft;1 j, d  y$ s) w7 \8 Q$ A( `
         document.all("supertext").style.top = yPos + document.body.scrollTop;; p( ]0 |( v6 q+ S: R
         }
. J! V; ~4 M  [, z2 t      else if (document.layers) {# G2 N! q$ d$ m+ g  g8 G
         document.layers["supertext"].left = xPos + pageXOffset;
# d2 L- ~+ J# G, T         document.layers["supertext"].top = yPos + pageYOffset;
. ~9 n  F& g/ G9 Z# l+ @: b         }
: i# i5 f, I1 G/ j      animatetext=setTimeout('moveBall()',20);
3 l8 W7 f. m/ ?1 s1 X      }
$ b# S$ E+ Z+ A' J9 V* B   }
. ], r5 ^" @- i" Z0 B2 [. p& a/ v4 t) [1 W! U
function calculatePosition() {. o- L' W! M3 O0 N3 ]% ?2 i0 u
   if (xDir == "right") {* f5 X* I( ?" s% ]: ^  E
      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 C. t" |9 o$ R         xDir = "left";% F  L4 }; d, P* q4 Z
         }
( @; L! _- _0 x+ z- j0 [! ^      }
7 p  c+ B4 K# w2 ?( d8 U   else if (xDir == "left") {
; n$ N) G  H( e. e) N      if (xPos < (0 + BallSpeed)) {
/ ?& R1 i3 \; o         xDir = "right";4 T; x+ G1 x4 T# w( T
         }7 d- z5 ^3 b5 M
      }3 h$ Y- _& Y4 \' K: u
   if (yDir == "down") {
" @, F, L/ q, B9 C- L) |      if (yPos > (yMax - contentHeight - BallSpeed)) {
. K# \6 q8 b4 l; w3 ]8 ?, z& c& ?5 y; e         yDir = "up";7 M" K6 L2 U% K
         }: e: t, g6 h+ x% {, @
      }' [# k; d; U" L* x
   else if (yDir == "up") {( w/ v3 Y. x! E& C2 {
      if (yPos < (0 + BallSpeed)) {$ W, ]' L/ W: I+ @, A, C
         yDir = "down";* C; z- Q  W# ^8 ~4 g  _
         }1 M/ p; P" b% B$ {( O0 _/ L1 L9 u
      }) H9 P- `& C3 b( U4 k3 ?$ ^1 e
   if (xDir == "right") {
$ d- [& m* E0 E4 r; b# B: c      xPos = xPos + BallSpeed;7 H; B; B4 Y* d& n
      }) a+ e+ H7 @" A" G- d, R. J/ G6 u
   else if (xDir == "left") {* u5 J5 p. x/ a3 Q
      xPos = xPos - BallSpeed;
/ S5 [; x' |- w: J, P/ c0 D      }
9 p+ h- f( z0 W' y   else {6 S* ]0 {% S& g) E; A( T+ n; ?. ?
      xPos = xPos;
. |, e8 a  v& M& g' a      }( R. r# R( v1 N/ [& T5 @
   if (yDir == "down") {
1 O  j6 J4 k+ z% v4 J" A      yPos = yPos + BallSpeed;6 o: i7 k' W8 k& ?+ \7 ?* V1 S
      }8 J9 c$ Y3 ?) q: f- h
   else if (yDir == "up") {8 X: ~' o* |$ E! n+ J0 a' g
      yPos = yPos - BallSpeed;6 V' t" V* z/ ~: c% N
      }2 A! h2 q+ }, [6 }
   else {* e5 V' o7 x( R; m) C  G. r" M
      yPos = yPos;
" W  Z) j; F4 ^4 v  k( k      }/ z3 s& K- c, o# O; O" d! _
   }- l4 T1 A0 m6 q( T

) B/ n' R! z# l& q1 G! E6 hfunction hidetext(){
# a' y' C" }' Iif (document.all)
: {: L  K: S6 _supertext.style.visibility="hidden"
* t, N: Y* n0 A4 v( A: belse if (document.layers)% M6 F) T$ O: w( N- T  r
document.supertext.visibility="hide"
: A) J6 D4 j+ E7 n9 b  j9 m: q, RclearTimeout(animatetext)
9 W6 _; k8 G5 }8 y}
* A9 `) P$ ]6 u2 m8 m
: E4 l1 V: [& X4 g, ]# W& x. Y0 o! Iif (document.all||document.layers){. s( I0 r2 c% N: D5 P
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 j, m  y& W+ w( N* H( V% E- @! w  ]
window.onload = initializeBall;
1 Y0 f" l; S5 Rwindow.onresize = new Function("window.location.reload()");
9 M& T: B( `+ e% U3 h( ?5 t}
* w0 g/ A0 d7 m' [# U( F, x; L* I) N
</script>

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