返回列表 发帖

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

<style type="text/css">& |3 x+ p' I: [8 o
#supertext {
" l2 H2 K7 P" v5 e7 Sposition:absolute;
0 {/ h8 [5 w) q) Mleft:0;
" Q9 G3 {2 Y: Y2 j  x7 n& }top:0;
$ Y4 t3 w, I8 @4 Zvisibility:hide;
+ h$ m9 v: w& [: d2 nvisibility:hidden;& @( [5 G- u1 {
}
3 B* D* Q! w/ f( m</style>; C+ L8 L, E) T
<script language="JavaScript1.2">
  A$ U; X0 L! I/ Z6 D2 X1 I<!-- 改变下的字体的大小。颜色-->
$ }4 z8 Y, Q" e% o! Cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& C. z, W. d" Y, wvar hidetimer='';
, |( j$ g; e: n7 K4 F+ |! P. `<!-- 改变下的弹跳速度-->$ y8 ]# m  V7 l/ S# [
var BallSpeed = 20;
) \/ M) b- I: B$ D1 h- wvar contentWidth;5 \3 ]9 C3 i0 k) ?( P1 J$ k
var contentHeight;
/ Q& V7 D0 C+ _% A8 u1 Tvar maxBallSpeed = 50;. L; w1 R5 W8 @% `- D7 V; K5 T$ o

, m! u" m2 C3 p5 u( |. L
! \. ^; i1 P3 B1 p4 b* d+ Bvar xMax;1 T3 o6 B) z1 z( M  n4 v5 ?7 N
var yMax;
5 C7 T* U2 f# n, rvar xPos = 0;: d6 z: x, p1 g2 z+ H/ ?2 p
var yPos = 0;3 L- o9 L2 |2 N2 i$ H) q
var xDir = 'right';: q& y6 A( C' {  w9 Q
var yDir = 'down';9 g8 y) Y+ `& Y2 j! w
var superballRunning = true;
6 }& U* p  Z, I) Evar tempBallSpeed;
7 E: I! K3 Z0 W( Q) T2 J. Vvar currentBallSrc;
* H# G5 l% R; Q( h& uvar newXDir;
/ |5 B2 l# K3 b0 i$ Svar newYDir;& x" A) m1 s. }3 F) v" ?0 I9 g. a

1 e) k* @0 ?+ I8 Y$ jfunction initializeBall() {
& {' O2 \' G, o( ~   if (document.all) {
/ r# h6 C" K* g2 J0 X      xMax = document.body.clientWidth
# p3 }3 N  @- T1 J3 d3 ~9 i" S      yMax = document.body.clientHeight8 `5 j0 o) p7 |& M  Q* S  D
      document.all("supertext").style.visibility = "visible";
+ I( y+ E% M6 {% z6 D      contentWidth=supertext.offsetWidth0 h& c! e/ d; p/ ^
      contentHeight=supertext.offsetHeight2 X3 L; h- S) |$ r' ~$ N
      }
0 A; B# p7 ]  N1 r$ \   else if (document.layers) {
4 I6 K) @: O; P6 F) W3 r9 h      xMax = window.innerWidth;* d7 q6 b$ }% c! R0 ]6 u
      yMax = window.innerHeight;
% Y2 E, x' c: V: y( J      contentWidth=document.supertext.document.width
; z# l8 S6 ]8 E$ p      contentHeight=document.supertext.document.height
' j9 O% Q0 O- X) V      document.layers["supertext"].visibility = "show";3 G4 y& z  d/ ]9 r5 O
      }
