返回列表 发帖

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

<style type="text/css">
: j0 }; w# B2 t9 d#supertext {9 X/ Y5 Z. Y; J. r7 Y0 [% M' O- \- f8 \
position:absolute;# F2 G+ q6 Y1 p0 s4 p; u* Y
left:0;4 K7 Y; U8 D& @
top:0;4 o0 U9 b6 @6 [9 q! u  g* ?
visibility:hide;
! N6 t& q5 C& \visibility:hidden;, I9 h4 Y3 A3 J: ~- |6 p. y6 [
}
# V2 j$ I; Q# K; f6 B9 ?</style>
- q2 a$ V/ ~. S# q/ }# C% u- b' L& {<script language="JavaScript1.2">( x) Z. ^" z% q
<!-- 改变下的字体的大小。颜色-->
$ _% d: L( J4 ~3 H" Q  Svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': V  e( _& R- d4 k8 ~
var hidetimer='';
! e' ]; `" g7 Z3 r4 a) e<!-- 改变下的弹跳速度-->
8 E+ z% L+ M0 P& Svar BallSpeed = 20;
; p. [- g/ a% A  e: l. v9 Mvar contentWidth;% m  ^& @: X' p# H- r  t8 y/ _
var contentHeight;' X$ \7 h  O! }4 s8 B& Z1 x- A+ M
var maxBallSpeed = 50;5 {6 Y! K: K( s5 V( c7 Z, c# r
2 p/ Q+ |; t, [6 I# k8 U
; o6 |8 M+ ]1 X+ B$ @0 G
var xMax;
8 @5 E/ {- v/ @1 d5 ^$ jvar yMax;
% X# c" T! f5 A7 yvar xPos = 0;# m' Q& q2 L' o* U& H# U# k
var yPos = 0;
8 l  ^8 N# ?1 |var xDir = 'right';! r# f- i! t, u9 H1 E5 ~
var yDir = 'down';
) X; m! X" |% B8 v6 avar superballRunning = true;
2 H. n% Z$ n* O$ v2 o. j8 ]var tempBallSpeed;
" Y) J( k5 g! u' hvar currentBallSrc;+ _! V- }3 a: w9 B5 v6 u
var newXDir;) m' D) o" o6 }8 J- c0 q
var newYDir;
' y( r& T2 d, I( V, w" c7 p  q1 w- L* n7 i7 {, v5 j- A  d6 U
function initializeBall() {
6 q! W4 \# u: P4 X2 ?" u1 E& H   if (document.all) {
8 w8 ]: Q3 ^8 n6 f5 @: t9 E      xMax = document.body.clientWidth
; J. ^& K3 Z5 {' A, H      yMax = document.body.clientHeight/ V) L+ H- S5 X9 [' y. m
      document.all("supertext").style.visibility = "visible";
7 o; T' R/ X6 [' U/ i      contentWidth=supertext.offsetWidth
# }7 y7 c( J. `3 c/ q      contentHeight=supertext.offsetHeight0 `* W$ Z2 {: }* R2 T
      }
+ P2 |' I+ V; z   else if (document.layers) {
) r$ b- U4 e( \& w- r2 t      xMax = window.innerWidth;6 S) I3 k% p( K" B
      yMax = window.innerHeight;
$ }1 N9 r5 o& y9 o: D# G      contentWidth=document.supertext.document.width
0 Z- q/ v; s3 @: A! {7 g/ Y/ y. I      contentHeight=document.supertext.document.height
+ g+ c; G' u$ Q      document.layers["supertext"].visibility = "show";$ Q2 l9 L6 }3 F0 s* O5 T& V  Q4 l
      }
  Z) p$ H4 F1 X  @( x   setTimeout('moveBall()',400);/ }; |0 a" y1 _& T. [0 L
   if (hidetimer!='')& ~; E$ Q& s, x2 z# E# M9 D, J
   setTimeout("hidetext()",hidetimer)
, ~( e0 v6 S! s" Q$ g& l& L5 W   }
5 I2 X, J- W* k- Z9 S
5 `# U7 o- j2 |$ u0 f: qfunction moveBall() {
& E8 r5 Q3 G7 I+ L   if (superballRunning == true) {+ R$ @5 X) a2 N- V6 Z
      calculatePosition();
$ X6 n2 V5 B' l% T& z& k/ g      if (document.all) {* M' m0 K8 Z4 c1 ]
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 Z5 f& k1 e: D8 W* C         document.all("supertext").style.top = yPos + document.body.scrollTop;' O+ A; q6 C9 ?2 G6 H" X  e
         }
& d9 _- J; U# X      else if (document.layers) {+ m- ~! Y8 p# ?3 @+ v$ ?0 S  B
         document.layers["supertext"].left = xPos + pageXOffset;# `6 r0 ]6 t/ [+ I
         document.layers["supertext"].top = yPos + pageYOffset;  e& x7 U/ {& T# h" |3 t
         }' F7 J3 E+ s) _7 [. A% F. S
      animatetext=setTimeout('moveBall()',20);+ G/ j8 @' l4 K- W
      }
# A  B) b. e3 ?$ B# t# i+ P   }
: e. l5 [2 }  u  N/ H3 h, N% N7 R. W, R+ }
function calculatePosition() {; I1 V3 H; J  ^
   if (xDir == "right") {
+ J3 M  l+ h7 V$ e' S, B      if (xPos > (xMax - contentWidth - BallSpeed)) {6 k. O2 `, g3 a% u+ e2 X
         xDir = "left";
1 K+ Z! i0 j3 K+ `7 L         }. \8 A- _: R4 }6 B+ s
      }
( m7 m$ ?$ g/ Z" W( a5 c* K! k# Z   else if (xDir == "left") {
+ Z. a; o1 k$ c      if (xPos < (0 + BallSpeed)) {' T; i: `% V4 b' |+ u, x/ l
         xDir = "right";' q& S+ W! m& j) O8 V+ W) A0 m
         }
) t9 d& M5 P( j8 E: q% e      }
( l1 @' K2 y1 B+ M- z1 N) Y& T   if (yDir == "down") {0 N% o& r; p- _' V9 @$ R
      if (yPos > (yMax - contentHeight - BallSpeed)) {
* Q2 S6 o) L( d         yDir = "up";
( W. O% l/ q: k* L         }0 X( k3 H# h9 J. h# a! }
      }8 z! i* V, z- n4 r
   else if (yDir == "up") {
/ |- C" q: Q6 a! v* @* d  B' O      if (yPos < (0 + BallSpeed)) {
2 P, ^: ~8 x4 k# |6 Y& {- Z0 W: J         yDir = "down";& A6 L" z/ |, O
         }1 q2 u: b! o/ \
      }1 Y' f5 t" ?# U
   if (xDir == "right") {3 I# y- `8 d( M, l- P
      xPos = xPos + BallSpeed;$ q$ V; K: j5 B6 b- s' v3 R# H
      }, P0 n$ t0 q* j1 M" S: ]
   else if (xDir == "left") {
/ i( `7 [& G' T+ b: I5 x      xPos = xPos - BallSpeed;8 b; A2 G  j3 w; A) e& ]- e% \
      }/ z4 O5 D. M: j, \+ p0 K6 q  b  Z
   else {/ p2 [, M0 m9 F# y: z
      xPos = xPos;1 E* k1 F; I5 K; r7 Q" @
      }
8 v0 C2 o8 ]# P' z8 k   if (yDir == "down") {9 u. e" [9 J  e! x, Z; B
      yPos = yPos + BallSpeed;2 W, S5 Z+ O) c& p- L6 h
      }- u) f5 D: @, s( p5 I
   else if (yDir == "up") {
3 _+ G1 w0 M/ l      yPos = yPos - BallSpeed;
! t" z' C$ U1 n1 o      }
0 d8 Y. U3 ^5 p- \7 ]/ E2 C  X   else {
- L; g/ _; w- M( \0 Y! D      yPos = yPos;
; p/ h9 {6 _; ?( M* E2 i5 q: ^      }
# ~, I: D# h4 m- t/ ~9 r   }! ^) @$ Q- q% g1 t1 R' v

. ^9 P. P, T  K, S, \+ D+ ufunction hidetext(){
0 e0 U) v8 q- N# v! G8 Vif (document.all)
2 J' q7 ^7 C- V; D9 I2 q0 V) a8 `% N; csupertext.style.visibility="hidden"
, R9 q1 b5 G5 t( J6 T1 Qelse if (document.layers)
5 u+ D8 `/ e5 _5 |! q& e- ]document.supertext.visibility="hide"1 O" q8 p' M* l9 t+ i$ n
clearTimeout(animatetext)
4 z3 q* v0 r; q; d' z5 u9 a; y}
1 u) J6 P5 I" e1 S2 _+ }
" p  i, ~) y2 A+ H( q" _3 o) n) |if (document.all||document.layers){
- c3 p! ^( I( tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* j% X4 U8 A  ?; V2 x
window.onload = initializeBall;
) R  s, k% @6 rwindow.onresize = new Function("window.location.reload()");
, r. b/ G3 [% \1 s' o}. h+ F( _$ B9 c- w

3 ]6 @: D$ Q- ]0 V( t</script>

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