返回列表 发帖

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

<style type="text/css">
" G7 P3 C/ B# u( w0 h* w#supertext {
7 B4 {# C  I; e2 Oposition:absolute;$ a7 a7 o+ e8 Y% e( L
left:0;
  M5 T( D& I( U5 x' w! N& M  O5 ptop:0;
6 ]! l) W' r! i* ?visibility:hide;, \: d' o- v+ y8 t+ m+ |( ]
visibility:hidden;
$ ?; r6 O1 o( q3 D2 F/ a. G) n}: v- x7 c4 m) \, f! P
</style>
% |2 u( i+ P& f1 d<script language="JavaScript1.2">
% R' s- a; r6 o/ w2 h# g. [" f<!-- 改变下的字体的大小。颜色-->
' A" g! U$ B5 }7 V$ xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': a$ E% P+ J* z  q, s
var hidetimer='';; |3 E1 [; E5 ]) `/ B: y
<!-- 改变下的弹跳速度-->! P. E' }: }; ]5 R
var BallSpeed = 20;* P0 `6 Q  p7 o5 s7 G, r
var contentWidth;
5 q9 t" o( i1 j8 K2 pvar contentHeight;
8 L. t6 I( ]4 svar maxBallSpeed = 50;& C, B5 o& C* }0 A1 V8 C0 _; {
. J8 Q- X1 S9 e5 P9 T6 w3 b

3 {4 b0 T* _$ o$ lvar xMax;
7 h% [2 _! X( B- a% j! D- Svar yMax;4 U! z7 }+ A' d+ W% p4 K
var xPos = 0;! M5 g$ m7 a5 U  ~) o7 ]' B
var yPos = 0;( N" J# a. E- T) C7 L
var xDir = 'right';
) k8 t9 T6 J3 P/ K1 r' |/ ovar yDir = 'down';
$ h+ _# I" z! x9 T& ]# i  `3 Jvar superballRunning = true;
% L) J3 G. V1 J9 qvar tempBallSpeed;
& U& s) c* s/ X8 nvar currentBallSrc;
# J. I/ Z* y$ N* Q3 H3 T4 nvar newXDir;8 j& [. G+ E" B8 `" b+ S( L
var newYDir;
: I0 N6 p9 C+ @0 D$ [& ~; W' L* H4 w$ c0 G" O9 A
function initializeBall() {. C* r: `* ?  G* J" `  A4 S
   if (document.all) {
9 T. l  n4 m1 b, J- F9 v      xMax = document.body.clientWidth8 l6 i- T# O8 }8 i; \0 V% S
      yMax = document.body.clientHeight
: Q- ~* C1 s* W2 o+ ]      document.all("supertext").style.visibility = "visible";+ b2 ~6 A! H- o4 M- d* @. w
      contentWidth=supertext.offsetWidth
: V# V4 o* E/ u" K      contentHeight=supertext.offsetHeight
. |, X0 X; P8 [8 T+ i$ V! b      }, j6 [' U% I$ ?( }
   else if (document.layers) {3 W! N2 i% W( M+ Z
      xMax = window.innerWidth;
' Z+ _8 d% j3 ?8 ?+ i- p0 g      yMax = window.innerHeight;) V/ H: T' q3 U1 Q# T# P: k  O% c
      contentWidth=document.supertext.document.width/ [! v" x. T4 G, {0 B* f% {0 v4 P
      contentHeight=document.supertext.document.height
: p( B& {# t7 E7 ], Q7 k      document.layers["supertext"].visibility = "show";
6 j3 I9 E! I5 C, j      }+ A+ j2 C0 g+ e+ Y7 Z
   setTimeout('moveBall()',400);9 i$ L" g+ t0 U9 n0 ^
   if (hidetimer!='')+ z' x. Z( ]8 E
   setTimeout("hidetext()",hidetimer)2 K5 a8 X: s% V" A! F+ V7 O
   }
1 d+ E3 k8 ]$ V9 p( y8 Z" Y; s8 l8 |, e: P
function moveBall() {/ c2 k4 v8 c) X- z
   if (superballRunning == true) {
- I- A% h5 Q5 }: l$ ~  M! q1 d) K5 e      calculatePosition();: _+ W( }. i4 `0 F. u- a% b
      if (document.all) {% e8 c* o3 c. R  w# [
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  w% k, S) x' F- V  @0 k  a         document.all("supertext").style.top = yPos + document.body.scrollTop;
2 h. \" j0 Z3 V9 N         }: R* C3 k4 W  k! E  ]
      else if (document.layers) {- u+ r/ I- p; R/ e
         document.layers["supertext"].left = xPos + pageXOffset;
: F* j$ ^( f9 W. q$ k* Q2 W8 Z! R         document.layers["supertext"].top = yPos + pageYOffset;
5 ^, ~/ @( c7 k: v! }+ h2 |" }% d         }. W5 w2 J  n& {) Q* e6 x' n
      animatetext=setTimeout('moveBall()',20);
( Q/ g+ X3 V# m) E# q' M( z( U      }
' Y2 q) c* H7 I: Q/ \. \   }
# A* N: `! M& U5 `8 t/ }) v* o! M' y' b" `" N
function calculatePosition() {- j  ?6 Q6 P& m1 y  b, k
   if (xDir == "right") {" ~: |0 N: r8 r
      if (xPos > (xMax - contentWidth - BallSpeed)) {$ t% A( F6 B& D, R/ l- n$ _5 G
         xDir = "left";
$ F9 n6 J: R4 Q+ ~3 V         }" P' m/ n5 l- n" }$ L8 Y
      }$ i! A& w, C% {8 T
   else if (xDir == "left") {
' \4 K! h: J- A9 o/ I. [      if (xPos < (0 + BallSpeed)) {
0 r) L% N8 L5 G  v7 _         xDir = "right";
2 D4 o( m4 H) Z) J         }
4 C: M- ]3 S& E  P: }; C      }
* k$ a% O! k# _   if (yDir == "down") {  l: J6 w3 A) |' L# C
      if (yPos > (yMax - contentHeight - BallSpeed)) {& U9 Q4 x9 r  N" f* m
         yDir = "up";
8 f0 c7 L) f4 h: J# W) R  C         }
* d7 M  L/ M: Z5 v& z1 |# ^      }
0 d8 R5 X! G5 J2 o, c) G# M  B   else if (yDir == "up") {
  l1 T. S# c, X3 Z      if (yPos < (0 + BallSpeed)) {
; V5 ^0 |7 ]" e; d- i$ n         yDir = "down";3 T; P( [( l" V6 R7 a. G0 K# `
         }
