获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">2 g3 Q0 s; M+ U( T+ n/ @* ^3 y
#supertext {
3 g# F4 G- p) w4 N; a! Fposition:absolute;2 w% |! O) a9 s' H# G
left:0;; ]' s4 H. n. `0 Y7 P5 H. C, q
top:0;
. l$ K! S3 u3 {; r; r. m1 A; B* lvisibility:hide;
& {! _( B$ r9 m3 W" ]visibility:hidden;8 E' S( m- N. J# N/ j
}
3 v' r. k( F5 p6 o3 A</style>" D0 x  H5 D6 A
<script language="JavaScript1.2">
4 g4 A0 @% |) h" W8 G<!-- 改变下的字体的大小。颜色-->
0 ~6 z- v0 k0 F1 S; f- {4 Cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& {5 t; d+ _- e; @+ Q
var hidetimer='';" G; i. Y, o* W
<!-- 改变下的弹跳速度-->' s2 Z+ s7 Z5 x1 y
var BallSpeed = 20;# Z6 C% w: N$ a/ C9 T' P! c! }
var contentWidth;
8 o9 b9 ~' L. J4 m0 G8 O6 n: X/ Xvar contentHeight;' M* v- W5 k0 {/ ]& T2 r3 h
var maxBallSpeed = 50;/ u+ F8 U- m0 X$ V4 h  w

9 d1 h# H9 i7 B7 L. K) _" o+ P
) K. T4 g: D  Q% M& I* _7 P8 _var xMax;
& z% \0 B' O, i; e  P9 r9 fvar yMax;
" t; J3 k5 t+ Q: G! v, c- ^var xPos = 0;
7 Z$ O0 z8 q, b, ]7 A: h2 J# Wvar yPos = 0;8 u+ q  N+ B% j1 W& U
var xDir = 'right';
( F+ _7 q4 D, o4 p3 p( ivar yDir = 'down';/ ]9 D6 H2 u4 P8 r+ x2 _% |
var superballRunning = true;
1 q- l4 K7 n' j( z& {/ kvar tempBallSpeed;# W+ w) r+ p2 R4 l7 d
var currentBallSrc;
5 Y  o& u/ _! ^% b  {var newXDir;! ]  u# |2 {' Q/ z9 T
var newYDir;
( u1 M& U# c' |5 b. c' s  I
& {5 f5 j7 y( p) d3 I3 u! lfunction initializeBall() {
) f+ ]/ o1 L8 G$ }- ^   if (document.all) {# \( a8 W5 M! R6 M
      xMax = document.body.clientWidth
- Q& _* }6 |/ k  k9 b+ Q      yMax = document.body.clientHeight( N' i; x- x) l' X
      document.all("supertext").style.visibility = "visible";
! v; b- [6 m- N) _4 i3 X      contentWidth=supertext.offsetWidth
% Y# s9 S3 T; l/ b7 D: x      contentHeight=supertext.offsetHeight
  A0 M* Q8 t( E9 q) [  S  |      }( c, R$ g: }3 O$ m& v- S' p
   else if (document.layers) {& n) D' y6 J4 F+ {; f
      xMax = window.innerWidth;
0 {2 g5 R) U6 J3 h8 G9 L/ t      yMax = window.innerHeight;
; |* g8 W6 ^, s1 J  r" c      contentWidth=document.supertext.document.width* ?1 ?1 M0 c# H9 q
      contentHeight=document.supertext.document.height9 V1 w0 S3 c6 Q' }9 b( l% r
      document.layers["supertext"].visibility = "show";0 i" h3 G" l; ~' T# c5 a
      }
! ^$ h. M" q* y) `   setTimeout('moveBall()',400);
+ m: B3 \9 M3 \   if (hidetimer!='')
8 z& T+ T6 H# K; c) w/ ]' x" o   setTimeout("hidetext()",hidetimer)
7 n$ A% v( t% U  d& x* d   }# i7 P* M* `' t' q0 L1 A" n/ G

. c" s* d# e- U/ s: [function moveBall() {
. M# g: I/ U! r   if (superballRunning == true) {
% I; N! x* o% H      calculatePosition();
  K  V) Q$ a( v: [& ?/ y      if (document.all) {& q* K. N  ?" R: q$ d3 @# c
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ j! \, V% O" e) [% }         document.all("supertext").style.top = yPos + document.body.scrollTop;( n. \! l* l, x' s
         }
  s4 @# U9 V8 h      else if (document.layers) {
6 H9 l/ J! H1 F& s& O/ O         document.layers["supertext"].left = xPos + pageXOffset;: Q3 b7 S5 x: f8 v
         document.layers["supertext"].top = yPos + pageYOffset;
7 G6 B: m* H! M! e) Z1 m6 U0 F         }" o& h" z( M8 @! {8 o5 p' O" U+ J
      animatetext=setTimeout('moveBall()',20);% S0 j* |4 a6 k- b2 u6 l& ]
      }
" w3 I6 \8 ]) S  V- h/ \3 I   }
3 C" G/ q/ d0 H* Y+ _) u+ d. N% K1 ^2 ?
function calculatePosition() {* V6 Z: b5 E4 z- c) d, ~) y) \, g
   if (xDir == "right") {2 {1 ]- ]0 F  j, D6 ?/ A
      if (xPos > (xMax - contentWidth - BallSpeed)) {" c9 ?! k  ?, N
         xDir = "left";
- K. \+ o9 T( |/ h5 o         }* f9 l4 Z3 R. s) z3 g. ^
      }
