返回列表 发帖

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

<style type="text/css">
1 Y* H; P' |+ P9 y7 I#supertext {
5 \1 ^) A% s6 `( U! w: ~position:absolute;: Y( \& d8 x7 K( |
left:0;0 ]3 Z% ]- g5 L1 k3 I
top:0;$ p( ~" O0 I# i
visibility:hide;- d+ G, E# @/ d
visibility:hidden;: w; U8 Q7 g$ q, Y
}
: t& M' ]8 b2 h2 p* W* U. s$ w</style>. b# A3 Q, V. Y3 C6 F9 A. F. T& r
<script language="JavaScript1.2">0 D. ^) J9 c# K( S# Q& Y, c
<!-- 改变下的字体的大小。颜色-->
1 B+ N0 C' O6 M" _( r) }7 Xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 ^! Q: I# Y2 U& X% d1 ]var hidetimer='';
. E) s& ]$ E* Z, e<!-- 改变下的弹跳速度-->
5 v0 v/ c; \9 f6 [. t* Mvar BallSpeed = 20;
- q' [7 D& d. r$ j- Mvar contentWidth;) l2 n2 _9 [. L$ [% H% S7 I6 N5 A
var contentHeight;
, c& q* W' \8 P4 O) E  dvar maxBallSpeed = 50;2 U) I, J5 v3 P" M+ W! P

% f& a4 L" h' W! O3 d
/ z$ O$ y2 s1 n3 D8 Lvar xMax;
+ I5 c# x7 N. B; M- r& G; ~2 \0 b/ Cvar yMax;
8 a" [$ P3 J7 m0 Uvar xPos = 0;
8 g7 N' B0 ^! `+ l: y4 Z/ ~var yPos = 0;: x& ]2 G+ l+ T, Y
var xDir = 'right';5 H4 h2 R* I$ `% G8 ?
var yDir = 'down';
$ s; ], G  [( S- {var superballRunning = true;
! Z6 p. E) s8 _var tempBallSpeed;. j4 `3 L* W: t3 {, O
var currentBallSrc;  V/ T9 l; q/ i  j
var newXDir;5 U+ w# v% P4 a3 Q
var newYDir;  {1 g2 Q) p6 B. M4 @& W8 C1 C  d
4 Y/ n7 E9 g5 W1 {: K
function initializeBall() {; Y" N3 A9 r6 g8 _% I3 ?) ^$ B, l
   if (document.all) {1 D% {" N+ G  _, R% ?2 L- M9 d+ X
      xMax = document.body.clientWidth: Y* \8 @! ^" i7 T1 z
      yMax = document.body.clientHeight. m6 a4 c8 S- `9 c9 A  V& g0 s, n
      document.all("supertext").style.visibility = "visible";( x) R2 L4 _% }( v: V; b& {2 G
      contentWidth=supertext.offsetWidth( q- D8 g7 M& L' C" ~. _! b
      contentHeight=supertext.offsetHeight+ z) N, \6 `( N' x; A( w6 @6 w
      }5 l: z" V* m+ C1 R
   else if (document.layers) {, j/ x% u7 m7 B1 w0 w  Y
      xMax = window.innerWidth;
, Y9 z8 E" ~9 M3 c$ t- e6 D      yMax = window.innerHeight;) F! R( m/ W: j
      contentWidth=document.supertext.document.width
% [# {7 |/ e& T1 X; n# U* s$ l      contentHeight=document.supertext.document.height
1 r1 V& p7 Z9 T( m( z      document.layers["supertext"].visibility = "show";
4 h6 A9 Y* r1 X. f      }* k$ X0 Z, a  u% V& G
   setTimeout('moveBall()',400);" }. A. [& c7 X
   if (hidetimer!='')
1 Z" k6 H1 u; X* s1 k& n   setTimeout("hidetext()",hidetimer)
% [0 Q5 Y% ^% R# p. A. W   }; L- g* N# R& r. ~/ K

0 f' L$ @! X/ q. v. N$ r( Pfunction moveBall() {$ }) k8 s: `4 S( _3 j2 q% \
   if (superballRunning == true) {
. h% l: x2 Q3 b$ @5 J      calculatePosition();/ J3 U5 ~2 u* i+ x/ v
      if (document.all) {
% \; w% a* M; T6 q% \         document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 f: ?1 `3 P4 R$ r8 u4 f# \& C  y         document.all("supertext").style.top = yPos + document.body.scrollTop;
* M! l1 m6 u; B; B         }" Z/ Q* \$ _# v/ A+ h
      else if (document.layers) {& ?3 z' [! w9 E5 H. ], Y9 c
         document.layers["supertext"].left = xPos + pageXOffset;  [9 E$ U- C  e6 ?) B7 H
         document.layers["supertext"].top = yPos + pageYOffset;
! Z3 P# X( y& E2 u& n' l         }
1 }# f. N& K0 x" J" K$ G      animatetext=setTimeout('moveBall()',20);7 r$ d4 H2 e0 S/ N& I  c0 v
      }
( s( k. l  U2 ^0 q" B5 _2 P   }
4 g  p- n- u  k% H
0 C! s' C- Y- z' a- ^& @0 Qfunction calculatePosition() {: ~1 t% F2 ~: x. ^
   if (xDir == "right") {5 d) k6 M& b6 ^+ e
      if (xPos > (xMax - contentWidth - BallSpeed)) {& T2 o- E( ^( N4 d! \
         xDir = "left";: v; v$ H' _. `$ Z
         }- {, l# q3 ]; p  g- A! n0 A1 `
      }0 k# c0 G5 \2 D# }! }
   else if (xDir == "left") {
% l4 s9 }: d" i1 {" y( m      if (xPos < (0 + BallSpeed)) {! ?' S  b6 h2 `0 U7 V
         xDir = "right";* S# a, [. q, G7 b" i! _% h7 V1 ^6 h
         }
# l2 p: k# E5 I# N1 F      }
* p4 y* @! D4 H6 M   if (yDir == "down") {$ T& i, M. |( Z( i
      if (yPos > (yMax - contentHeight - BallSpeed)) {- j% U. z! p" g8 n4 x0 @; }2 F% f
         yDir = "up";
- N: M7 q$ f: A5 y4 I- H# G         }( y" i1 l2 X7 y6 P" c5 {3 x
      }
$ x9 E' G( ^) C3 S3 o   else if (yDir == "up") {, {2 W: `* H' n7 [- ~! ^
      if (yPos < (0 + BallSpeed)) {
) C0 W+ J$ r% |9 w: ~- M8 i1 e: d         yDir = "down";
" g) O& G8 M/ n* q$ E5 y         }
8 D4 a' U( y) e) M% L  n      }- }0 K/ P  L0 @" n  e
   if (xDir == "right") {  Z( Z* Z( K  N$ \& d' l' C+ h1 F" y& \
      xPos = xPos + BallSpeed;
" a5 L, N- O" P) z( t+ X2 [- B- A      }
. }$ r5 m( E9 n   else if (xDir == "left") {
5 t1 F* ?$ d  k5 c% n" Y      xPos = xPos - BallSpeed;8 F7 h, Q9 `* o/ ^0 i* }
      }4 a$ [1 W+ \" N1 y& L# {
   else {+ E! i0 u- W1 G3 h( }: ~* X& }
      xPos = xPos;
9 R4 C( F, W' n9 K0 v) ?      }2 w3 O& U7 y, }( ^
   if (yDir == "down") {
; `9 X* U. Y: F& U      yPos = yPos + BallSpeed;5 f: j& {+ N9 W4 t
      }$ F6 y, d( L- p7 h
   else if (yDir == "up") {2 W; W$ @/ p0 |- `+ p$ |4 U! |
      yPos = yPos - BallSpeed;
( Z6 J4 Y- W' U      }' `; K4 D4 y* j
   else {
9 [4 H: q! X  `  a/ U  }      yPos = yPos;1 _: I1 U1 _' R. @1 o: }& r9 |5 C) s) w
      }  H& j8 @9 C. H
   }8 R9 r5 q* [0 l9 n$ S
8 N& \; Y3 |5 [3 J2 K3 c# o( G% l
function hidetext(){
5 I6 Y" w9 f7 _9 g) _if (document.all)
8 e/ G# B$ K3 E0 C" ^9 W' Hsupertext.style.visibility="hidden"$ A$ J$ w" T/ e8 B
else if (document.layers)
. B' j# w+ E" X! ?' A1 N7 n5 _document.supertext.visibility="hide"( ~2 v, m% \( u& E4 o
clearTimeout(animatetext)
$ y* V  S% k- g+ n. v/ C/ n6 q* d}/ d) _& S  O: z* A

' V, W$ M" t5 h! i5 @$ d, Aif (document.all||document.layers){- b4 s9 A& F- z. N% g. h6 f) ?' f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 n% Q! w+ i: J8 _, o- J1 ^0 c8 Gwindow.onload = initializeBall;! R( d4 i2 T+ ?1 c6 M  E$ W( @
window.onresize = new Function("window.location.reload()");! r: e: y; F. H7 P; w
}# X$ v" S2 a' g( a

$ P6 Z1 E" R. K7 i</script>

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