返回列表 发帖

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

<style type="text/css">7 z- ?1 q8 v% I
#supertext {
5 D& _; q2 a/ N1 c1 F  Yposition:absolute;
( M% K, D) N. ]left:0;; n8 M) Z( f% o- M5 v3 `! h
top:0;' S( d6 c4 j5 w% L7 r: W  B
visibility:hide;* _! g& Q$ ?: `# W; u7 |8 u
visibility:hidden;/ ~, `" i! @  t/ h
}, T& _# I* d: D
</style>$ I! O- E  b- }+ {6 I: e
<script language="JavaScript1.2">
5 t: E/ \: y1 y% `' e1 x/ B<!-- 改变下的字体的大小。颜色-->
* W+ D! e0 ]0 B2 ~& }. d* `1 r; wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 l4 m, ^  T9 D6 fvar hidetimer='';+ N' L) k5 d) W2 @3 T, b
<!-- 改变下的弹跳速度-->
% o: }1 h" }7 K! V- G, h0 r; j) \var BallSpeed = 20;5 f4 [% I3 c! |* X
var contentWidth;2 D# n$ T. q" k5 U. _
var contentHeight;
8 u; f; @% Y$ mvar maxBallSpeed = 50;
0 G- y! A7 U) }$ D) S: j: M0 \; n0 P& a$ f" R

3 c- `; z- b" U: I- {8 vvar xMax;
5 `6 V5 q$ ]5 b. dvar yMax;+ Q$ F% J2 Q. Y- \2 F
var xPos = 0;
/ Y; |8 t: b  L2 {" Q/ ~var yPos = 0;* K9 B! `( x6 v# p5 a. ~8 k" d; M
var xDir = 'right';
/ Z4 u  h: c6 D/ d6 I8 Pvar yDir = 'down';
( C7 e( {" \7 f# u! m! Kvar superballRunning = true;& c2 A$ S/ N- y" N" q' N
var tempBallSpeed;
) O8 }# t+ I, l; \9 O& f5 g8 Evar currentBallSrc;
% I* h' ], p+ Z% U' M+ ~" C% |var newXDir;8 l# Q. X$ ~, H7 f' i% u0 y
var newYDir;
9 A& i* M" l' T6 d: w4 r- @/ h( b+ o% \8 _# e$ b& Q! T6 X
function initializeBall() {
! ~/ s' {) u+ r5 `# g0 P   if (document.all) {
( p* z6 K7 \: G7 P) z$ M: y4 W9 ]      xMax = document.body.clientWidth
0 _1 d4 o; d& q      yMax = document.body.clientHeight7 r) u9 [6 v9 R9 R4 k3 z
      document.all("supertext").style.visibility = "visible";
' ?# ]/ W1 h" W9 `3 m9 ^      contentWidth=supertext.offsetWidth1 x' W/ k- s2 J9 x# d  x% S
      contentHeight=supertext.offsetHeight
( Z9 p8 ]/ Y& t, m! J$ M      }
! E$ b7 f9 O) {- b8 W' |: z9 D   else if (document.layers) {
4 i4 f% ^* t) g: k      xMax = window.innerWidth;
6 _$ p( C" ^6 Q& g  N1 A) `; W      yMax = window.innerHeight;
( M: w6 Z! Y( q7 L( u      contentWidth=document.supertext.document.width+ @8 d! E6 R" n
      contentHeight=document.supertext.document.height% ?2 }9 k3 w4 G
      document.layers["supertext"].visibility = "show";4 c4 G8 }: N- G1 Z
      }2 R- N9 o; K% b6 \6 f
   setTimeout('moveBall()',400);# J" G  J1 a4 J6 _3 h' u- @, |
   if (hidetimer!='')
2 u# n* _6 f1 h$ W   setTimeout("hidetext()",hidetimer)9 x2 [- N& [8 ^
   }. l' ?- a6 K. Y( \0 m

0 I3 M2 V& }9 k4 P8 sfunction moveBall() {$ c& R9 T, n+ ~6 ~- \
   if (superballRunning == true) {
( \5 d5 j3 F  p% B; Q. p; B1 w4 ~1 C3 c1 |      calculatePosition();
3 D2 E! z3 p5 `# i: Y$ ~" D- m      if (document.all) {
9 ~- Y  ^& B, _2 ^- d         document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ K& W5 a6 z6 ?         document.all("supertext").style.top = yPos + document.body.scrollTop;
& F- Q5 `' k7 b: c         }/ i3 z/ r7 O( q
      else if (document.layers) {6 J4 [" |2 b2 s4 U; A& l
         document.layers["supertext"].left = xPos + pageXOffset;
3 o2 x7 x. A- ~/ S, c" b$ @         document.layers["supertext"].top = yPos + pageYOffset;
' i$ @; e$ h' @3 A8 U4 b7 B2 ]. d         }
4 u7 R5 [  X) E  Y) y& L" e      animatetext=setTimeout('moveBall()',20);
0 r7 R$ n' B5 b! g5 z* b      }( A0 w; B" D% N! P1 i6 }
   }1 w7 p& E) b0 a8 N9 k* F$ O0 J
