返回列表 发帖

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

<style type="text/css">
& t; P, w. {1 {* q#supertext {% [4 ~6 D/ S% v# j' G
position:absolute;
3 w7 B% a  e) w6 z( C1 Xleft:0;
# y& g% w( h4 r# {: z/ t; U' htop:0;
! w( A+ M8 {( k+ }! ?visibility:hide;
0 Y/ L& }1 L) C( V4 _visibility:hidden;$ H( T' K# ~" y9 d
}
+ ^( D+ _6 z7 Q, h2 v5 X</style>4 T; ~& ^% V  F3 W+ X5 ?( i9 D0 w
<script language="JavaScript1.2">
9 H4 E, ^$ ^! u! z' q<!-- 改变下的字体的大小。颜色-->2 o" e8 `; y/ g: s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 s! `. c: A0 r, O
var hidetimer='';) Y+ K8 [8 A, d; I
<!-- 改变下的弹跳速度-->8 T' @0 y2 @( ^/ F9 \
var BallSpeed = 20;
7 z! a. E; @! `* j/ I/ \  j. |. ?, S5 avar contentWidth;
, x1 N1 ?8 k' h6 Q: d6 w) Zvar contentHeight;& d. Y/ ]1 H& F8 h7 R' ^
var maxBallSpeed = 50;/ n/ E% e  [, R2 X

3 g4 _4 B1 P. a: \3 ~7 k: g8 w7 P9 s. i8 n! L% z( O0 c
var xMax;
. k: `  d+ _- J( }var yMax;, }/ {2 \  z6 y2 C0 j% j( F8 Z; _$ x
var xPos = 0;
9 X$ D4 k; b( P/ T' Q9 y2 V- z5 {var yPos = 0;
& @0 [9 B# V! c8 _, [1 t  W8 @. tvar xDir = 'right';
, b: `0 o+ U6 [' svar yDir = 'down';( E* n1 ?$ f* i8 l3 [8 c
var superballRunning = true;+ ]0 l$ g- R0 ?' j+ g& C
var tempBallSpeed;3 p, `' A6 C% b+ R
var currentBallSrc;
2 `  j% W* j) t0 V5 u3 B# @var newXDir;
$ k: ~3 v" a/ x" Mvar newYDir;3 m( z) k& U; Q4 a3 s# K" ^% `" [

% x" j) \7 {9 Vfunction initializeBall() {
9 A+ v+ h3 S# a$ }! l   if (document.all) {
8 R- g7 X6 O3 m; \7 {5 {      xMax = document.body.clientWidth
3 Q# |) z+ z. o8 y      yMax = document.body.clientHeight
8 b2 h6 H% ]* e- b      document.all("supertext").style.visibility = "visible";6 h+ f. F; @! P, v: O# S
      contentWidth=supertext.offsetWidth
, b4 R+ ?" I! g* c      contentHeight=supertext.offsetHeight
7 a$ R! m# r7 j; R8 |+ ?2 N      }
5 W5 L! b7 o; E& \   else if (document.layers) {, k6 A/ T/ m* O5 O* P
      xMax = window.innerWidth;4 C( G# X  _5 d+ x
      yMax = window.innerHeight;
8 {& _( m, h: Q" ~2 w" }      contentWidth=document.supertext.document.width
2 ]- q( N: T8 ~7 b% Q* j0 ?: f      contentHeight=document.supertext.document.height, C' t( x$ L- g/ O5 b
      document.layers["supertext"].visibility = "show";4 [( x; t6 |7 f) l9 T
      }
0 u! ~4 G- B; l7 f* m2 V   setTimeout('moveBall()',400);& Y1 L, O3 [* [1 A3 ~
   if (hidetimer!='')0 \4 X! d' Q& x8 f4 p" u
   setTimeout("hidetext()",hidetimer)4 o0 P: P# d) t- L0 ]
   }9 r; @( a( {2 V6 ?! t6 z

9 s0 b( I; C- Q6 a  wfunction moveBall() {
) @- H9 n) @$ q, o1 Y: X   if (superballRunning == true) {/ j( \4 @# }. x+ T* x
      calculatePosition();) s- v3 C% r" _; K$ e7 l. S/ l
      if (document.all) {
$ [2 N4 Z  M0 @: a* y% }3 m         document.all("supertext").style.left = xPos + document.body.scrollLeft;) E; V- [3 |/ V- V1 R  l& h% O  a
         document.all("supertext").style.top = yPos + document.body.scrollTop;
$ m5 M2 O0 h) N) {         }. t" j& \! u0 H! E( I: G; L& }
      else if (document.layers) {
6 T! L6 {% r% F) c& C, @         document.layers["supertext"].left = xPos + pageXOffset;$ O+ x: A% `8 K! K( Z/ s5 r
         document.layers["supertext"].top = yPos + pageYOffset;# O- Y3 U( o1 m% V
         }
8 N- w9 _  A  G8 U2 H( a! ~7 o      animatetext=setTimeout('moveBall()',20);" I# [7 N; X: Z) E
      }
9 d' l4 n% K- M& b   }" b  f4 ]# B. }) }7 w+ R

: O! e; H' d9 ~8 Q* _7 U. e4 }( k2 kfunction calculatePosition() {
1 T1 i! ~6 J8 E9 `0 s4 `- d$ w; ^   if (xDir == "right") {
2 y" o3 J0 k! ^# U2 F      if (xPos > (xMax - contentWidth - BallSpeed)) {
; o' ], r8 V0 {$ Y6 A         xDir = "left";9 T9 o* k& J8 ^" a* R9 a: `
         }$ s" V, J$ X7 D( O. f
      }
- Z6 i% {1 ~1 T) p- @   else if (xDir == "left") {! u" e& r% u' K9 j
      if (xPos < (0 + BallSpeed)) {
* ]/ g# T( S* r0 |         xDir = "right";  e$ z7 W( q* z4 R5 Q7 S- Z
         }
' Q8 x' U  r' W, e      }% ~0 A  }8 t2 }, S5 t
   if (yDir == "down") {
2 c  H# \: W3 P2 K  R; y+ }9 U      if (yPos > (yMax - contentHeight - BallSpeed)) {# E: G, I; [+ f8 v! B- b9 h" y
         yDir = "up";
! z$ F- k9 b) h5 o. I% Y         }
; v8 H! E" U1 W  m- ^      }
5 q, R3 y5 F+ e) ~. B   else if (yDir == "up") {
( Z; S% y2 [0 L& b      if (yPos < (0 + BallSpeed)) {! Y5 f0 j8 a: Q1 {9 C! L0 v
         yDir = "down";4 C* A; j: X5 b' H; ?. V
         }$ K5 F- l2 h' C* ]& b  i
      }8 ?, m  A& }0 i- S
   if (xDir == "right") {& U0 O, z7 k0 y
      xPos = xPos + BallSpeed;' s. N. d, L$ _
      }6 U/ Y& A9 u  B1 s
   else if (xDir == "left") {1 m$ k7 b9 Q) y7 ?/ ~5 H
      xPos = xPos - BallSpeed;
$ q5 V$ h$ a) V+ E/ T      }9 ?* }: O$ d) W* W5 A" B7 q
   else {
; ?+ a2 n( G" T# e2 x6 i      xPos = xPos;, e# t) r. [* [  }1 r2 O
      }- G; a3 N, R7 {+ G; g
   if (yDir == "down") {
( G: L% _& C5 _) P( F      yPos = yPos + BallSpeed;
' x  y+ s" W. T2 o) E7 I) `6 w      }
- @5 }+ r$ Z: H. B3 ]% V; s   else if (yDir == "up") {; [0 U) l: Z* a7 ?- E  Q9 K
      yPos = yPos - BallSpeed;9 C& O% a) Q8 F* W) G
      }6 R5 [+ S+ f/ X- M. k. P/ T7 ]
   else {
& ^& ~# U- Y+ d7 e5 z8 n6 r' u      yPos = yPos;4 T3 u# |0 r, P5 z' I; c
      }
) Q0 d9 M% a' Y7 k# P   }
2 d' K; T6 g2 o; u) f% ^& e+ M, E& |( x
function hidetext(){
2 X8 _: X* M% T) Mif (document.all)6 {1 d- W$ }# R
supertext.style.visibility="hidden"/ V/ h3 a7 P7 ~# a* `7 J% k
else if (document.layers)
" t" k2 I" R: a$ K6 Odocument.supertext.visibility="hide"
) i: E9 S, J& _4 k2 Q9 W  Y+ d& Q2 xclearTimeout(animatetext)
  B; C- L2 E+ z& v5 c  t}
8 }' r* g6 E: K  c, j* E* j) L3 t7 f2 O6 @% K. P) l
if (document.all||document.layers){
, v  _6 m& h' s- P2 K$ `+ ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')* @0 y) ], X5 t+ C
window.onload = initializeBall;
" c6 m' e1 ^) H+ i: rwindow.onresize = new Function("window.location.reload()");) {7 G5 L9 A: U' Q2 K' ]1 A- B
}
# {& E! n; Y. ^, y% c% _
, ?; s  G6 c$ e( K</script>

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