返回列表 发帖

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

<style type="text/css">, D. s0 h2 [+ ^9 K- T. D
#supertext {# [' q, W+ `5 Q/ n
position:absolute;: e2 o% X  n, ]8 O( s: F& D, A
left:0;2 S& |4 i8 g) d& m
top:0;
. F4 k. g: @0 D& p- hvisibility:hide;
. i% }2 A5 f$ uvisibility:hidden;
) L4 ]6 q5 G" p% e( p" D; `}
, _& g" h) ^& O</style>$ a& q; [6 Q# s
<script language="JavaScript1.2">
; S  k- r, y2 t<!-- 改变下的字体的大小。颜色-->
" h/ V+ A5 |( t4 evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& l: f7 A$ Y8 z. O1 B& H3 M5 |
var hidetimer='';5 b+ p; @% [& X: U- G3 A
<!-- 改变下的弹跳速度-->
9 T) i: `6 b; jvar BallSpeed = 20;
3 \: o" e+ Q% n1 A: j4 J) Vvar contentWidth;+ k7 Z) O% q2 L2 ~- }$ _6 B7 d
var contentHeight;0 [( t4 e( `/ _3 t0 d, S' K1 q0 R
var maxBallSpeed = 50;
. l5 w: h, d9 k9 L$ j/ D# z) [0 W  q; p0 y$ s! F& N! S# l0 k

$ s, m5 |; W) t) K3 Gvar xMax;2 ~' }  `% j% n; Q# ^; ]+ S* z/ X9 t
var yMax;; S0 Q" i+ S+ A( A& f4 C
var xPos = 0;' J' ^, l+ A9 e+ \9 g1 T7 p* O" R  V( ^
var yPos = 0;4 _& {; G9 i9 m) ~! m- _; ^- E
var xDir = 'right';3 J* r3 ~, G: I( j: _3 L
var yDir = 'down';
* Z/ C) _5 Z; _1 w* B4 \var superballRunning = true;/ I  y# L( q, I6 d& n6 Y$ a$ v
var tempBallSpeed;0 `4 V' r: p) ~- R# q9 P) u0 q$ \2 w, ?# d
var currentBallSrc;
9 t  ~; J5 l! F9 V0 ?var newXDir;
2 |6 q) W. T" F  {! lvar newYDir;
6 N0 T" N. [+ Y  o# c
, A% {9 J* P: g4 J9 w/ L; B8 kfunction initializeBall() {
6 M" h/ ]2 O6 P9 @5 ~. O, M4 p0 ]   if (document.all) {
: T5 `6 n2 t/ P8 b$ e      xMax = document.body.clientWidth& J9 s( M4 r1 s4 u# g9 ~
      yMax = document.body.clientHeight
( g% J  K9 S; K: k' ?- k      document.all("supertext").style.visibility = "visible";% @( Y7 f( G5 z# |0 {1 h! F5 q
      contentWidth=supertext.offsetWidth
" p# x  I- m" l      contentHeight=supertext.offsetHeight- p$ e0 T! I( `; ~, K4 D
      }4 o5 x7 A8 u7 ]2 M% Y/ C; r
   else if (document.layers) {
8 u5 |& J0 I% X9 A- t+ r      xMax = window.innerWidth;, h  f5 d5 V9 Z5 K7 A' B6 J8 S2 L
      yMax = window.innerHeight;
- V# ?" W( \# ~, P" O( Q' t      contentWidth=document.supertext.document.width3 `4 D8 I5 S' V4 E: [4 v* h7 z# l
      contentHeight=document.supertext.document.height" i. Q) R% e/ D7 u. n1 x
      document.layers["supertext"].visibility = "show";) W9 g6 f  A/ ~+ Y5 x
      }
9 \" C, J0 t4 i& U5 G" `* U. ?   setTimeout('moveBall()',400);# W9 I2 I* F8 _7 m9 Y# s
   if (hidetimer!='')7 ]: X4 _9 r+ v8 B
   setTimeout("hidetext()",hidetimer); m1 s1 w, P6 C5 E6 s0 D
   }8 L6 L2 t. `/ s' J5 p0 z

: A% W3 n9 {+ W+ W; B% cfunction moveBall() {
/ Z* U$ ~0 M9 \% S% Z+ A   if (superballRunning == true) {5 y1 ~9 v; K1 [
      calculatePosition();
8 M5 j) N" ~8 ^+ i; L      if (document.all) {
0 }/ H4 T9 a6 M7 y         document.all("supertext").style.left = xPos + document.body.scrollLeft;* V/ W  D) b. I
         document.all("supertext").style.top = yPos + document.body.scrollTop;
% I: E# `" ?7 L" N* h         }3 r" i, P0 |4 Y5 }0 D& @; W& Q
      else if (document.layers) {+ P% T/ {; y6 k/ ^
         document.layers["supertext"].left = xPos + pageXOffset;
! }( l0 N: T! t/ x: v         document.layers["supertext"].top = yPos + pageYOffset;# ^5 c+ h, _, a7 [8 J$ Q: L
         }
/ J2 Q4 v$ ?5 \) G1 o) t      animatetext=setTimeout('moveBall()',20);
0 @/ z: {( Y) F% e1 s. W) j  x4 c3 a      }2 \% `" ?( N- d% z2 \% e, n
   }
* X5 \6 g" D# k; G. c
3 \4 y* ^: a$ `function calculatePosition() {
9 X" N9 q9 K% k2 k% _! _5 I5 _   if (xDir == "right") {: ?! f; m3 \8 o* m* S$ _: A
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' ~7 \2 l9 T( w# n: M         xDir = "left";
8 E4 ^/ j) g( o1 v         }
: K  T* S2 }1 Z      }
! V  D$ d3 j9 J8 h$ Y   else if (xDir == "left") {+ t) j0 {* A4 b  N  c- w- m
      if (xPos < (0 + BallSpeed)) {
: w7 @* e8 K/ W1 }) z         xDir = "right";! m- J+ R. q) q9 }
         }
