返回列表 发帖

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

<style type="text/css">
, [3 g: u" q1 B) q3 ~) \8 {#supertext {
6 w1 W$ q  ~$ j8 n# vposition:absolute;
$ A+ b8 m. h/ y! nleft:0;
' G$ ]( C7 O( b8 x8 Y3 c# r; Otop:0;, J7 e# p: e& H
visibility:hide;( ]0 r$ W* f8 P; g) F4 ^% r/ \
visibility:hidden;2 n  a2 v) \; M' [& @, I. H: |/ V4 q
}  ?/ e4 z+ Q- `: z
</style>
1 c8 y9 ?0 d7 j) v% S/ k<script language="JavaScript1.2">+ v* T) a; U, M$ g' X
<!-- 改变下的字体的大小。颜色-->1 @# U4 W# L9 J. b% y' @0 T
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 m! [/ B5 j* w* `$ h; J* Wvar hidetimer='';) e* C" [% L# m% |" C1 v1 r& N/ j% ~
<!-- 改变下的弹跳速度-->! Z/ }, S8 E7 \, H1 H
var BallSpeed = 20;
! X2 A2 T% W( P2 I9 svar contentWidth;
7 ~. }& P2 d0 Jvar contentHeight;7 I4 p- a1 H. t
var maxBallSpeed = 50;
' Y: [- R. X1 Z! G  P# p/ F
+ c4 H" X) Q/ o1 h
* g$ ], a/ O( E6 N5 @0 Bvar xMax;
+ |9 A/ V% ~6 Qvar yMax;
/ \5 M3 }/ K2 ?: X: Zvar xPos = 0;) I( D; X) a) n8 ?7 t: d+ f
var yPos = 0;
8 R) p2 C( ?" Y$ H1 Yvar xDir = 'right';" C# H9 L7 W* `; J
var yDir = 'down';
/ A/ f/ d) |2 ]& avar superballRunning = true;
, l! u6 W7 A4 w( M$ G3 fvar tempBallSpeed;( Q) Y: D8 V: }4 p
var currentBallSrc;
, G& ]5 H" t1 t; {' b" X/ Qvar newXDir;2 R0 [1 @: h: X. ^" L% {
var newYDir;
$ {! \$ }' Z" g% R6 R& e
' d6 s$ d7 v! {: _/ R0 Efunction initializeBall() {% U4 `/ ~* X; [0 w/ e. U+ b
   if (document.all) {
$ s% V- ^$ ^# J' V! T& Q& z      xMax = document.body.clientWidth/ c- T2 |" ]$ o
      yMax = document.body.clientHeight
. K3 h9 R0 e1 c, A      document.all("supertext").style.visibility = "visible";  a0 c, |+ m' G. Y" e  J
      contentWidth=supertext.offsetWidth
8 a4 q; r( ^; h2 n7 }, z9 i      contentHeight=supertext.offsetHeight+ ^# I5 E4 F, P( t# {8 ^
      }! W% F: x' Q; z* R! N" _6 n
   else if (document.layers) {
3 E: i, M  W& r6 ?& F      xMax = window.innerWidth;' |* M* V8 D: C( N
      yMax = window.innerHeight;0 S) J0 u: Y" h1 x* f6 W
      contentWidth=document.supertext.document.width' r% V1 v$ I+ B( e
      contentHeight=document.supertext.document.height
" C$ R: z: e, G$ d( Y      document.layers["supertext"].visibility = "show";
  {: b3 G4 d( c$ q9 f1 m* Y      }
$ t. I0 Q$ o: A! d" ?   setTimeout('moveBall()',400);  `- G& l' c) ~  k
   if (hidetimer!='')5 T3 b4 Z# ~$ t+ I& [  A# P
   setTimeout("hidetext()",hidetimer)
: `5 W7 e+ _' ~   }
# n  W9 O# `& _
- R8 F/ R: c. D* j: rfunction moveBall() {1 U% J0 x: p+ _, s. n0 L
   if (superballRunning == true) {
; e( i$ {5 c1 j0 D      calculatePosition();. W! a4 c, ^, `9 g6 ?
      if (document.all) {! v$ B1 T) y! X9 |
         document.all("supertext").style.left = xPos + document.body.scrollLeft;# W% m/ H& A$ _% Z
         document.all("supertext").style.top = yPos + document.body.scrollTop;7 L# `( a$ u- Q# x9 t! P- F' _
         }$ ^' F; A4 v* V/ a1 R
      else if (document.layers) {
" t8 s. @, g% r* D  k         document.layers["supertext"].left = xPos + pageXOffset;+ @$ ]. F& s: L! s. w3 p% @: [
         document.layers["supertext"].top = yPos + pageYOffset;
# A% m4 p8 _- O. T" g         }
9 L1 t* x. Y  M+ ]      animatetext=setTimeout('moveBall()',20);, _: F5 j  r4 x/ `+ b2 L
      }# v( \- j1 n# s$ F5 _, U
   }  a' ^; Y2 z+ N0 J+ z6 Q6 v9 y  Q
  q/ u& o, }. y  C; w
function calculatePosition() {* d: Q0 }- j2 M# M! Y4 Z
   if (xDir == "right") {
  z- d, b- l" M7 `. Q      if (xPos > (xMax - contentWidth - BallSpeed)) {
( E6 a! O9 e$ u: k" q4 Q         xDir = "left";
) L+ i) l' I' |/ w! C$ V' l         }
# x6 M. Z) w0 C6 Q( e0 x% \5 ]; y1 n/ R      }/ b) Y2 a2 o, ]) P2 @
   else if (xDir == "left") {
2 P! r& S; z( _! I" i3 k      if (xPos < (0 + BallSpeed)) {' D0 u, X6 [; d5 C( ]
         xDir = "right";! l- U# K3 F2 [1 S, ]* [, h
         }
) ~2 U$ U3 }# i4 I3 |- N      }
: `( D1 d6 T$ Q5 g- D) V; z7 j   if (yDir == "down") {
4 V1 B+ C5 Y  P  C      if (yPos > (yMax - contentHeight - BallSpeed)) {* m4 f. @/ @0 o
         yDir = "up";
. w6 U* I' J7 O" f' v6 E         }
. N' h! Q5 x% K$ F      }$ N* l, N3 z! a/ e0 h6 M% e7 q
   else if (yDir == "up") {. w% O5 ]' O6 [3 x
      if (yPos < (0 + BallSpeed)) {
5 `2 [0 A' ], N1 W9 X8 T         yDir = "down";
8 b) a3 u1 h$ I/ o% {         }. N% g3 X, X+ u2 `1 D
      }
: ?! ^1 z  T+ x   if (xDir == "right") {( b1 r% Y+ |" T- r' R8 S6 j4 M
      xPos = xPos + BallSpeed;
- ]2 q" H0 z7 N$ |- w0 \7 }      }
0 W5 N! t5 u2 U: c9 {! C( N! t. V   else if (xDir == "left") {
' p0 |% s% e+ y% d; S! |! M/ p      xPos = xPos - BallSpeed;, e& F# V# E! B) x* B
      }) \. W% o2 n0 h( s
   else {
! s; I2 Q' T* ?$ u      xPos = xPos;* g0 S/ o/ g0 ^& K1 \( e+ \
      }  A/ A; q' b3 n; G2 y
   if (yDir == "down") {
' K3 V+ q. E5 @      yPos = yPos + BallSpeed;
; {- Z8 a7 J; ]- V' ^# B4 w      }
' w2 H0 m; a" G   else if (yDir == "up") {- E% F5 k- a. e$ {* d
      yPos = yPos - BallSpeed;
$ H# j# v( T0 w1 k; _6 y" L" X' M8 `      }
* |6 R) H5 T# E1 h, T" ]   else {* E, k# f5 C& v. B5 r- Q) A. i9 P1 d
      yPos = yPos;
# ~  P; C* T, f0 r7 P: O2 f) M" T      }$ q# ~4 Y7 w: V8 z/ h1 L7 u# _/ q
   }! Y6 C+ g* F  L0 P" H6 E

+ I" X! C& J1 L5 v% @: \function hidetext(){" p9 ?. T3 {$ ]* U' w3 X# z
if (document.all)! o! p+ f6 b& c
supertext.style.visibility="hidden"1 Q* \) [. @8 u% K1 [; G5 @5 A
else if (document.layers)9 l2 Y" U* R1 W, c
document.supertext.visibility="hide"9 Z) I$ k8 X, B4 r3 m
clearTimeout(animatetext)
% I3 T- s, x* K. G8 ~# X}
; O) }: F" W0 s) O9 [
- h' p5 J# C- R& y+ zif (document.all||document.layers){
  L2 b! Q/ }8 u; V' _! p5 s9 qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% H3 z5 M3 @" U' b; y! `window.onload = initializeBall;) R9 t$ d! C) T) W; f! h
window.onresize = new Function("window.location.reload()");) Q) y; k6 Z* {7 I8 l- C. C5 O7 i
}
7 T/ L- I0 Q: v* S0 C
8 C5 u( d5 j. d, F  r</script>

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