返回列表 发帖

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

<style type="text/css">
+ Y0 H( E" U, d# v3 ?#supertext {/ {2 i0 L" ^6 [, c, s% \# J
position:absolute;, Y* p; z5 x* X- e* k
left:0;5 c* K4 Y% Y2 [  U7 J& a. k6 ^
top:0;
7 ~9 ~/ H3 I1 D( m' R- a( V. {visibility:hide;
( F, A: m/ x9 T% {visibility:hidden;) a+ H' L7 d0 a  ^! b
}
1 L6 Q# A$ G" h4 w% L; O1 v* u</style>& Z  R5 I6 O% T5 I  m8 B: h: _9 h
<script language="JavaScript1.2">
# Y6 p0 d4 w& u3 C; \. p<!-- 改变下的字体的大小。颜色-->" x' e' }- t1 F9 Q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# Y6 P4 e" P3 l$ j5 h
var hidetimer='';% ~7 K  h3 D5 B# i0 {- U: }0 O* o1 F8 Z
<!-- 改变下的弹跳速度-->
& E- e, z3 ?; B6 l$ `' ^var BallSpeed = 20;
+ q. D$ _. X+ x9 Bvar contentWidth;
/ s3 w0 G& C  |7 Kvar contentHeight;7 @: }) U9 |# y6 r4 F# Z
var maxBallSpeed = 50;
/ }' M2 q0 C1 U1 D. x% M
( K4 ~( m$ g$ r6 }/ ?0 \. o! |4 _3 D  N' p- f1 V+ m
var xMax;' K" I0 j( u, U3 b( y3 k& A
var yMax;1 @' T* {( y% t8 f; {2 f
var xPos = 0;
! k6 h: M& a- S" g8 c9 n; ?var yPos = 0;7 z, c1 m" z# Y  Q: D! _
var xDir = 'right';
2 J& K* Q  x' rvar yDir = 'down';
! U0 W2 H9 a* Uvar superballRunning = true;
" t+ j7 x  v& c" }0 m/ nvar tempBallSpeed;2 x& R) v" B* K9 u  K3 t
var currentBallSrc;" i' ?3 U/ @. b, W% d) o
var newXDir;# D- U- M% m5 ]* R. b8 k
var newYDir;
: @# w8 O  X% l8 U2 t9 S6 h4 s* L
' Y7 x6 y1 |# \' z9 B  E* jfunction initializeBall() {
+ l+ D$ B1 q+ b: h9 O7 c; e; z   if (document.all) {
- q: Q% A, i0 `! W- J/ w      xMax = document.body.clientWidth% }0 B& r; B' z
      yMax = document.body.clientHeight
% m1 v: M3 E) d. h6 B      document.all("supertext").style.visibility = "visible";0 G2 Y( b; Q" T- a! T; p
      contentWidth=supertext.offsetWidth
" p* ?7 s, r8 w: g& v; e- l' w      contentHeight=supertext.offsetHeight' p, J" X$ F) e0 L
      }
% `: Z( x; E. O  v& x, c   else if (document.layers) {% \5 X3 v% R2 [  N0 y
      xMax = window.innerWidth;+ N# E' c; Q% a1 T, G
      yMax = window.innerHeight;, m. k" C7 Z% B
      contentWidth=document.supertext.document.width0 k8 i/ f/ Z0 \4 l
      contentHeight=document.supertext.document.height
, [" l! ]9 u/ U. n      document.layers["supertext"].visibility = "show";4 c  H  x  H, s/ L& w
      }5 F6 S, y. \# C: [
   setTimeout('moveBall()',400);
1 [% j! ^  V; e   if (hidetimer!='')
# y# z9 f6 P" E/ D   setTimeout("hidetext()",hidetimer)! |$ ~/ e/ A+ @6 w! d6 p5 S
   }  i' @+ ?/ D9 d( d2 r- e
/ s+ n" X) Y( c
function moveBall() {
2 n3 m3 o& m' ]& [1 a, R6 `- I   if (superballRunning == true) {4 B" V) v$ L- n, J
      calculatePosition();* \' y- O6 i: h6 \# g) z) z
      if (document.all) {
% N0 f, P8 u2 f' l; d3 }1 M6 m         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 @% w' _) t8 K6 N1 C6 V
         document.all("supertext").style.top = yPos + document.body.scrollTop;
) r" @* V2 b3 V* k4 n         }0 y, t7 l" I6 Z
      else if (document.layers) {
! G+ @- O9 ^2 Y5 B6 j         document.layers["supertext"].left = xPos + pageXOffset;
0 X6 C9 W$ v9 V4 b, H; m% P6 B         document.layers["supertext"].top = yPos + pageYOffset;
" T4 }+ b1 \: g& }- E         }" s4 W# M$ F7 T" m' N% n
      animatetext=setTimeout('moveBall()',20);
! c  P; [; T5 D% _3 \& x      }/ S" M  r0 w( e7 }
   }( f5 F; r5 s/ M7 x* r& @4 f% c! }

# n) I# s/ N2 B; h6 a+ F9 `function calculatePosition() {# ?. N8 F; {/ J* |, [% ~# z
   if (xDir == "right") {
8 L, Q" R$ X) O! \/ h      if (xPos > (xMax - contentWidth - BallSpeed)) {: F+ j% t  H3 m* D; h9 z9 \
         xDir = "left";
# h- ^3 X4 K( `% a7 P" w         }2 I2 M; Q& A) @, O  I! k
      }9 N% `+ e! t# `7 [9 P% V
   else if (xDir == "left") {
1 C' n, `7 r8 `9 G6 k  P8 N      if (xPos < (0 + BallSpeed)) {
& F: t! x5 t# d( M. `2 x% e         xDir = "right";5 F5 p) a( I* j
         }
1 O0 V+ l  v/ u! k  m5 }6 d      }! b1 j5 H* w0 z
   if (yDir == "down") {6 l3 V0 C) T, J9 m$ R
      if (yPos > (yMax - contentHeight - BallSpeed)) {  @" h& @- i8 F; G% }- h
         yDir = "up";
  t* G7 K$ Y; ^: J9 A4 J         }
