返回列表 发帖

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

<style type="text/css">' R( }4 n2 L! C: ^: z
#supertext {
0 V4 w  {& B1 }; M" j  u5 u- fposition:absolute;: H/ c& O* y& ^
left:0;
& c4 |  K2 T, p% Ftop:0;
2 J4 f2 Q! l4 d+ wvisibility:hide;) y* r& K' j! w. l- v0 f* O
visibility:hidden;6 T% R- C. k$ [0 x* u, Z* W
}* p  D! O2 I: @& J% f
</style>& m  H% e1 M- V2 Y$ x, k6 R9 v
<script language="JavaScript1.2"># t$ e$ N) u* W9 A
<!-- 改变下的字体的大小。颜色-->5 x  ^$ ?3 f# B0 ~/ x
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. c/ l) `  J  Q$ R( K8 m' b
var hidetimer='';
" _3 [$ V6 F) ]6 B7 f! L( L( h0 w<!-- 改变下的弹跳速度-->
) M9 G9 e3 u5 vvar BallSpeed = 20;+ O. a" l5 g( ~6 j
var contentWidth;6 m0 g6 b! j. A9 c
var contentHeight;: ]0 f* `2 D+ G* t' F$ p
var maxBallSpeed = 50;+ U: ^& L/ U7 Q3 j1 S; p. O

8 s/ {3 _+ }. R% ]1 V1 L  C! k/ Z; v& m! m/ V+ T/ S  I' a
var xMax;
7 p- P* W' Y$ J* ?var yMax;( f8 D" _* ~7 o, ]) r
var xPos = 0;; E( x2 o: S) N* j
var yPos = 0;
4 M2 W/ K' ]+ L8 y8 d+ ivar xDir = 'right';4 e3 o1 ^# r. c8 _" {  V
var yDir = 'down';
5 b! X7 E4 A% E2 b2 o2 A6 a: ivar superballRunning = true;1 |5 Y$ f! G/ i! O( C  L4 h  `7 ~: S
var tempBallSpeed;  y- e3 [( m  @
var currentBallSrc;
  h, n5 o5 B% Z- Mvar newXDir;
8 s! C9 J' a% x7 a+ _2 [' _' ~& j! t. hvar newYDir;7 A- ?. l, m4 H7 [
  `' u9 I% i, }! _
function initializeBall() {
6 z% |, r  t9 d% f0 X   if (document.all) {  m: P" p9 p7 u
      xMax = document.body.clientWidth
8 k# A0 L! _, [! W; m      yMax = document.body.clientHeight
2 T" a4 M8 M8 S9 @7 |: ~1 |( s- E, M      document.all("supertext").style.visibility = "visible";
# G: k5 y" ^( x: k; P: z      contentWidth=supertext.offsetWidth
6 X6 X+ o4 K1 l      contentHeight=supertext.offsetHeight
/ x1 Y+ r5 R7 ]) z' Q# c      }
0 s0 B2 Q3 @: f/ V) f   else if (document.layers) {6 h2 K: c9 N+ E9 |
      xMax = window.innerWidth;
) V0 d5 P* W- _- \) I      yMax = window.innerHeight;
1 s7 D* u- o/ Y      contentWidth=document.supertext.document.width
$ `0 V% X+ k" v$ A9 ]9 q      contentHeight=document.supertext.document.height
9 n. O% V! h) a$ a" ^      document.layers["supertext"].visibility = "show";
% c3 k  \, Y# }! I+ c" @      }
' v& Y; L, @" t" G9 e8 D5 f   setTimeout('moveBall()',400);
9 j& r: }6 x5 g7 b' U% g   if (hidetimer!='')! H2 Q5 u2 y+ d6 T& x* y
   setTimeout("hidetext()",hidetimer)
' V! Y2 m, h5 \* U5 }4 F   }( T, W( b  I; G1 \7 k
& Q1 k, a  K2 A
function moveBall() {7 M  A2 F6 R5 F
   if (superballRunning == true) {
' x& b& H/ e& [' B/ A: ]! F9 p7 i      calculatePosition();& I5 Y( \+ Y; t( ^% k0 O9 f4 C
      if (document.all) {  l* `' U$ {: J& E# q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;- i3 \9 K/ i2 f0 h' ~/ H/ E
         document.all("supertext").style.top = yPos + document.body.scrollTop;
