返回列表 发帖

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

<style type="text/css">
' Z* X: t4 x) ]+ `9 H$ `. B3 i#supertext {
" P5 x$ a, r6 u/ m  Wposition:absolute;
! R. h' W- `8 V  E% X* m1 ?left:0;
% F& I& l& Q" ]: q2 [1 Utop:0;
  @# Q; X6 A( Z5 c& Bvisibility:hide;
$ a5 O6 f6 R  q' Nvisibility:hidden;1 q: @$ S1 i! ]7 d7 ]
}5 [% @- q9 \* y# T; `0 u9 |$ _
</style>
& q, C6 a# `( `. z) @  \! Q3 @<script language="JavaScript1.2">
* f/ P5 i# a% d2 x; y* r<!-- 改变下的字体的大小。颜色-->
% ~; S# M+ B0 \8 \var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 V- f$ ]7 m- S! Kvar hidetimer='';* E# x) R% g: a( _% J) u; b
<!-- 改变下的弹跳速度-->  n& \2 V0 B" @; M' D8 a4 L. |
var BallSpeed = 20;+ ?+ \/ b3 Q2 w" z
var contentWidth;
8 A5 D# A- I7 x7 vvar contentHeight;' X2 h7 r( L& c
var maxBallSpeed = 50;3 h7 {+ d8 ?4 R% ^
1 t' K  z5 R' B8 `: {8 L4 I5 \

; _4 Q: O, r" d8 a" }2 Evar xMax;
! |8 H# \& m: P: D$ b: wvar yMax;
  G7 b3 ?1 X7 Y( N4 rvar xPos = 0;! @) j/ }; M+ z, o: `# Q% X( x
var yPos = 0;2 ~% @" j7 F7 m) C8 o5 Y& h
var xDir = 'right';
, _8 y, J% x5 x- s; Pvar yDir = 'down';9 w! M+ U& o2 ?! j4 x
var superballRunning = true;
3 i- P/ M) `  \9 t  U9 Zvar tempBallSpeed;
* M; `- W5 L' e' C' z/ \( bvar currentBallSrc;
3 z# S4 I$ l3 v# t5 |var newXDir;
! q4 `: ^' g3 y" }5 Svar newYDir;
5 g* S0 D9 d" z4 ^. l$ S' v! K4 ~6 _/ _# x+ k; i
function initializeBall() {
  r5 V' d+ F, c& X. \/ X   if (document.all) {  a# y" U" s. t8 ~
      xMax = document.body.clientWidth2 j, o7 n. k  l
      yMax = document.body.clientHeight7 ^3 k% s0 }4 Z  M
      document.all("supertext").style.visibility = "visible";
; f& Q0 ?5 F+ M9 b, p' r, _  Z. x      contentWidth=supertext.offsetWidth
2 l. g- M0 S0 }- W" l7 }      contentHeight=supertext.offsetHeight
- ~- ^- ~% [9 n% X% D9 n9 T$ E, R      }
) R; H0 z1 u; L) s   else if (document.layers) {
+ M% X. a1 R- i7 N/ v/ ^) ?9 @      xMax = window.innerWidth;# Z/ l8 v' T: d
      yMax = window.innerHeight;. z  m# j2 F% h: ]1 U
      contentWidth=document.supertext.document.width& T3 F. \8 e& \, C* E  y
      contentHeight=document.supertext.document.height/ G- G" ?3 B8 J4 H6 Z. J7 W
      document.layers["supertext"].visibility = "show";
. g2 }; R, L# C% i4 f      }
0 T2 e5 z6 R8 Q   setTimeout('moveBall()',400);0 C" T9 x7 `* I1 a) Y4 d
   if (hidetimer!='')
& S, e- |8 y- e! ^; J/ ~# R& ?   setTimeout("hidetext()",hidetimer)  O- G7 F$ o  c# I& n1 X, s
   }2 H& W0 w* F& d; e2 X6 X0 I