5 H  ^* c* K1 G& w& g, |3 ^$ d      }# i/ l5 f3 P: t5 n3 O
   else if (yDir == "up") {
7 h( U3 Y8 u# w5 E# I      if (yPos < (0 + BallSpeed)) {
! }: e& D3 }& Y" x         yDir = "down";
3 f; X+ l5 S$ P6 t         }- d1 T+ {  l* [: y0 V* `: ?
      }
6 _4 Q* ~7 t) }# g   if (xDir == "right") {
7 F8 I8 U2 e8 O% `: t      xPos = xPos + BallSpeed;$ F1 Y" K4 g+ d9 u
      }
$ g& h3 |% n2 E   else if (xDir == "left") {
& {) V  h; t' I% R5 o      xPos = xPos - BallSpeed;
  [: I; L7 s# i/ d1 c& n      }# f0 J1 J3 H5 n
   else {. U7 v/ g4 W* M! X: W
      xPos = xPos;
% @8 o4 j2 ~& Z: S' D      }! u) M  l5 E4 K
   if (yDir == "down") {
) @( ?# |: c5 K( U. _1 I      yPos = yPos + BallSpeed;% B) ?8 X- x( K9 ~, H
      }
: I: Y( a( S5 k   else if (yDir == "up") {0 C! j8 Y$ r# b, m7 F* s$ X
      yPos = yPos - BallSpeed;
% m( @9 y# }" k( Y/ v9 A      }
  X' f4 v6 }+ s* _/ N, q, _   else {
% y3 n3 N7 P, E7 x' Q' M' @2 D6 b      yPos = yPos;: y0 l( i% Q6 [2 I
      }
- l2 U) q. C8 Q   }
1 R# q" d6 d. ?& l- b" G& h
  ^; d3 J) g6 _6 ofunction hidetext(){' L" u0 G0 t9 z6 D6 x- E
if (document.all). t8 X2 q' K6 `2 ?* `
supertext.style.visibility="hidden"1 q+ n6 V9 z. l: G- p" R0 A
else if (document.layers)1 T1 K: K* k0 f7 P. V
document.supertext.visibility="hide"
, D1 Z$ h/ ]# \) `. U' cclearTimeout(animatetext)$ E) }7 G. o7 E& Q5 q2 Z# k1 U
}
& H0 B2 A4 F1 |8 e# E9 M+ z  M2 Y: M; c% X) j) Q" j5 e- P
if (document.all||document.layers){
1 w! \/ X8 K" |. t9 T. s9 |+ X% ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), n/ f' C2 H$ O+ L2 f1 R
window.onload = initializeBall;2 ~: W; Z# e2 f) }
window.onresize = new Function("window.location.reload()");
& x% Q1 ]* s2 a6 y4 N% P2 z8 ?: A}) y  j% {" p5 _; h5 e5 y
8 R' \& e0 r/ ]% {
</script>

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