返回列表 发帖

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

<style type="text/css">
  b- W9 {: Q3 n% c: Q7 P#supertext {
! g* f5 Z! D9 dposition:absolute;" C, `- a; N$ d3 J
left:0;
7 B% U+ ^% D$ v8 @/ c4 Ktop:0;! Q  C6 u9 S9 o2 T
visibility:hide;
/ y: v+ Q" t4 g' bvisibility:hidden;+ A( C+ m& x; B, R
}. D. J* E7 e: n4 D; T, {5 V  D( W, N
</style>
% q8 X3 @% W& n) ]( |* V<script language="JavaScript1.2">+ y7 r' b3 l* O$ z
<!-- 改变下的字体的大小。颜色-->( v) N1 a5 L2 \* l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 W  s1 _5 v6 M' m8 ]5 g. H: _var hidetimer='';
& m5 F6 Z9 j! `9 u* R<!-- 改变下的弹跳速度-->3 o$ I. q: n7 d/ E) A
var BallSpeed = 20;+ F! i7 `8 G& U9 K( l, |
var contentWidth;" b5 g0 w7 v: o: Z& t) w$ G
var contentHeight;
0 f6 Z' q! @3 o& Z- fvar maxBallSpeed = 50;. |: m1 ~  d; I3 `( K3 e8 I' G2 m# W7 s
# Y( i; H* U* q  V4 B

. |1 w' m! a4 B1 E. F! ?var xMax;2 M9 f6 U& o& V8 p" H/ {
var yMax;
: _# \/ ?5 a, x) i$ {/ P5 fvar xPos = 0;
: u/ K0 S  W3 j1 T8 H1 @% s  p- ovar yPos = 0;9 f) E* Q8 O1 R2 I1 c; `: N. u* N
var xDir = 'right';
' U  \' y; |# O& Ivar yDir = 'down';
/ Q0 @# J* m$ w( \  U: Cvar superballRunning = true;
! e% ~: b8 T7 jvar tempBallSpeed;" T/ h; q! E) Z
var currentBallSrc;
( I5 x' \3 f9 [, k/ X  Lvar newXDir;
( {; r+ e& q# R, [! A7 ^6 x; {0 Kvar newYDir;( L2 y7 {8 i& ~+ y; i  T8 N- A

+ L2 M) Q% ^0 R) T9 ffunction initializeBall() {3 H& u/ e$ c+ Q1 N
   if (document.all) {
4 w7 J' }+ i( n9 w- J! Y      xMax = document.body.clientWidth& N: H  p9 y& G' d+ C' f9 Y  D; J
      yMax = document.body.clientHeight* B& }$ D" ~0 L) G- ~5 |/ h
      document.all("supertext").style.visibility = "visible";
/ x4 `( J$ }' }2 A      contentWidth=supertext.offsetWidth: ?6 f4 F! I5 H3 X  v" V
      contentHeight=supertext.offsetHeight+ Y! V5 N2 {2 a+ V; Y8 |" M# f: k
      }/ c9 V" J: a$ S2 b
   else if (document.layers) {& i4 ~7 R. P- P
      xMax = window.innerWidth;7 V* X* x+ ^8 f* ^
      yMax = window.innerHeight;
" T9 `+ N# ~9 z( y7 Q% }" p      contentWidth=document.supertext.document.width
! R- s% W, x4 R$ t$ M6 F; }7 |4 D& i      contentHeight=document.supertext.document.height2 v' ~" P0 T. ?
      document.layers["supertext"].visibility = "show";
* y0 H2 t$ j0 b" K, f: t' t6 v- v      }8 t0 H2 ]- `/ ~& E. o3 `3 ~) ~. I
   setTimeout('moveBall()',400);
6 i4 E' C. K6 Y' N: P2 `8 g$ E" @   if (hidetimer!='')
5 l$ Z8 D! V' K   setTimeout("hidetext()",hidetimer): J; s9 }, q0 D3 ^$ I
   }
  @& f5 T7 l# i' Q: l
$ S1 P1 l7 ?$ M5 Y; _& u1 ~( \function moveBall() {
% A& B) K0 Y# F. _0 g   if (superballRunning == true) {
9 `  S8 u) a9 e5 I      calculatePosition();/ T: ]) ]4 l; e  ^3 m9 g
      if (document.all) {+ Q8 y% x$ K( ^. U9 @0 @6 V4 c
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. ~3 l2 \3 Z/ M$ E# @         document.all("supertext").style.top = yPos + document.body.scrollTop;' p+ W5 l+ w/ R  w2 l5 c, i
         }( \! r4 b( u) C1 i" c  ]
      else if (document.layers) {& o5 f! w, u; U" a9 J& r. D. W
         document.layers["supertext"].left = xPos + pageXOffset;
" c6 J' S4 {7 l# P5 u4 I: c         document.layers["supertext"].top = yPos + pageYOffset;
/ M, k% `7 F  e3 j; V% R         }' t7 a3 l  V$ L% [
      animatetext=setTimeout('moveBall()',20);8 I  n2 e' F% ?1 @' R1 {
      }  [' E& w* p2 H, P/ n2 M+ t( E
   }, `& K' C1 Q0 }# l) _" p
% Y  H- J5 w! a
function calculatePosition() {
6 L6 M, c  ^% \8 O' M$ @   if (xDir == "right") {
- t% d. `6 O' b; j1 o0 \      if (xPos > (xMax - contentWidth - BallSpeed)) {) p+ t7 _2 r' r. [2 U5 j* R
         xDir = "left";7 Z0 z6 j  F4 {+ v) Q
         }
+ p3 w( F! k' M, y. ?2 Y% G$ J      }
3 m% C9 j& a2 T% {+ a0 k0 G   else if (xDir == "left") {
! X9 q$ G" \, ]+ Y; ~& t& k2 C6 y      if (xPos < (0 + BallSpeed)) {; L: }* o; L# A2 g
         xDir = "right";
4 Z% S  g* ]- Q- {9 P, s( R( Y         }
; H1 E) p! a  j4 D) g8 r: w      }' Q8 G6 _. N( t
   if (yDir == "down") {
, S  j# ?; f2 E7 R+ f8 l" r* J4 W, `* D      if (yPos > (yMax - contentHeight - BallSpeed)) {
) X+ e/ P" R: P1 k( A9 r         yDir = "up";
. q* v: d9 A0 n0 B$ }' V         }+ Z3 _- `" N0 \1 r8 f# Q# `
      }
5 p* K3 K0 @* a* _   else if (yDir == "up") {2 z& {: Q- l! J: \
      if (yPos < (0 + BallSpeed)) {
5 K6 _# \, \* }& b3 t9 u         yDir = "down";8 ]0 r0 G9 B8 r' E" U- s8 {" f9 @9 S* n
         }. p7 I; {! E1 ^4 a
      }# a; Y7 S$ x' _4 k) p( K4 o9 [
   if (xDir == "right") {
' a' Q# `1 f9 f  {- g7 n8 j5 m7 b" p      xPos = xPos + BallSpeed;
7 w0 M: n$ O% k! {8 X      }
  ~/ }5 o. z# k: m1 c   else if (xDir == "left") {
' }2 {- J* p4 J5 q$ r# P      xPos = xPos - BallSpeed;
7 B% j4 X# V9 B- L# k      }9 [' }7 r6 x+ S2 M# `6 Q
   else {1 p& r& S6 }7 Q6 v. l
      xPos = xPos;
0 Y8 z  u4 L' U, g      }
4 K  c/ {5 p8 t% g) p   if (yDir == "down") {! ]  o0 a( y, s2 R/ W6 _9 }4 F
      yPos = yPos + BallSpeed;
8 N" d/ t9 ?2 Q      }
' m; W# D, t; P. u: F6 z$ U) I8 \' I   else if (yDir == "up") {4 g) l: v! v, k+ X
      yPos = yPos - BallSpeed;
. W% S  _2 ~3 z. c' ]' a      }
2 _+ t. M# p; g   else {
' Y$ q9 q  W2 p3 T  ]( H      yPos = yPos;! Y3 P$ I. D: V- P  y/ K( _( d
      }' M1 d1 {6 Z* c2 B
   }
) C4 o9 D, S; N! {' @, a2 |# Y# A. a; Y, u6 h
function hidetext(){
: i$ ^' d6 S) s7 ~if (document.all)
; Q, G) @9 c+ Q; ?. hsupertext.style.visibility="hidden"
0 c* G/ N( k1 Jelse if (document.layers)
: J) w. {2 @- {7 N4 D4 F- Gdocument.supertext.visibility="hide"! }9 ^6 j/ _) H7 k6 X' t
clearTimeout(animatetext)
9 E; D+ ]( N9 b! I" |9 `}
& T$ C. }( m! P, s7 m% ^+ l8 Y$ C: G- `) R# W& C7 @
if (document.all||document.layers){
* Y) E6 ~$ P5 r: N" R- ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): T: s6 @+ H/ A: H; @; E- y
window.onload = initializeBall;
4 k' d3 f/ y" j  v3 Cwindow.onresize = new Function("window.location.reload()");
9 O; }+ d: E" c7 q1 p% U$ k}# f* o! V7 q- k% M

' J) w0 q2 W. g: D' @</script>

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