6 \7 U, l7 {+ n
function calculatePosition() {5 @+ r- j2 T+ z) J, ?
   if (xDir == "right") {( [8 n4 U) T. @$ ]
      if (xPos > (xMax - contentWidth - BallSpeed)) {
" W4 j& ~6 g3 H         xDir = "left";
: P8 d! k) t2 R- D5 i4 I7 n/ ]         }4 P- {: _  Q7 p. i' `
      }' W* x2 [) P5 Y  @: w; J0 F' A  D
   else if (xDir == "left") {- y/ v' r8 _3 z0 X: A% q* R
      if (xPos < (0 + BallSpeed)) {* m3 p! l! j1 a% N; C
         xDir = "right";* }* S! K( J; X5 B3 X, r# P
         }& @0 N- s% q7 _9 o9 Q
      }+ j3 G5 y$ k7 p; b( @# u* [
   if (yDir == "down") {
* {+ u+ y$ W& R0 N8 U      if (yPos > (yMax - contentHeight - BallSpeed)) {
9 r4 b$ H+ V) }& m4 O         yDir = "up";
) ]3 Z9 n5 g7 W$ d- I, f         }3 d3 B4 R) x' P% B1 M
      }1 C; L' N' y! i( j1 ^/ d
   else if (yDir == "up") {: t* ?5 V) f% ]
      if (yPos < (0 + BallSpeed)) {
4 A+ v& O& ?8 g1 H2 Z         yDir = "down";
( B0 ~4 M1 e/ ]4 k  R8 P         }. b) o" u/ D7 J. p& Z/ Z3 G
      }
5 y1 E* g' _6 M* E" v3 }# l0 B; z   if (xDir == "right") {
2 a( Y9 E1 h/ t* F' i% r      xPos = xPos + BallSpeed;
6 ?) q: m) Q* j" o      }
  O! F8 W, @- v4 D0 A- p   else if (xDir == "left") {
) S4 f* m) D9 Z* O3 N      xPos = xPos - BallSpeed;
& G4 ~# r0 x2 a! {$ l' h      }
. N2 L2 j7 p! h( z' N   else {# V/ V' ]& _+ U7 F- i, O
      xPos = xPos;
7 f3 E. h- L1 X- Z      }
; ]8 e6 U4 a; u& ~- n' R' V/ o   if (yDir == "down") {9 H: o; Z/ P! e: h: P7 x3 G( P
      yPos = yPos + BallSpeed;- f4 S) A( Q5 p+ w! d
      }* g2 q2 n3 `" o% @4 E9 l# o
   else if (yDir == "up") {0 w, _! u  I% E( P6 @7 x7 Z
      yPos = yPos - BallSpeed;
3 e' X' j% z' s! C! a, p2 M      }
+ c* c$ Z% v/ r/ P   else {1 I  e% K/ m# j' q3 C
      yPos = yPos;9 ]8 e: T5 V- M" u5 d
      }
& o3 G( F) ~- s) A% |) b   }
$ C1 W- x+ b) V7 M1 L. m
9 }' h# X, b& i% ]% Ifunction hidetext(){" m. C# C# d& O# @+ u: o
if (document.all)# ?7 T1 D9 U; h0 x7 {8 |; l/ `3 A# G3 G
supertext.style.visibility="hidden"
- H8 q) o; B3 b. nelse if (document.layers)5 N' e! ]' P" C) W; T, i, v7 b  O2 g
document.supertext.visibility="hide"
8 J2 ?4 {. t5 R& \clearTimeout(animatetext)3 t) v+ d$ ?: W8 i
}: Z6 N6 m! Q, i( u" p
5 Q$ I- I) _* {
if (document.all||document.layers){
3 t7 Z0 v) k# T( odocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% z6 M# D- q# wwindow.onload = initializeBall;7 v: m3 l  H! k
window.onresize = new Function("window.location.reload()");
2 D8 J$ ?$ u2 n0 _8 y, K" {}$ ?& v5 V; p! d. x& }2 |

- {, s  n: Z& i" T8 V</script>

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