返回列表 发帖

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

<style type="text/css">- n$ g1 R. ~! l, V) A
#supertext {
6 [% U  K) G0 c4 q2 J3 i+ Vposition:absolute;) L9 U7 }4 l6 A% ~$ O
left:0;5 p6 \# F8 U% u7 P" s% N. ^0 S
top:0;
5 s3 Y: `6 {$ Z' `* _7 ~1 zvisibility:hide;) g0 m, O8 H  E1 z, O
visibility:hidden;
- G. N' {$ V9 I( |; V, }: }}
& B# T( ~5 y' a3 @</style>5 C1 F6 v/ z4 M, y
<script language="JavaScript1.2">
* e# }: \5 ^3 Y% D" a/ Z<!-- 改变下的字体的大小。颜色-->; K* p5 Q' r6 ?+ J
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': X& ^& g, L5 f  s( D' g% b. }7 E
var hidetimer='';
9 F# b2 c3 n. ?# r3 f# Z. k<!-- 改变下的弹跳速度-->
4 ^( c% H2 @0 U3 [+ H: [5 |var BallSpeed = 20;7 \8 p! V5 f4 T# x# }/ s- v2 u- D
var contentWidth;
$ R. b0 T) ~5 D% ]8 }- Wvar contentHeight;
0 t9 f7 c0 U5 ^var maxBallSpeed = 50;% o/ x3 b( q* }; u0 h3 E

5 o# y: o# {1 h1 r$ l% g  }8 |2 d/ v% a
2 e, {# }3 l$ C* a* n2 m  tvar xMax;3 I2 j, z. I/ k5 C2 h
var yMax;) a- p! ]8 G  o$ ], T' O, A# D6 m
var xPos = 0;1 V. f3 w  z1 i: z
var yPos = 0;
" u& N+ s0 a: Y0 b6 j( Y2 ovar xDir = 'right';
0 Y; I4 i& ]' l/ b8 Ivar yDir = 'down';
2 L7 G' b2 A, O) o2 Yvar superballRunning = true;  t2 T6 Z* ^& X, f( P4 g- u) u
var tempBallSpeed;
( K& ^- ?7 j7 C7 s; r! Gvar currentBallSrc;+ [, q/ I. \8 g% p) C
var newXDir;: T2 T9 `( V( M! k! d; c
var newYDir;$ I. B9 g. ?- Y

/ \  B; B. w; r% k4 m  c- f9 ?function initializeBall() {
' j- ~8 T% O  q7 u8 [* ~- ?! Q   if (document.all) {- B9 d  W5 e/ G+ s; }9 O
      xMax = document.body.clientWidth6 E# W" f  w* a1 d! N9 ]+ @
      yMax = document.body.clientHeight" `* L- L9 p1 I/ D
      document.all("supertext").style.visibility = "visible";
5 p9 M) X$ t$ L# u+ A; }* ^% D* @) V      contentWidth=supertext.offsetWidth
+ u( q5 G# i$ ~8 k      contentHeight=supertext.offsetHeight7 Y/ L# J& B' X) [8 d" d/ l6 Q
      }
0 _/ d4 `3 O1 z+ Z5 _* U( b   else if (document.layers) {
3 J2 G, i% n6 R5 b" u      xMax = window.innerWidth;+ [' u# e" D4 G$ j6 u3 `9 D/ s
      yMax = window.innerHeight;
7 G. U1 F0 Y! h3 g7 Z      contentWidth=document.supertext.document.width, H: Q  _% q& @" w$ ?2 b! Y
      contentHeight=document.supertext.document.height+ b- p! S/ e2 t/ e
      document.layers["supertext"].visibility = "show";+ |% @5 [0 [  U0 }+ {
      }
3 V, e1 S8 O, i! X1 ?' r! V   setTimeout('moveBall()',400);
+ y5 M, d0 r4 g# P1 I3 h   if (hidetimer!='')
: q) G! ^: Q1 k1 b  |   setTimeout("hidetext()",hidetimer)$ h2 j4 ~5 A  L1 B  s3 W) n! f* D  K
   }
