返回列表 发帖

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

<style type="text/css">
/ I  M5 P3 g( L4 B& h+ o2 h( ^#supertext {& A! O9 p. ]' Y% W3 x4 g% _& r
position:absolute;3 F0 @8 i) t7 \5 q, r
left:0;! z8 z4 x$ E5 _  N& G
top:0;
+ T1 i3 i* Y5 D# P: _visibility:hide;
  Y/ u( e3 R0 D' T: e+ gvisibility:hidden;
' V. l' Y( g# o. W}" N8 U( E" L+ [6 s  I8 v0 m+ e1 P/ |
</style>
* R  L/ L9 g+ v1 l( }0 [<script language="JavaScript1.2">
' t% ]- ?' L7 r4 N. U' j<!-- 改变下的字体的大小。颜色-->
/ o# k4 _% T: O! O2 ^# M7 E2 [6 i# Qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 f5 V$ D3 d6 \, L- F  E! |; W
var hidetimer='';
5 T- V* [# F9 n( ]2 l9 H4 J+ B! D<!-- 改变下的弹跳速度-->, ?6 _% l2 c1 ]5 I
var BallSpeed = 20;0 ]/ r" ~1 P9 `( H
var contentWidth;
8 r3 q6 q; D/ a# ?, h  b6 Pvar contentHeight;, s2 h1 F7 g4 I. T+ ^
var maxBallSpeed = 50;
$ K+ R, [  s1 I. _  p/ p4 @3 B6 Z: t1 s' J

2 Q- H/ V) t8 M: T7 S( cvar xMax;
& R& L/ h6 a5 v2 q$ jvar yMax;
9 D  ~  y$ c% H0 F5 D& mvar xPos = 0;) m0 Z7 x4 Z1 U  p# \$ ?
var yPos = 0;
& R# a3 u4 f' ?; v+ T6 E) K! v0 Mvar xDir = 'right';# `7 ], C% ?1 a
var yDir = 'down';5 E/ ^) P7 a9 f3 ^7 D3 G
var superballRunning = true;( _& ]' p" r: W0 J: f0 h
var tempBallSpeed;) X8 B# [. Y5 V" n4 f2 ^1 L, k
var currentBallSrc;
- r$ K$ Y0 u1 {" i" b( U7 O9 G1 Yvar newXDir;  @/ e1 L; B+ a  o
var newYDir;
. o2 L. U. I" j4 P9 e$ X) u' _' ^# \' `# s
function initializeBall() {0 z5 J: @9 Q3 x) D+ @1 q5 f2 N0 `' u
   if (document.all) {" B; v- B- V0 S# R( c
      xMax = document.body.clientWidth
+ i4 `7 `6 i. Z, T) {- I- X      yMax = document.body.clientHeight! n' {: `7 `4 V4 C/ A& {
      document.all("supertext").style.visibility = "visible";2 Y8 U7 M- f' |
      contentWidth=supertext.offsetWidth4 Y3 L2 P5 Q4 Z  @
      contentHeight=supertext.offsetHeight
- x( }4 f8 t1 x+ n! e# b      }; w& ^6 x+ H. X4 P0 f# B
   else if (document.layers) {
5 w( R2 Z0 c8 @# `& h) v" r      xMax = window.innerWidth;
1 l# E' A  F, V/ U2 N, ^& z- u      yMax = window.innerHeight;
: a5 G; q, K0 u: \( I9 D) q8 T      contentWidth=document.supertext.document.width" B. O; b4 i. l
      contentHeight=document.supertext.document.height
, h9 J3 z7 S& O" e      document.layers["supertext"].visibility = "show";% I; e& K- u0 `
      }3 p+ v! Q$ f1 _  t
   setTimeout('moveBall()',400);
- {! _  Z* j' c" W* e   if (hidetimer!='')
& Y/ N5 y- P2 g- x  t4 _, s   setTimeout("hidetext()",hidetimer)
& R0 C+ s/ p( T8 y4 w7 e/ J# K; k   }
8 e. p' a% K7 o  O8 l1 X& O0 _$ W( s& _2 S+ _6 M  [: E
function moveBall() {7 O7 {( }% Y( ]! ~
   if (superballRunning == true) {# M) z$ N* D) h/ v' |: R1 F
      calculatePosition();
# ~3 B  F, Q" ~! p; |0 k7 B      if (document.all) {
7 T, t  ?  t3 i7 W6 N         document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 _9 M1 i% d2 a$ a/ C         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 a* y# n; H5 ^         }. Q4 h' }% Z1 h+ t
      else if (document.layers) {
2 C& E5 A8 m0 |! x8 q9 e         document.layers["supertext"].left = xPos + pageXOffset;$ [- D$ Z& B5 U( g
         document.layers["supertext"].top = yPos + pageYOffset;
- D( l' q+ J5 t, e! E) L3 q         }
9 a$ ~' U$ K, _6 P: U      animatetext=setTimeout('moveBall()',20);
# F+ J* Z# ]) ]/ S! O% M2 ^      }
5 k* w: X* d1 Q$ ?- y1 I: Y   }
. j- l% r9 N* @" T+ Z( N
/ l# S/ R8 P' C$ a7 }1 qfunction calculatePosition() {# x- [7 N. f5 a+ i% T# J% ~: q$ }
   if (xDir == "right") {
- A* U& ~# h) [/ c      if (xPos > (xMax - contentWidth - BallSpeed)) {
! Z# g9 O" C* P. q6 o- X& y3 U         xDir = "left";
  D% A1 f  w( Y8 H6 s         }3 u( Q/ i) V% a0 g& _
      }  F; D0 V2 i3 @6 P& i9 ^' r9 p
   else if (xDir == "left") {
  Y3 j) _( ^$ ]  A* z      if (xPos < (0 + BallSpeed)) {
: i4 T/ J$ G9 P$ _9 |" @8 a% V: N         xDir = "right";7 q7 a4 E% |6 J+ v
         }6 o! t8 T1 c9 _& s$ p8 B" s  `
      }
) i) N. ^4 N5 s$ F   if (yDir == "down") {
& _3 Q, E4 E- o* F) [# r0 q, ]$ ?      if (yPos > (yMax - contentHeight - BallSpeed)) {
$ @. Y: t" Q% H7 P         yDir = "up";
$ H$ U- m, _! l" h5 U         }
, Z' s- L  H$ F      }& L3 `4 D; f: t$ d: P: J4 P+ c
   else if (yDir == "up") {2 H  V* R/ v* p
      if (yPos < (0 + BallSpeed)) {
+ Z! I2 S. W: u1 d9 f. ^         yDir = "down";
2 d0 z9 o4 x; G4 p1 J         }: L1 |8 s( g5 C# N/ b* `+ R
      }
  e7 S. R; {6 u5 i8 W, h" G   if (xDir == "right") {( g8 ?& G7 O  k( M
      xPos = xPos + BallSpeed;5 b/ ]  y& I8 j1 p& H
      }9 o! \- {, y7 X* I6 A! f; C9 t
   else if (xDir == "left") {# C' m6 k2 C) W5 J+ p
      xPos = xPos - BallSpeed;
5 |% C9 ]/ Y- a4 W      }
1 N. b" D6 m% F3 y   else {
0 i6 _6 j4 i0 Q- _( t+ s      xPos = xPos;: V: e; G: i: G( F2 E& I
      }
0 N% [2 v2 O' k/ R. w  D% [   if (yDir == "down") {/ V" H' p( y$ s
      yPos = yPos + BallSpeed;! n. O3 w8 M8 F9 m9 t  B9 [
      }
- P+ V. j7 z1 b( i9 N! U   else if (yDir == "up") {3 y1 Z  e( z* g. i: Q' r' @
      yPos = yPos - BallSpeed;
' M9 X; k! B6 Q4 H% I0 _      }5 {- b0 j+ z3 D; _2 k# @3 d
   else {
7 ?) Z' c. B3 B* z! V) }: J1 a      yPos = yPos;. U* a* K9 z8 H! H- j
      }
6 _  s1 E+ H$ Z, N% I  Z9 W   }' X( F8 \2 J0 S! U- {/ c
; V6 j  B, |. Z! U5 J
function hidetext(){9 g" k$ C) G+ f- `0 `
if (document.all)
8 l7 W$ Z2 E( r0 L3 ^" ?# msupertext.style.visibility="hidden"
% [, e: h# {8 \$ v$ m) {7 h' A  {else if (document.layers)7 b5 N$ j- ^. w
document.supertext.visibility="hide"$ c% R3 j8 f; c2 D- Y5 S* l
clearTimeout(animatetext)) ~! l$ ?( F9 h, ?
}$ V0 L) z5 U& M; j  j

4 C3 k0 ]0 {0 H) mif (document.all||document.layers){
& C% T+ N; F2 i+ h' q: \0 {document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 {' i( K0 E; O  R" Vwindow.onload = initializeBall;0 u5 R" v6 v2 i7 p2 d1 P
window.onresize = new Function("window.location.reload()");1 \1 }. ?4 d# o) y* c6 I
}( n" C# e+ g6 |! Y! l# g6 r/ ~% c

' ^" L2 D; V1 f: p2 X) a! y</script>

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