返回列表 发帖

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

<style type="text/css">! x" l7 d# C) }
#supertext {5 b1 o) m) w$ T/ U0 ~2 C/ ~
position:absolute;2 R. P! j1 Q) Z. o# C
left:0;
! p. F7 [* a" d, l* ytop:0;
3 w/ J8 h6 O5 V9 `. }3 [visibility:hide;
- |$ n8 W! z3 b/ xvisibility:hidden;. k! B$ A% I9 y" G
}
3 ^2 u: W: H& \$ R1 c( }</style>
* p; B% v+ i4 O1 b& f! D1 V$ Q$ h<script language="JavaScript1.2">% j8 A0 }2 P! u8 O# s, d* G
<!-- 改变下的字体的大小。颜色-->! O* G9 t) [$ ^0 ]1 f/ m( W( M" W* `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', P, M4 o" m! x* u) P8 P; e% X2 }
var hidetimer='';0 [$ i1 h6 j5 w- y2 C. A+ _
<!-- 改变下的弹跳速度-->
6 T9 j6 m( T) Fvar BallSpeed = 20;% k1 h( e9 X& @( ]' `2 M! K- u, f
var contentWidth;3 ?% M1 g; p7 l- L" g' T
var contentHeight;7 z. Z, h9 ]6 M1 h% C0 E" s, I* w
var maxBallSpeed = 50;$ o" u% o2 G. T* ]8 ]- {

  \. ~1 N4 U9 B- F" B8 V9 G2 P; Y6 T& L& h# G
var xMax;
7 C$ P- K; Q1 X7 Z" \var yMax;5 ^, V9 W8 y0 C$ D2 m
var xPos = 0;9 g* c8 j& x% ]& W3 U0 d7 ^7 u+ K! o# d
var yPos = 0;
$ R( V6 d8 _- d& k, R. J  Q6 Ovar xDir = 'right';" p9 C8 Y6 y4 v9 d1 |9 @# R8 d+ w
var yDir = 'down';
, N+ T8 J! s5 i# A2 \/ f" X7 gvar superballRunning = true;
1 ^: x/ y5 T# [) r' bvar tempBallSpeed;
, j4 M4 S& t1 I) O& k$ m0 {9 y7 Hvar currentBallSrc;
: c9 T' e# B# |var newXDir;
* B/ y* v7 h* G# Z$ ?var newYDir;, i3 }5 ^% ^+ r. e. G. K- y

3 n! K: E9 Q4 `function initializeBall() {
) q) T* p5 U9 Y6 K& x   if (document.all) {8 i6 l4 o0 z: [$ Q% `4 c
      xMax = document.body.clientWidth" {; v+ v; R6 f" L! v# F
      yMax = document.body.clientHeight; c! \- F" y! F
      document.all("supertext").style.visibility = "visible";; W/ i* }; r5 E6 o! y6 V1 X
      contentWidth=supertext.offsetWidth$ o0 R3 \% e4 j, d! p
      contentHeight=supertext.offsetHeight$ r; J$ d/ `2 V; T7 v
      }
' Q2 L. V' I* F/ ?3 A* e& e5 c& f   else if (document.layers) {0 w/ K1 w3 N, s+ Q' N, P
      xMax = window.innerWidth;  O9 L) s9 J& s# s# @, q
      yMax = window.innerHeight;) Z7 H' C$ ^9 W7 Z7 v: `
      contentWidth=document.supertext.document.width
3 P2 h* J4 V7 w2 _; w& B1 {7 O      contentHeight=document.supertext.document.height
# R' u0 \) E6 b" P      document.layers["supertext"].visibility = "show";
& t2 N) W4 q- I9 r# Q$ E, r      }
' U7 Z6 d6 Q% [. P2 \. a4 z   setTimeout('moveBall()',400);
9 ?3 z; R2 W& h  j% i/ c4 e   if (hidetimer!='')
3 C4 B6 t. g0 X  t2 T' @* `   setTimeout("hidetext()",hidetimer)$ Q0 i1 p: V' w: Q
   }