# ?% J, G0 x, R, rfunction moveBall() {
8 t: B) P; P) K( a# w0 ~9 h! P& h   if (superballRunning == true) {
: j$ g. j. S1 U- h; A6 i- A      calculatePosition();8 b4 b4 B! a# I( O( T# B
      if (document.all) {
! `% E+ i0 k9 ^         document.all("supertext").style.left = xPos + document.body.scrollLeft;7 s+ l9 P' e2 N1 F
         document.all("supertext").style.top = yPos + document.body.scrollTop;& e; _5 f1 z4 l" ?
         }# k8 H0 J3 O8 W/ x' x& e
      else if (document.layers) {- s' `3 c$ R. Z) ?  T- q
         document.layers["supertext"].left = xPos + pageXOffset;
7 G: Y- ]- C/ Y+ E         document.layers["supertext"].top = yPos + pageYOffset;
( S9 {0 Y. @# a, `6 L         }# a+ z( \* ~5 g3 j7 A
      animatetext=setTimeout('moveBall()',20);
1 |* r% j/ }3 p0 Q  R  }      }& e6 `* G# I' @# A# z  K' _" N
   }0 z7 f" T1 U- l  ^7 L  m
% E0 t3 q( k( L9 ^
function calculatePosition() {2 q* a8 Y  w% A: a$ j
   if (xDir == "right") {
3 F' A0 E$ G" P5 V. r5 n) X      if (xPos > (xMax - contentWidth - BallSpeed)) {  W/ }- A' Q/ Q9 f/ }
         xDir = "left";
& r, |1 L) b' K         }2 E/ X8 v' S( U( K3 A
      }
6 d( |, x; ^# I" `+ |+ L( F   else if (xDir == "left") {3 J( D5 P- U! y* V* p
      if (xPos < (0 + BallSpeed)) {7 T. r6 d( B9 J& t
         xDir = "right";) Q& G% m5 ~/ f& A; @) [; g, B& V
         }7 n) H- A0 K9 D) K
      }# p* |  P- }1 b8 L9 x: M
   if (yDir == "down") {% E  v3 j, L" g. _5 e
      if (yPos > (yMax - contentHeight - BallSpeed)) {
1 S: L: Z4 D0 J8 f         yDir = "up";' N8 B5 |4 L* Q, R" |% n2 C* l, I
         }
" Z% f# P4 y1 T/ f      }- s6 z" e( O  x* f! }% M
   else if (yDir == "up") {
3 b" f8 C9 Z. N; {2 A+ f+ N      if (yPos < (0 + BallSpeed)) {
7 `. z# t3 I0 k* O5 @8 P1 }: h. L) b         yDir = "down";, `: c5 f* _. {
         }
9 p0 S3 B3 |' M" h" [      }
8 j' Q6 p. s1 f! i   if (xDir == "right") {
# L/ L. f8 [) ]! k+ z' @% \      xPos = xPos + BallSpeed;
& w0 g  m7 |; @( D      }
9 r% u- G4 {8 |6 j) O3 t  Q  N: B" e5 s   else if (xDir == "left") {
, u" _# o+ j; I2 W      xPos = xPos - BallSpeed;0 J) W+ s. M' O
      }' {5 ^7 m$ F4 ^( M# h. E3 s0 i7 t
   else {
6 n8 N  l! y! k0 Z4 F      xPos = xPos;
1 \/ G- F8 }/ A) V, ]2 V      }3 @, c; d- Y+ U
   if (yDir == "down") {
+ F# ~$ \0 a. U5 E! x# u& F      yPos = yPos + BallSpeed;! G8 H, H( T: r" P
      }
% f) b( _) a& o9 Y   else if (yDir == "up") {
8 ]- g$ ~& h. U9 b, C      yPos = yPos - BallSpeed;
6 G0 \$ G, n& t      }
& W- E; H1 D" Y5 J$ B5 t9 J# w1 c' j" K   else {: _# x1 b! F. W) R+ P, T
      yPos = yPos;
, H8 [, T/ R8 I, t2 v      }
! Z# D9 M5 H  k2 b8 X1 U   }4 e8 ~1 u* A% k
$ p: D1 p9 i3 J7 V% W5 r6 q+ D7 T5 t
function hidetext(){
( e% |. Q( v- f* k8 vif (document.all)
' e! f5 |3 `/ f5 {3 Ssupertext.style.visibility="hidden") S/ y. I7 x5 `* V
else if (document.layers)# u% q- o5 V1 }
document.supertext.visibility="hide"
$ s3 r- x. ]0 E+ z0 r% U3 ZclearTimeout(animatetext), U, s2 r% G& a7 I: J* D: M# J
}3 v& H, [+ |+ j" M
- ]( _3 f) b5 v6 Q! k: l; G
if (document.all||document.layers){
) w  C. k, \( e8 rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 `% c% }, @7 B  q
window.onload = initializeBall;3 D9 \5 V- \- w0 }; m* @% n/ ]
window.onresize = new Function("window.location.reload()");" X2 X/ I. c% ~
}. p) ]( L+ s6 D
2 @( C6 I% O# r1 [
</script>

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