# Y7 ~. e6 P6 t9 }9 j( x/ n( n( H" q   setTimeout('moveBall()',400);
; N/ F0 u3 I4 O- L2 a, w   if (hidetimer!='')2 `& m; R. ^* d9 D, c( k3 F
   setTimeout("hidetext()",hidetimer)
$ ]) ~8 H# S: _( Q% _% G   }2 D3 d) C6 _9 d3 A# z- a4 N7 ~
" n9 \  E% X8 K3 O$ `  d7 I
function moveBall() {
! i- y* w5 ]% u/ m1 q) y   if (superballRunning == true) {: u: T, y1 M4 z& v
      calculatePosition();/ k+ N$ H/ p6 k; T; k. y, I; b
      if (document.all) {
/ b" e( I$ U# x5 \+ d( A! y         document.all("supertext").style.left = xPos + document.body.scrollLeft;) O! D; c6 w, a; u; M1 @4 X0 O
         document.all("supertext").style.top = yPos + document.body.scrollTop;3 F7 Q! X6 B8 o) k( y8 @. p. C
         }1 _% r8 K2 C1 @) V  x$ {, ?+ c  ]
      else if (document.layers) {# s: P/ w) g0 H( b1 u$ a
         document.layers["supertext"].left = xPos + pageXOffset;( f7 ^4 U& f, \0 o$ b6 e! C
         document.layers["supertext"].top = yPos + pageYOffset;7 D( T4 |  m+ {
         }
6 v- A; q# }5 V' @  M7 A      animatetext=setTimeout('moveBall()',20);! U; U, u1 P3 T
      }
' f* `# S+ G, n7 y+ j5 p- C   }
0 c' @; n5 Y4 `7 @6 T: R3 x
+ E/ ~$ H/ [& @$ d& i  L6 Qfunction calculatePosition() {- A; K/ r6 p! J# [5 {
   if (xDir == "right") {& ]$ G# }! Z, h5 Y; Q+ U5 F
      if (xPos > (xMax - contentWidth - BallSpeed)) {
; b' ^8 F7 f7 `& S         xDir = "left";. K5 P3 u/ J% a* @, p
         }5 n1 l: f3 V0 b& W3 U9 G
      }0 |/ ^7 d5 m3 D
   else if (xDir == "left") {9 i8 h- b+ a/ h& X+ ~
      if (xPos < (0 + BallSpeed)) {* D# u8 S6 [. ?* v- P1 l4 K2 a
         xDir = "right";( @/ O5 X5 u  l. H4 K( G* U
         }
/ Z! y; P$ V/ s: j% ]+ h      }& R: |% M: Q+ J
   if (yDir == "down") {
3 M. |* S. H  o      if (yPos > (yMax - contentHeight - BallSpeed)) {
; n. t4 a" g: R% F5 ~8 i) I  s; Q9 h% P         yDir = "up";
# y$ j1 e" }' e: y/ ?$ T, T4 e6 N         }
5 H4 |' H' o$ I2 N0 @9 @      }7 y4 m5 H% p- N1 R2 A6 i
   else if (yDir == "up") {
, T+ h' t) r9 I) z& a3 I  G      if (yPos < (0 + BallSpeed)) {
  T3 S! s6 v; `8 @) D         yDir = "down";4 b0 z( P, D; f% [4 ^, C
         }& t* g" M  j( _
      }
  I# o  j- [* Q7 }9 b+ L* ?   if (xDir == "right") {
8 E  r" h* y) i) s/ t$ b) I      xPos = xPos + BallSpeed;
, X. B( b4 U. k      }; E: O3 @  A9 c6 L' @3 J
   else if (xDir == "left") {0 j% T: D0 I; [8 \+ l1 g* j) y3 L
      xPos = xPos - BallSpeed;8 I: K' N5 R, F& p* J& `
      }- v$ y8 `' C! `0 x5 @6 K' f
   else {
* F  V0 o# Y3 L* j4 ~      xPos = xPos;
2 Y8 z- D$ m# n' ?      }: z8 y" e0 O3 D  W( A; v3 V$ @$ D
   if (yDir == "down") {% p5 k1 w+ T, L2 J2 v. j
      yPos = yPos + BallSpeed;! c! `5 l* K. o
      }
2 [; T- ^& f( ]# k   else if (yDir == "up") {1 [/ z/ }& \: D/ b+ m
      yPos = yPos - BallSpeed;
/ B. U+ x* k- M0 C7 n- W      }  g* W7 }7 _5 b2 g
   else {
% `& F) I3 A% M3 J4 P9 r9 p5 f& U      yPos = yPos;) I- T' y# M- i0 F, K( \
      }
+ x2 q' V  }: T% B   }) h5 H9 B  U, I$ \5 W! B; A

, `% Y& Z. G! d" Gfunction hidetext(){/ y. W4 F+ e; B* I
if (document.all)
# W4 p! X* E% Z9 F. @" o6 _' b7 asupertext.style.visibility="hidden"
$ L0 F2 E7 w% s, ^4 Z. Qelse if (document.layers)
) J! S! c9 f5 Q4 `% adocument.supertext.visibility="hide"; @6 B1 J; o( N8 a
clearTimeout(animatetext)" v- B+ d, B# Q7 y( [7 E
}
$ t2 I% t& N: V# [# n/ U% f) K
7 w2 J/ a$ ?/ c2 m) p4 w$ Qif (document.all||document.layers){
  ]+ K6 f9 T) t) `document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 u% g. e5 D! Q+ A1 Twindow.onload = initializeBall;6 z/ z& [( ~4 M: r" c8 O; G
window.onresize = new Function("window.location.reload()");- A& d9 O+ X* O" V# R+ [
}
+ H% Q& H7 J# F( W
0 @: s% q1 p8 ]1 H- H</script>

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