( I, ]" D) }2 u5 Q* J% |$ E* G8 {      }
* g7 I' I: Q/ l   if (xDir == "right") {
7 A0 [. f8 L  @4 a4 C      xPos = xPos + BallSpeed;
3 i) h5 t2 G, j5 Q* L      }
* v* g) O) a  s1 H5 P   else if (xDir == "left") {" u& ~# h0 f0 |# m
      xPos = xPos - BallSpeed;# K4 D0 q; P$ d; z
      }+ C, ~3 O3 g7 E6 h
   else {
0 b: O; e: @5 k- h" r& A      xPos = xPos;0 ?, G- K$ _. i2 b! e
      }6 B# a# z( K+ F- @3 r" A  x
   if (yDir == "down") {
. k1 t4 @& S8 L0 ?* Y& I5 b3 n4 N      yPos = yPos + BallSpeed;
3 V+ k3 G4 R6 L, ~      }3 K1 X8 X9 E# f5 ?5 H' T' p5 `
   else if (yDir == "up") {# f' J. m7 f$ K- ]. b# l
      yPos = yPos - BallSpeed;
/ G! N7 g1 w5 s+ M2 A) q+ A      }
+ a/ P" R% F; `  P+ S9 T# B   else {
' D; q; }# [  J3 b      yPos = yPos;
5 V9 S& Q) K. j      }- Z4 g. ?8 ^; h$ a* W+ @
   }
% X1 M9 J( w& d  Y+ [7 H5 j
7 y7 W. o5 t# N7 p# O9 d: |8 qfunction hidetext(){( p6 h' D2 i5 W, V& c+ h0 n
if (document.all)
( J( S  S9 ?+ e. F; Msupertext.style.visibility="hidden"
( |3 O' v8 F# P, p7 |( |else if (document.layers)- [9 v4 A5 J5 x5 s7 H
document.supertext.visibility="hide"
2 y! l( D$ {2 f4 U( }3 w# x0 a0 yclearTimeout(animatetext)
! n( I& F2 B( e; t" T1 Y, B}) k0 S4 o" A* G% t6 Q& ~
7 U5 Y! a0 Q; \  k- u4 v6 d) P, y
if (document.all||document.layers){+ o& J7 e+ W8 U  E& T/ {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* s: ]9 Z7 b, a4 zwindow.onload = initializeBall;. [" Y0 c/ f; z! [. @9 L! t
window.onresize = new Function("window.location.reload()");
& `" E8 {6 ^" r% J: w3 V6 C}
; T# s5 l( f$ F+ m; H% t& F6 R" ^
: Q2 ?. ]. |* U/ _& U8 l0 Q; X</script>

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