, s" m/ m) \& k         }1 r* S8 P3 G9 G4 a
      else if (document.layers) {
( X$ r2 e4 k: C+ P         document.layers["supertext"].left = xPos + pageXOffset;2 i3 j' B& B2 x4 r; u4 n8 C
         document.layers["supertext"].top = yPos + pageYOffset;4 c1 h6 S$ B' Q( \
         }# N, O, K- H! @( S. Q, V+ S  u! G, C
      animatetext=setTimeout('moveBall()',20);$ T3 W0 y8 Q! X3 X0 K2 S
      }
1 |  O. U# Q0 o   }
8 E# V- L: `' L; n4 z, y( F
! d- l4 i0 ~, cfunction calculatePosition() {9 P; u- ?  }; R; g6 C2 Z& H
   if (xDir == "right") {
( U8 |8 f6 G' c2 O      if (xPos > (xMax - contentWidth - BallSpeed)) {
. u; z6 Y2 A- |+ y  \         xDir = "left";
! U9 }0 s; O  i% J1 X         }0 I- B9 E2 C+ A( i5 Q, V5 g$ M
      }5 Q3 o3 F4 o5 U, ]* y% o
   else if (xDir == "left") {
  b8 ~; U, e- t; L$ p8 [7 `      if (xPos < (0 + BallSpeed)) {4 q$ ?/ S, E, b# a6 x
         xDir = "right";8 _' h' E, }) T# l1 Y
         }
# y* \' g$ J# e  g/ h0 K. c      }
6 ~' \( w9 Y7 ~7 S   if (yDir == "down") {
- |7 ~+ I, r" M  R: n) A! F% m      if (yPos > (yMax - contentHeight - BallSpeed)) {' }' ^* u. y8 B; D
         yDir = "up";! r8 t* t& O' u9 S- ?
         }6 p7 l" ^2 U# z6 `, q+ W/ R
      }
+ S/ |( F2 A& r- J   else if (yDir == "up") {
4 s% ]4 m! l! F2 E4 K' X      if (yPos < (0 + BallSpeed)) {: U( J: g* Y; X$ J
         yDir = "down";: H; {% u& t2 H3 }: |( A
         }
0 x: `, {0 e8 u) F+ \      }
  ^' v! D8 a, c( o) z   if (xDir == "right") {
$ U& b1 ?9 V- P- o* q      xPos = xPos + BallSpeed;
  b2 a/ P3 x- }, j# j' k3 ?      }' Z- q: {# ^4 Q0 l, r0 J
   else if (xDir == "left") {' [( Y* {, k( y+ f
      xPos = xPos - BallSpeed;
) ?8 q1 |( G- f3 b/ s7 n      }
5 y4 P- X( Q7 x3 E1 X   else {* \& R7 Q: }- ^
      xPos = xPos;8 _; o" f9 J# P" B) `
      }$ m" O+ a4 Z7 e/ v, Y; d- q
   if (yDir == "down") {6 Y" @8 R9 S* K$ r2 j" W: o" a
      yPos = yPos + BallSpeed;0 {, `7 j5 d/ G  w5 g
      }% J3 [; m. P0 ?+ e$ I
   else if (yDir == "up") {; w2 F& v6 @- B
      yPos = yPos - BallSpeed;
5 o; U) P7 ]+ D. g# t      }! _9 f7 @6 l3 Q& O8 W7 k
   else {2 ^7 D% V) F) M: ?% ?3 o
      yPos = yPos;3 V8 D0 Y5 ~4 B8 a) X0 D$ g# e2 y
      }
9 r  A5 |; k5 ^6 o3 B- I, [3 g5 [   }
0 q1 Q. r9 A1 x0 v6 D/ [3 b3 s1 f2 B+ c7 `5 M% z7 t
function hidetext(){8 @3 X; _' ~* y( @7 x
if (document.all)5 H: ~2 C4 [" v3 I
supertext.style.visibility="hidden"
. L; y; Z* I6 c# oelse if (document.layers)& t# T- H2 O  }% }1 y
document.supertext.visibility="hide"
' f: P  z9 v( W. b9 q! x9 [clearTimeout(animatetext)
" f- }8 v$ L: N# ^  A# N}1 k" @+ e1 g9 T+ S' s
$ ^( {1 S. t; A
if (document.all||document.layers){
! S0 p4 |: @+ D9 Hdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. T0 a$ |- \( Z2 b7 ^& h, n) Jwindow.onload = initializeBall;$ e2 y8 E5 q; z6 k9 \
window.onresize = new Function("window.location.reload()");' l. g- U$ m6 N2 C9 d, V! c
}* E; B3 Q; z- Y
. s' x2 A) W! W( i- L7 ^8 O
</script>

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