. O% a/ ~# t* p% ^% s
; H2 U/ q, g2 u0 }function moveBall() {" v7 S+ P( Q/ w  q7 s+ X
   if (superballRunning == true) {
2 K( s/ p) u  I9 p1 c      calculatePosition();
& K# s4 [0 F" H; A      if (document.all) {
; b/ l2 G% c2 t1 F         document.all("supertext").style.left = xPos + document.body.scrollLeft;; c! h1 w# T( ^3 ~
         document.all("supertext").style.top = yPos + document.body.scrollTop;4 _+ v% f# ^) A. u7 ^6 E
         }
% ~% a6 \) [" J2 _" g( R/ J0 y      else if (document.layers) {
1 C  p4 I+ W( U9 o" ~         document.layers["supertext"].left = xPos + pageXOffset;; P5 p8 C/ Q9 Y/ N  g) V4 ^
         document.layers["supertext"].top = yPos + pageYOffset;
) p9 B4 s9 x& @" D6 A# I2 ~         }
5 T, C, j' E+ I5 W$ z( Z  u      animatetext=setTimeout('moveBall()',20);
5 [2 C5 f2 V% v, H- q9 x( x7 M- Z      }) e" p: P7 O3 G; u- i% S
   }
$ }+ ^2 P- X- g- U1 J$ x& w2 g9 w; |8 `
function calculatePosition() {
5 ]! z$ x6 x" {3 f1 L   if (xDir == "right") {( q" U3 D/ v. ^9 `4 ]
      if (xPos > (xMax - contentWidth - BallSpeed)) {2 f9 L9 K- Z- x: ?8 b5 F0 E( Y" |
         xDir = "left";! U, S3 g5 k% b; Q
         }
! U+ v7 o2 R1 l      }
2 \8 f: R9 a5 y   else if (xDir == "left") {
$ T7 D0 J- T& r8 g  ~      if (xPos < (0 + BallSpeed)) {: p# w' G5 C. C* v
         xDir = "right";
7 i  F; j! A: A3 i6 I/ j9 V! H; o         }
% @  X; x) p2 L9 U      }/ [6 {6 p) M  C& d" Q9 m5 a
   if (yDir == "down") {. S' Q9 L( L' X2 P& O- f* R& N
      if (yPos > (yMax - contentHeight - BallSpeed)) {
; C3 g, v6 b4 y0 `, B         yDir = "up";
1 H. _. q* E7 F( G         }
1 O8 M/ R* R' V      }
- K- _9 G# }; q) N) l   else if (yDir == "up") {: S* U/ P  Y9 `# K
      if (yPos < (0 + BallSpeed)) {* y3 o+ w5 R" c' ~
         yDir = "down";
, h  B+ Y4 x! \0 G5 |1 l, ~5 M3 J# Y         }2 g+ r$ n8 b0 Q1 Q
      }
8 g8 ?# G2 t  ^8 ]6 f   if (xDir == "right") {" c; Z, t5 e0 t7 d& e
      xPos = xPos + BallSpeed;
" a, I9 J! D4 y& ~7 P- l7 y      }
: q( g: Z+ Y/ u' I" O   else if (xDir == "left") {1 J  B5 ]0 K" c7 B
      xPos = xPos - BallSpeed;# C1 J' }9 H% ]- s$ ]0 |. X$ }
      }* w5 K$ m' U  f8 i$ T1 p4 b' X
   else {0 `# B2 t7 w) M7 J1 C4 p+ Y* @% V( x& a
      xPos = xPos;, L% ~: g4 l# S, V  @* C
      }
4 X0 B" h9 z! V6 p% g/ e7 n   if (yDir == "down") {* ^) j7 r3 K6 W3 ~. t  p" y' G, w
      yPos = yPos + BallSpeed;+ i* @' V& T- w6 d
      }
3 X* A' W8 M' _* L   else if (yDir == "up") {1 `" {# N8 }4 U3 I# |5 p
      yPos = yPos - BallSpeed;+ ~2 [/ b0 Q: N* d+ x
      }
- I% s7 v3 w8 ?   else {
  l; `# r. ]3 L# p- k      yPos = yPos;$ ^5 e5 I$ F/ }
      }/ Q7 b9 s, D4 l' C1 e+ `
   }8 S" F; c; E, `  T  S

- M8 D+ u- R" L; w4 \function hidetext(){4 G8 k9 L1 K8 Z9 |- u9 L
if (document.all)) k. ]4 _! A0 P$ X" ~, |5 w. h
supertext.style.visibility="hidden"
: R/ H) h9 R0 melse if (document.layers)
2 @3 H" t' l3 H3 w8 `* Hdocument.supertext.visibility="hide") ?) s( Y* g0 j. n1 k
clearTimeout(animatetext)" W/ j  G0 p0 Y: D& q9 {# N" \+ s- t% g
}
. i$ x  _, Z; g8 j& U. R
0 D- A+ Z2 o- e+ C' s3 B' G6 uif (document.all||document.layers){4 Y" q+ T" m* T/ Y3 y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 P# E+ V) U& }. M' e& T
window.onload = initializeBall;
2 V$ Z' `5 {9 {window.onresize = new Function("window.location.reload()");$ H/ z- X4 d& E! w" k( g9 [; c
}8 X$ G. X  D6 \7 B- e& e7 L

9 m; k1 H  u% g$ o- z</script>

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