- T; G- j/ o3 A( G; k9 a      }1 ?  c5 q3 h: D$ }
   if (yDir == "down") {
1 i; y- Z+ n% k0 `( M5 B' c  ~      if (yPos > (yMax - contentHeight - BallSpeed)) {
! R# l6 S5 p7 e0 w7 A8 s- c         yDir = "up";
& ^" r1 Q) x1 L0 g% x4 C% T         }$ ~4 ?) g; W" }2 _9 _6 Z" v( w
      }+ a( D; w( T& O3 }: k1 ^
   else if (yDir == "up") {
: D" [& R  e+ B      if (yPos < (0 + BallSpeed)) {
: K( F2 @# z4 V7 y! q7 N9 E1 F         yDir = "down";' I* z! D5 D. y) V( r
         }. X! x  W: o9 q: F) @- e
      }8 U9 ?8 s6 i. q5 _- K
   if (xDir == "right") {) U3 l9 u, c1 M" K' W( v+ {! j
      xPos = xPos + BallSpeed;' H3 J: J% a* W8 B/ m5 O$ O
      }
$ \' }9 ?0 t5 w) P& g. R   else if (xDir == "left") {
. i9 M% C* Q) W* i5 x0 I% h      xPos = xPos - BallSpeed;
$ k+ @0 ^8 |! Z0 I      }1 @. ]. z8 f4 H: k. ?6 [
   else {4 m! d* T; o0 H6 l. j7 x! ?0 Y
      xPos = xPos;
6 B* r! |  R# R, H  w! b      }) s: m! n5 x5 Z4 S/ g; ]# g
   if (yDir == "down") {
3 W  t, p  F$ r. z      yPos = yPos + BallSpeed;& _' Z' Z" c) X4 C% ]; ?
      }) j  {% e  |0 `
   else if (yDir == "up") {' |& V3 C3 F+ h3 s' v% ?6 _
      yPos = yPos - BallSpeed;6 g  M: K" u9 E7 Q3 h: Y
      }$ ?8 E$ }% a, I/ g: j/ o
   else {
4 l8 M9 Q4 g& f# N6 H+ q      yPos = yPos;( m- Y6 z' c* z  t3 \$ r
      }( V+ \3 c9 M0 K( g
   }# H; j% R9 a" i! o. Q
) v9 p! J# `1 w. j7 G0 S
function hidetext(){
! L4 E1 D  u4 x/ t8 O- C6 x# xif (document.all), ^" B1 h  ?- K
supertext.style.visibility="hidden"+ a& f: k4 I5 Q+ _
else if (document.layers)
1 _# u# T, N6 q6 Sdocument.supertext.visibility="hide"# E3 z4 ]9 [: P* a$ j* o5 T
clearTimeout(animatetext)# d# v  C5 z# i) P
}9 R7 Z9 N; g- i( ]! i$ |7 S( `

0 X! e- S: |. z# }% |  e) vif (document.all||document.layers){
8 T$ x1 j+ c6 t/ ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
1 y$ Q6 l( `) z; |  `8 Fwindow.onload = initializeBall;, p  n1 C! `2 t( K: V$ C+ {
window.onresize = new Function("window.location.reload()");1 w  ?) }9 t  y3 ^* X( s( A! `
}
# a9 G* S# }+ b$ u+ _+ P7 p! x
/ g# `6 H- I: Y$ E0 j2 j: H</script>

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