7 h$ q8 v0 F+ [/ D  G" P  {9 I7 k9 r  @2 Z. c
function moveBall() {
  f$ z' _- }. s- A- ~. h& d+ O) Z   if (superballRunning == true) {
2 a6 F0 J- L* W      calculatePosition();
3 ^) l: v+ ?4 Z" [# p& [4 l      if (document.all) {
0 o9 g% U; t- z         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" r9 h; Q% E) u; d         document.all("supertext").style.top = yPos + document.body.scrollTop;( Q8 {5 p+ G+ A* G" a2 P( {
         }5 [% E( V. g7 Z6 _5 B$ Q
      else if (document.layers) {
# l7 h" \3 f% s5 B2 ]9 t( g         document.layers["supertext"].left = xPos + pageXOffset;4 u0 h* Z5 `9 B5 d& W. F  E
         document.layers["supertext"].top = yPos + pageYOffset;
2 Z2 s/ v1 K3 R0 f         }/ t% j, N9 s7 L4 q) ~. `
      animatetext=setTimeout('moveBall()',20);
% M& L/ `8 D% U& `3 k      }9 ], T; g7 r5 h' a. N
   }
8 k+ M$ R- i& m# O) w5 Z( }/ z; p+ e0 I4 k# }$ Y. x/ `$ d
function calculatePosition() {
3 b0 n2 N. X0 z- I2 i+ G   if (xDir == "right") {- h" c6 C( v3 ?0 [9 J
      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ ~( T! `& |! @( _+ }         xDir = "left";
( Q6 ~2 h+ o4 Y* r4 U         }
/ p9 H! O0 O$ r1 q      }
" G( V# q) }9 M* r: Z8 e) |" |   else if (xDir == "left") {& V1 U4 c8 o& R$ m7 Z, p# M1 Y
      if (xPos < (0 + BallSpeed)) {1 b# ^& c; ~) K1 [! K
         xDir = "right";& s8 R2 G3 u  C7 y  R0 {% a
         }
  V5 e( Z4 U" b- D% m+ c+ v) }      }. J/ x- B9 T' C
   if (yDir == "down") {
" l, E! J$ [; L7 ], @      if (yPos > (yMax - contentHeight - BallSpeed)) {
3 `; _) ^  L0 R; F" F, p         yDir = "up";% L( _$ \# f. [5 O4 W
         }' @# S9 k8 k) u5 l4 T
      }$ w' N( D# d/ o9 ~
   else if (yDir == "up") {
4 B$ E! E  g. ~9 }  [7 a1 O      if (yPos < (0 + BallSpeed)) {: ?; Y; b' A; W2 C9 l; r" v. p
         yDir = "down";- A4 Q4 I1 i+ {# B7 ]3 t
         }0 O# b7 n) @# ^, v, |0 |1 o
      }
$ a! l1 @' {9 E, c$ h* Z; B8 y   if (xDir == "right") {
" c) _9 \. c  Z% m      xPos = xPos + BallSpeed;& {2 I+ [% V% D, W  F* n2 D
      }
0 a0 h3 P- X4 P2 `, b" j1 V   else if (xDir == "left") {
" B: A0 m; Y8 M2 [( v# ]      xPos = xPos - BallSpeed;
; J3 W7 A# I6 d) W. r      }% N, D$ E0 X9 f( @) E
   else {
- z& @$ V3 p$ ^: @% S1 F      xPos = xPos;
4 j. q7 d6 H0 ~% T      }. _# j. q; T! i2 w
   if (yDir == "down") {, |7 ?; U% @* F
      yPos = yPos + BallSpeed;
$ L$ q, ^: M9 Y3 d) ~2 Q' S, B% ]      }* G( N! A$ H$ n! s/ a
   else if (yDir == "up") {( ^! u3 K) a# v0 V6 U- p
      yPos = yPos - BallSpeed;5 Q! W6 u! ~/ J) j' T
      }. w. }5 b" A& ~* p3 Z
   else {  T9 V2 a- o5 T& W4 [; Y+ t
      yPos = yPos;" c: h' r4 U7 P+ D! S( @7 K$ E
      }9 z3 R: Q" O. E3 J4 n7 }
   }( {9 ?, P& r1 a4 P2 B; t

4 Y/ Y" r# G! o+ ^( sfunction hidetext(){* A: f8 |! ]; f  n) A
if (document.all)# Y* a. ]/ |3 ^! G' ?9 b4 I/ r
supertext.style.visibility="hidden"
* x2 R" g# N. G+ i3 P* Selse if (document.layers)% H& M* F/ ^9 E' x
document.supertext.visibility="hide"& G: B  Q" O9 f" S4 s) i: H
clearTimeout(animatetext)3 D2 `6 H, b" h8 I% ^
}
. [" F5 s, k' _: }
4 B3 c/ d6 d* ?& U2 c8 uif (document.all||document.layers){0 Q- [) m( C& R: m3 l
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 G6 J) j1 I, L4 e  e
window.onload = initializeBall;. V' B& w' ^& V7 g. E
window.onresize = new Function("window.location.reload()");
# N, J! x) @+ A( k# y}" Z* D; h! c& v( p" J! ~, z/ `" Y9 f6 V9 O
2 D+ h; i5 Z# s3 ^
</script>

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