返回列表 发帖

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

<style type="text/css">
4 o, u5 M( N$ d7 ]% G( G* t0 N& f#supertext {* m4 F3 v7 b" F) H6 Q0 j1 }
position:absolute;+ T2 y: O  a& N
left:0;
" M8 |& E0 |/ ]top:0;) ~8 U  N8 @' n) A+ p
visibility:hide;
, y0 V5 {$ Q* E5 s; rvisibility:hidden;
9 c4 q( H7 F' H# x4 s* T2 u' G' `}
) L  ]! J' B# b5 E) M9 o</style>
) J- p, M0 {: A4 D5 D<script language="JavaScript1.2">' h- |( |) Y2 H, I/ @" r  ~& r" d" s$ a* \
<!-- 改变下的字体的大小。颜色-->
$ I8 q) \+ _) c: a6 Evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'0 h; W5 m" }  ^3 W6 L: X0 h! E
var hidetimer='';
5 n; U0 h4 a5 f3 P2 Q8 `1 _9 ]<!-- 改变下的弹跳速度-->+ ]# D3 O3 Z3 f4 p  V4 |/ d5 p
var BallSpeed = 20;1 Z& m' h5 W6 S. X- D
var contentWidth;( |! ]( h: c) _6 O+ ^- Y+ r- w* a
var contentHeight;' x; n, s7 f/ {/ k
var maxBallSpeed = 50;8 q1 ?. `% W& E* v) F% O
4 Q* E, G: n: U+ o9 q" A4 E
2 U- j  _; T  Z3 C3 j2 U3 o' @2 W* s
var xMax;
! K3 f" ~. O& i0 v3 ~9 B4 j3 Wvar yMax;
1 t( d0 O6 ]3 Evar xPos = 0;
8 L8 c# ~9 l0 lvar yPos = 0;
+ B+ }) _* m4 T4 V; ^var xDir = 'right';
( B- r8 Q$ E+ S# J9 d7 Z0 v6 m7 hvar yDir = 'down';
. ~9 V( @% {  yvar superballRunning = true;/ M( z  I& ^8 V- V" b
var tempBallSpeed;
/ _; t! F: v  X+ G/ W7 Svar currentBallSrc;
+ [4 P- J! S% B3 T1 D' _" ~var newXDir;: @6 e; Y+ K* }, w0 e5 p3 j
var newYDir;
$ }  i8 D, M) X+ p# q# u: u. J
+ S, K  X! L7 h* sfunction initializeBall() {# n; C% ?/ w8 q6 y
   if (document.all) {" z, c# V9 Z/ ?7 j) f
      xMax = document.body.clientWidth
' d" U8 u2 Z/ U& W% F      yMax = document.body.clientHeight
) v4 [9 m  z( _. l5 `! x% j      document.all("supertext").style.visibility = "visible";
! U: G- p! V8 v7 D      contentWidth=supertext.offsetWidth. d; n& z$ l& n5 T( F$ ?
      contentHeight=supertext.offsetHeight7 U6 u/ L3 q+ Y- \; P. _
      }8 L% [" v( K+ I/ z; X
   else if (document.layers) {
& n5 N" v6 h4 s      xMax = window.innerWidth;
9 i1 k! ~9 R7 z) Z% a! j7 g% _5 f4 C      yMax = window.innerHeight;) {2 t+ u2 q4 H, m
      contentWidth=document.supertext.document.width4 U( g( Y5 D: M- ?8 S) X% {3 _
      contentHeight=document.supertext.document.height: e( e7 j& s6 u) k
      document.layers["supertext"].visibility = "show";: _" J1 R$ `) L7 f1 i" h# J: H0 ^
      }7 g' v! Q; \, n' [& [
   setTimeout('moveBall()',400);
  u5 F6 z3 e% L3 r8 s2 M5 s7 V8 r   if (hidetimer!='')
/ {/ d7 m3 ?3 Y+ S/ Q   setTimeout("hidetext()",hidetimer)7 j+ c9 `; m1 }& i
   }
' z6 A0 X  B# G2 D% P( Z" x) e
( Z! v/ r' @/ j2 O+ j( Yfunction moveBall() {
3 g" ~; J. s( @9 @9 @   if (superballRunning == true) {
' L  {2 Z) Y, n2 g- q+ ]2 H      calculatePosition();! @6 i! _3 m, C
      if (document.all) {
/ a- Z; b& E  ]0 {, z% Y         document.all("supertext").style.left = xPos + document.body.scrollLeft;5 n- k# G5 i& W
         document.all("supertext").style.top = yPos + document.body.scrollTop;
1 L1 Q' @" Z" c. ~6 @& H' C         }
# K) O. U, D* _$ t: Y% ]2 S      else if (document.layers) {; Q3 `- U; R$ W+ O3 W$ \' r
         document.layers["supertext"].left = xPos + pageXOffset;
4 _& h1 Z' w2 n8 p: o9 a         document.layers["supertext"].top = yPos + pageYOffset;; j7 g5 y9 `4 L2 v2 M( I3 c- q1 a2 v
         }
# ^7 @1 t3 R% G, @- ^/ A4 y& g+ t      animatetext=setTimeout('moveBall()',20);( G3 x; ?2 h8 V; h" r/ V
      }  q, V# p/ f: G, C% y  L
   }
( w9 _- t0 r3 q" e; Q, [% g) @' s% a; u
function calculatePosition() {
6 }* \7 i. X) {, y' S   if (xDir == "right") {
8 ?; k1 k' l& K  k+ d; q      if (xPos > (xMax - contentWidth - BallSpeed)) {: ]/ Q: X. x0 W1 o) O5 c  e6 J
         xDir = "left";
" U7 R+ S* B, k4 q8 g5 w         }2 [5 J' G/ G8 C) O6 t
      }
, G# ^" @2 g1 L. |   else if (xDir == "left") {& R4 _! C, ]' B8 x9 J+ x
      if (xPos < (0 + BallSpeed)) {
. B5 u6 D4 S3 W3 |         xDir = "right";7 v# o0 P; {$ q& Z; F
         }
1 h/ K9 P  f  E' s" h7 e6 ^      }: G7 [* O0 [7 A8 Q) o  ?- ]
   if (yDir == "down") {
/ _# r6 E5 B; E, J$ S1 t3 X      if (yPos > (yMax - contentHeight - BallSpeed)) {, W+ M  I( }; Z: h
         yDir = "up";7 Y" f4 Y0 f! w" u
         }
  _' j; f% S1 x1 t4 R- u      }8 Z9 t3 W7 B7 k! H3 ^3 G" e
   else if (yDir == "up") {! F' f' D: z; w, n# u" M
      if (yPos < (0 + BallSpeed)) {2 w5 d  V9 f- o8 D( }  f/ h- h  T" u
         yDir = "down";5 x: W8 t, R' y: l. y& l
         }
$ a3 m% H! t  E. U& G3 ]( y8 C      }
% j( J' E5 a: ~& v) H4 o9 n   if (xDir == "right") {2 R, W" h) Y9 i
      xPos = xPos + BallSpeed;- J% s* C+ V9 {+ p' v% ~* `9 p
      }
$ E2 l! P. u7 M  U* Q   else if (xDir == "left") {( \1 Q3 |( k( y& j* n
      xPos = xPos - BallSpeed;% W+ m# u& o: t; R( H( Q" _" F
      }
& _+ K4 }2 e, j! k   else {
' I, G+ D# d: [& I5 L5 d; I      xPos = xPos;
& u) B/ |: B8 Z      }
; M+ _6 p2 Z! _7 a: o( w8 y   if (yDir == "down") {
1 g( `+ a: {& v& r0 x      yPos = yPos + BallSpeed;
' u+ S6 {* i! ?& y  B8 V      }- a3 {3 `5 _' J* U; c! }
   else if (yDir == "up") {" Z+ o) m8 l  X5 @0 k7 w3 v5 l
      yPos = yPos - BallSpeed;
, m1 u- \- ]7 B      }6 o: X( Z$ R" ?
   else {
$ Y; R8 k; t  f- P% r' W6 S      yPos = yPos;6 t  L' v/ R3 P) H/ E5 g/ o* C, N! |
      }6 A+ K. K- Q0 V9 w
   }* W" `6 z' j4 c, a
! @) K6 P& c% k( J
function hidetext(){2 X# N4 W/ e/ N( [# T$ E3 b. a
if (document.all)# n- `$ f% q  [# _, b- D  Y! i
supertext.style.visibility="hidden"
, X7 P! l7 Y  l; yelse if (document.layers)( r6 L1 y1 _2 W" j
document.supertext.visibility="hide"
3 i7 O" ]8 m3 dclearTimeout(animatetext)
" Y' t3 R( p- `}
: V* k/ ]& r) k
* Z/ z( G+ j( e: ?4 K0 f4 Y! G: R3 Sif (document.all||document.layers){
8 Y7 O* ]; S) Xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- \: Q  @! _9 b% R
window.onload = initializeBall;0 e! E: r. v% l, b  w
window.onresize = new Function("window.location.reload()");
7 }# y) W# s- f( B}
2 S4 ^  Z4 c$ C0 q$ `7 }: X$ ]8 z6 S# d7 S1 z3 R7 o# [
</script>

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