& g5 ], x* l% x& f1 O9 O   else if (xDir == "left") {& M, s3 S: [' W  O0 b6 H  B5 n
      if (xPos < (0 + BallSpeed)) {
( p% N0 y. A+ Q4 r         xDir = "right";
9 A! O$ W/ ^" i  B$ r         }$ X6 f/ }  M, K" _8 ~. I: [, T( n
      }
& I. H5 \; e/ [# B& g! n0 r% l   if (yDir == "down") {# w* v( l' k0 E6 R: ^
      if (yPos > (yMax - contentHeight - BallSpeed)) {1 \/ \' d( v7 R( V
         yDir = "up";. O+ X- g$ Z1 g& r* u4 m. r0 l
         }
: ?# B. x2 T; x9 q; k% \      }( \1 H+ a+ T$ ]
   else if (yDir == "up") {0 ~8 l4 N, s* n& h/ L
      if (yPos < (0 + BallSpeed)) {" o2 x9 N7 \" X7 v, C7 K6 J1 g8 T
         yDir = "down";& |7 ^5 _7 `& j9 ^9 @
         }% `9 s. K) P: x2 Z# p
      }. E: H5 k% p9 I
   if (xDir == "right") {+ i# D  C- y: |& A3 |. K
      xPos = xPos + BallSpeed;5 o7 Y' Q% t  _# W+ K5 f
      }$ z" T6 T! J6 C. W
   else if (xDir == "left") {
+ X" J" F- A/ r6 X      xPos = xPos - BallSpeed;
1 \7 O9 N) ]% t% [+ E      }$ q# G% w, q  E' ~$ }: K8 p6 T
   else {1 E0 n0 V; b+ C$ Z( H) I8 N+ p
      xPos = xPos;
  ~* ^; Z$ K( p      }6 R! d- G" d8 W2 W
   if (yDir == "down") {
: o2 c* C7 u& I; w% n      yPos = yPos + BallSpeed;
1 e* K& d7 u6 `2 b+ L5 M1 Q/ P      }
& M5 b  V1 E4 u. `   else if (yDir == "up") {' G  v4 ?& [$ i
      yPos = yPos - BallSpeed;7 ^. L! Z) j: X; n
      }4 O. ?- B# s( k
   else {
& P$ x& D3 D- C9 h) f: a0 G      yPos = yPos;
- Z& v6 v- E+ ~4 {      }
$ X! Y7 a0 K$ `  ~   }* U  R/ n4 }# w$ I9 e
* P1 P: e$ V. d" i4 [
function hidetext(){
; r2 t5 w  D$ H% P; lif (document.all)
$ u- X( J. }3 @4 x" {1 tsupertext.style.visibility="hidden"
5 ~- _2 \! k6 ?% i' y( @else if (document.layers)
  H- Y  @" J$ ?/ Cdocument.supertext.visibility="hide", q! {: ^* Y& h" c* h! O! f1 }0 k
clearTimeout(animatetext)$ L+ q3 n* c5 c: z8 U  `+ M
}3 x* ?7 T) f* b

" x) @- {; I9 P0 {# y. C/ Qif (document.all||document.layers){) F! ?- N6 ^7 C6 V+ S+ @. u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  f: E* V8 q* W7 b# kwindow.onload = initializeBall;
: K7 [5 ~. r; F# Zwindow.onresize = new Function("window.location.reload()");
) P* n0 ~6 b! M  c}' y; J0 h5 u+ B& e, t; h
" X* r$ |6 R! y/ ^" q# m
</script>

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