返回列表 发帖

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

<style type="text/css">/ Y3 u! z% S4 S$ f- e' M' S4 T
#supertext {
1 v3 ~6 E4 k% c+ ?' yposition:absolute;
3 Z5 b  z& k9 sleft:0;- I0 P+ Z- k# _5 a, }7 y, N
top:0;! g- T" w; N' T- j" a' S2 e3 w$ u3 D
visibility:hide;
% U7 P1 `+ i9 S& o1 `visibility:hidden;
' G( F3 Z) J+ b}5 L; {% a. q. e  y& Z0 L
</style>
  I  a8 k. a; J* h$ m<script language="JavaScript1.2">
5 ?3 a) u7 L1 Q5 Y) H# c<!-- 改变下的字体的大小。颜色-->7 v7 {+ y4 z" o$ A+ j
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 \+ j: v+ M) }; Evar hidetimer='';" c$ y5 M' W/ ^2 r
<!-- 改变下的弹跳速度-->
/ o7 G# Q" w! }4 M3 xvar BallSpeed = 20;/ ^2 Y! v1 d; m5 {+ Q+ k8 d- ?% S
var contentWidth;
1 \9 h/ W3 r: A0 m$ q  hvar contentHeight;' }8 i) C/ y8 J
var maxBallSpeed = 50;
# v. S- R* `: p1 q; Z8 b* P
4 ?, z% @# g% T$ g4 X
- h. R! |% c7 t* ?var xMax;3 F" Q9 X- x5 Q9 W9 d8 E, k+ e
var yMax;
1 o' s: S5 u$ X! @2 avar xPos = 0;
, |3 B5 _/ [+ zvar yPos = 0;
' Q" l. y! `' l6 Rvar xDir = 'right';
& f4 l. z2 Q9 }3 h0 q% O( c& f% Rvar yDir = 'down';
2 W7 f; p  u3 u7 p, N  Avar superballRunning = true;
) A3 A- \: e( n4 pvar tempBallSpeed;7 W; V4 M2 O7 ~3 y
var currentBallSrc;
1 \6 ]: N) y& o2 G- z4 hvar newXDir;
* n9 @0 J0 S9 x) M3 Bvar newYDir;; ]$ C: _- z2 I- X

& z  c4 V+ C5 H  o5 H9 m# Vfunction initializeBall() {1 J: f9 [; e( V0 h
   if (document.all) {- y4 D* O" \2 v; k& O
      xMax = document.body.clientWidth
& B; r& ^7 r8 H8 X/ A" K" v      yMax = document.body.clientHeight  V8 t2 j9 F$ w) O$ L9 s6 Q  y
      document.all("supertext").style.visibility = "visible";) q! t  n3 f" T
      contentWidth=supertext.offsetWidth
% V! E( ~: m1 B3 W; @9 V2 z. f      contentHeight=supertext.offsetHeight
* E/ B. f2 R2 H9 r      }
4 ^  P! J+ b1 o' ~  U   else if (document.layers) {
3 Y7 {5 r4 k8 i! X0 I" @& f      xMax = window.innerWidth;: g& A  K4 p( Z7 ~. M
      yMax = window.innerHeight;3 N) T$ ?2 f# T: [) H5 ?
      contentWidth=document.supertext.document.width
9 P5 p0 x) L" M: w) }# a  c      contentHeight=document.supertext.document.height
4 m% _0 C/ s. Z7 h  t      document.layers["supertext"].visibility = "show";1 u- [+ ~3 O7 w& T* h3 h$ w" O
      }
* A, Y5 {& p7 q! W   setTimeout('moveBall()',400);. h6 V2 t$ F( w* h; @
   if (hidetimer!='')
/ D% P0 i% y8 f  Z   setTimeout("hidetext()",hidetimer). Q! X' N' @5 ?6 K- E! S  o. I; T
   }; s& Q' I& `' T- k0 ~1 l7 s
; C6 j. H" m5 V! c& A
function moveBall() {
3 m& V7 z/ E: n  p8 A   if (superballRunning == true) {
  _5 _" d1 \6 l, g& T- h; N  _      calculatePosition();' G/ J  g. C3 w3 u$ |) \
      if (document.all) {7 ]  \' F) e1 a6 q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
) b! ~$ e& b' @1 Q2 e% p         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 h" `& n8 A7 `8 }. [         }
3 T+ P% ]3 H& |  J! c8 y      else if (document.layers) {. Y4 K- o3 b7 Y% f, ?
         document.layers["supertext"].left = xPos + pageXOffset;1 q1 A. S9 c0 n! T
         document.layers["supertext"].top = yPos + pageYOffset;1 q! L; N1 Y3 C* }
         }
  @" P2 h  ?! v7 I; ~+ R3 x* @      animatetext=setTimeout('moveBall()',20);
