返回列表 发帖

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

<style type="text/css">! i! N+ a. Q9 D$ ^
#supertext {
) G" I) x' X0 y/ mposition:absolute;3 R# E; @5 c) Z& E* ]( |
left:0;
2 d% n/ S7 s: B0 O! j8 Mtop:0;
1 ?( n* k0 }1 ?1 hvisibility:hide;! Z. d1 S" }" @$ b) k# I( }
visibility:hidden;
) S: q, D0 ~6 O/ x9 [2 O9 j& X}
2 ]: b( Y' v2 T; K: m3 U0 P0 I</style>) x, `# v: s% I; }
<script language="JavaScript1.2">
- j  o6 m6 S2 X  p<!-- 改变下的字体的大小。颜色-->
3 }6 O0 w$ Z  ]  S% Xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 h. Z* O# I  U) M# D' W
var hidetimer='';7 C  }$ h0 ?: h# j6 J
<!-- 改变下的弹跳速度--># l/ n. K, U, a' A" h) h
var BallSpeed = 20;
/ f  v9 X/ q% k9 `& [" W3 F7 ]var contentWidth;
  M- I6 v, `$ }, P$ t( mvar contentHeight;
2 v+ {- n8 G. N7 _  |/ R* Dvar maxBallSpeed = 50;
9 K+ w8 p4 j" ]# a3 o, A1 L; l$ W; I, |/ [3 U2 x, P) g

- j) H: g1 A2 S5 F8 @0 a" i; G0 w7 ?; Evar xMax;1 l- L5 D: G$ r8 U
var yMax;
" K/ U- T# X# x/ c; h  B& Bvar xPos = 0;# @8 w+ m. u7 l1 |
var yPos = 0;
( g- e) H. x2 ?var xDir = 'right';" L2 ^8 L3 z0 E/ b8 P; c
var yDir = 'down';
7 j( t$ ?0 ~" ?  ^, `0 k* f! |var superballRunning = true;- D& j: y5 z; o, X2 Q  {5 E1 J
var tempBallSpeed;; b7 Q) G& X( w- G, h" C9 |
var currentBallSrc;
. g7 M1 [: B1 Kvar newXDir;
4 @8 w) B0 ?; {2 G3 Q- Yvar newYDir;; c, h9 ~/ x: N3 G0 I

+ n* _: A, i6 Q4 R+ y, Ffunction initializeBall() {
0 L" J. y" p1 d' m   if (document.all) {
  X' i; t" |$ G$ Y      xMax = document.body.clientWidth
* T3 O7 Y. G  w( c* @5 P      yMax = document.body.clientHeight! C5 a. W1 W/ A6 e- ^4 x3 c( M
      document.all("supertext").style.visibility = "visible";+ N7 i6 f$ x! K. ^, b* t
      contentWidth=supertext.offsetWidth
" ^# e" A7 v/ j) X" H2 {      contentHeight=supertext.offsetHeight
, a$ `, L& c: y& {  a5 h8 T) a      }$ Z9 u3 J6 v; F! M9 h
   else if (document.layers) {
  |* v: C& N* ]" q      xMax = window.innerWidth;
4 ~8 D; p/ T1 m; D      yMax = window.innerHeight;
. D, N* z$ h- b      contentWidth=document.supertext.document.width
8 V* N. c' F& R. V5 K4 a      contentHeight=document.supertext.document.height
" U( ?6 \* ?9 [' b3 l. H+ `5 \      document.layers["supertext"].visibility = "show";4 s0 Y# k8 C! C# d1 X) m- K  N) L- V9 J
      }' E1 s4 a% _0 X$ Z8 c9 p" Z
   setTimeout('moveBall()',400);4 I( @# ?, C2 Y- C2 }0 h1 V0 ?
   if (hidetimer!='')
# @7 x, ~$ i( `& ^8 ~/ R* }" ?6 u   setTimeout("hidetext()",hidetimer)
" ]3 |* i) l* `7 Q  ?5 ]) A: X- _6 G   }2 a5 ~9 d7 W4 r; c% I# Z* I, B( n

: N+ B8 S% ]) e, _7 M4 I% u6 ]1 T" rfunction moveBall() {
  R4 I& J  W4 q5 @! q7 t   if (superballRunning == true) {+ R* H; o; y% d8 F/ G
      calculatePosition();: G- S9 l; x' U) I4 n$ a
      if (document.all) {
0 a. V+ [" R. {  M* {         document.all("supertext").style.left = xPos + document.body.scrollLeft;* l, s' E& b8 y( _4 p: c% M
         document.all("supertext").style.top = yPos + document.body.scrollTop;
1 w: G' I2 \  ]3 x8 z         }
8 P$ ^* p) R, }3 ?7 k      else if (document.layers) {
0 o4 A8 F8 u+ o         document.layers["supertext"].left = xPos + pageXOffset;
4 j1 E3 o7 C# K/ ~% c$ Q1 t         document.layers["supertext"].top = yPos + pageYOffset;
$ L1 |  t3 Y/ q, a         }$ I5 M% j6 G9 X( ?- k/ }
      animatetext=setTimeout('moveBall()',20);& W' ]' l% I( W' s$ T1 D9 @  G
      }
- @( ?2 g9 N9 E. p* e   }
6 }- T4 f8 I& V: g, U: |8 t  [4 g) Z0 }" d6 Q) B
function calculatePosition() {
0 ?! y. S% U0 W# _   if (xDir == "right") {
( z8 g1 x8 c' ^0 ~* |3 ?      if (xPos > (xMax - contentWidth - BallSpeed)) {
! y! u. S# Z6 t$ k6 x2 _" z. L         xDir = "left";- p) A3 W5 ~# u7 J) }
         }3 O4 e/ h  D0 ]; U' j
      }+ c6 x- ?9 J) M7 h
   else if (xDir == "left") {$ T: L0 W6 E0 w. r9 N  o
      if (xPos < (0 + BallSpeed)) {
; h5 C3 X, x% K/ X8 r/ _         xDir = "right";4 |: G; D5 G" @3 I; V& J% T) w
         }
# B, z0 B1 N% |2 }      }3 `0 Y2 e' f6 Q) P
   if (yDir == "down") {. r$ ?1 b' H4 A6 w- L" ]
      if (yPos > (yMax - contentHeight - BallSpeed)) {
3 U( o9 R0 v3 W         yDir = "up";
% ^  |, w# _$ W" c( X         }6 P- a; n, G1 @; ], |, s
      }
: w3 Y4 u! w9 A7 X   else if (yDir == "up") {
- B) Z+ T5 ~6 E# R$ r+ X7 C( q      if (yPos < (0 + BallSpeed)) {
  }( ]2 \: [; P" e3 n# P5 e! \) y9 \         yDir = "down";
2 h/ I0 M# i4 ]0 {         }9 V7 R3 z4 I3 |% ]
      }
: r; J7 T" Z5 C4 Z5 Y; I" b   if (xDir == "right") {: U8 r% R; f+ i( K$ H' V
      xPos = xPos + BallSpeed;
) k# p+ f0 M" E3 Q8 Z      }
$ L' U: k$ [+ M, e, y   else if (xDir == "left") {
8 ]9 `2 ~" x' h! n) w      xPos = xPos - BallSpeed;8 a' t' v* K7 w/ b3 M5 K6 z
      }
  L& J1 H' D) G# Z! y' \5 V   else {$ M1 A+ r% |( @, g  D* r
      xPos = xPos;
) p, k1 O0 u6 b  V      }
% I: h( E: G2 Z* f. c; o# Z   if (yDir == "down") {
% E2 K2 [- D8 j/ X      yPos = yPos + BallSpeed;
3 X- {2 a7 }6 g      }
, J# ]9 t' m$ _3 I1 n   else if (yDir == "up") {
+ n; ]- L2 s; y7 K+ u* G      yPos = yPos - BallSpeed;0 {8 U0 o; C* C& A3 p2 @
      }/ M+ Y# P7 J2 e5 `/ z& t
   else {  C5 Q  N8 l; S7 t( K) v
      yPos = yPos;
) G/ ]' j) s6 l6 T" ?      }
4 x9 c  T3 M5 Q% s" g   }- J9 j: s+ m3 a
" U2 S" t6 u$ H  G' g# e6 S) ?5 f9 c
function hidetext(){
& i: o0 [4 o3 c& oif (document.all)# V) t  g/ ~& q9 V
supertext.style.visibility="hidden"7 n/ q' w- O( c' c5 M% f
else if (document.layers)& o$ |; ^4 S8 J1 \) f% c
document.supertext.visibility="hide"
7 j/ s3 o0 D  \# X! Y0 c; x) S; `clearTimeout(animatetext)' z2 o2 U# {7 K, T) T' r' B- Y
}& d# b: x/ |, U8 E$ B0 U% D& \

$ |  S9 U9 K: ~% ]$ `/ eif (document.all||document.layers){; Z; s/ y# M" [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 p" {$ m. e! n! T% _. ~
window.onload = initializeBall;
" X+ \  L4 S/ l% [window.onresize = new Function("window.location.reload()");
% d( H6 X4 Y6 M% n& a}9 p! y0 L0 X% c, A7 L9 t# g

$ S4 v, Q9 Y! x+ S( l0 H/ a' u4 W</script>

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