6 k, I1 @: J- _3 L      }$ ^% ~' m0 L1 a4 U0 ^
   }& _! e7 O* C" ]3 g/ F- g2 c" O

7 |8 Z! r1 X- [- L- pfunction calculatePosition() {3 k2 g: n. z: h' G7 G+ ^' G
   if (xDir == "right") {
' B- `3 q* ]. e" g6 d  |      if (xPos > (xMax - contentWidth - BallSpeed)) {$ w9 E9 a. i- L* J, v# Q6 e
         xDir = "left";' x( {" `( b& s6 m: f- F
         }
( }8 ~. D( c& s; j  O) A      }) |# h2 k+ r  f  \5 J1 M. C
   else if (xDir == "left") {
" m2 m& e0 v7 W: R! w4 u      if (xPos < (0 + BallSpeed)) {: I, }# W( g' y
         xDir = "right";
7 r& Z* O1 T! b         }6 u- c6 m9 [' d; @9 X
      }1 u( y' i  P7 O+ A* p) y# L' D
   if (yDir == "down") {( ?3 S% _1 N6 b0 f7 L  s' ^% w
      if (yPos > (yMax - contentHeight - BallSpeed)) {7 W& L# r( t5 J! q$ ~
         yDir = "up";
$ ?- c. P% S! O& J         }
1 k% R9 w4 j- r      }
% W3 _# e3 o& z+ y* g* P! V& v   else if (yDir == "up") {+ T: U* P9 m3 w& `7 s  L  W: H5 p5 n
      if (yPos < (0 + BallSpeed)) {0 A  M- A0 z* s9 B- ]( ]
         yDir = "down";1 Z+ q+ \2 [5 T! D, g/ V
         }
. f, ^, Y  S2 M0 G3 w; K      }
5 x( l8 J: O9 _! r$ V( A) t( O   if (xDir == "right") {
! a$ b6 g- A  C6 w      xPos = xPos + BallSpeed;  }- s3 I9 t  T, Z/ g; A8 V, c
      }
! N5 ^# v" Q9 `, U# a- ~   else if (xDir == "left") {/ q5 A9 R3 a/ S/ U1 @' |2 \( S
      xPos = xPos - BallSpeed;- P0 X6 E9 Q5 g" W3 v5 L
      }
+ [- |7 z; i& l. c# ^   else {
) s: h% S- y8 S8 K, E' V1 w      xPos = xPos;7 i- ~( J, f- F1 Z: P7 a/ ]/ c
      }. B0 e2 V, }9 W2 y1 M' _" n' h# t
   if (yDir == "down") {9 c; A8 j* a0 M- i' R
      yPos = yPos + BallSpeed;. e$ `; v  e% |: u- v7 ]
      }
- ]' \# m% Z3 q2 R! l1 Q   else if (yDir == "up") {. b7 N! {1 d7 |. w* N, i+ u7 E
      yPos = yPos - BallSpeed;8 B: w% D( o/ N. x6 ^( p3 A
      }* z* i2 i& A  V4 `( M  S
   else {
) g$ k, ]/ g/ ^( e+ I. w4 M6 k      yPos = yPos;
4 ~! n' O2 |  |2 ^      }
* n9 N/ {; [2 A. B, ]; T   }
1 C2 Q# E! F2 b
" T# l$ I; p3 gfunction hidetext(){+ l$ k0 i1 E- T( h4 F
if (document.all)
6 W9 c; c$ ^2 }. E: Ysupertext.style.visibility="hidden"
1 s2 }' H2 x: K+ k$ \3 K0 felse if (document.layers)
& l( g. ~) d) u- E! B  Rdocument.supertext.visibility="hide"
1 _/ |7 K4 U1 j1 z5 ]6 [7 BclearTimeout(animatetext)7 |7 C4 g& u1 ?* g3 d: U6 I9 r
}
4 A( K; z& A0 C
$ L6 ~8 b% {0 H0 H3 bif (document.all||document.layers){
0 f" z: |. n( r. x* _1 q6 N' ~document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 u, D* {' V/ D2 x. t; \
window.onload = initializeBall;; v* |4 o# I+ R( o0 d
window.onresize = new Function("window.location.reload()");+ e7 K/ C& g& a  k1 K
}
4 V2 B* X+ S" T9 a. o, ~; q7 b) p; Z4 i7 H
</script>

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