返回列表 发帖

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

<style type="text/css">, X! @$ _; K2 H
#supertext {
4 c3 L8 L- O. ?& S( f; G- dposition:absolute;' W! L1 c* @( V+ j( a( [2 ?
left:0;
, a1 u; n2 K  o5 Q  T0 {, ^top:0;. k: W! F& e6 c) H8 t) Y2 |
visibility:hide;; t5 H5 e. ]+ h) |- q/ Q% S* O
visibility:hidden;( h" ?( s" n" ~3 S% c
}3 X$ ]3 ~' h' q* e1 w3 t2 p
</style>
. J5 q% Z9 f* }<script language="JavaScript1.2">. S3 a' W# L4 K, K7 f& Z) Z
<!-- 改变下的字体的大小。颜色-->
; a) E5 r5 W- C/ R. qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% ^5 s# P' ~& }$ Q: X2 W2 rvar hidetimer='';9 W5 X# A: c* k  c
<!-- 改变下的弹跳速度-->% M/ r! Y* C' Y' h, r7 {9 C
var BallSpeed = 20;/ j: O7 b3 F# E$ z( s# g! e
var contentWidth;  l9 w) ^+ e7 m' ^2 {2 @
var contentHeight;* n7 K2 r; Z# M% e
var maxBallSpeed = 50;7 g" s6 D: \) s# l& [' t

# \+ [' F- W8 N' e
# t) g! C' c, U* T& M/ B! l+ Cvar xMax;
# \- ~9 ^# }. P3 Z) H+ J3 p2 dvar yMax;
- [5 h0 \. w) Q1 J3 f& N+ c6 L, Zvar xPos = 0;! f2 k% p. a* X, m
var yPos = 0;( h1 d8 @* R# t/ c
var xDir = 'right';
* m' J  I2 u6 w8 nvar yDir = 'down';
7 }; }0 ^$ V$ @  W' Q8 C9 tvar superballRunning = true;
) ?2 ~) F: G7 R3 _. g& M; h! C2 avar tempBallSpeed;3 }6 v, T7 g+ c3 ~
var currentBallSrc;; H% w" s7 {5 d- R/ a; _& O6 \
var newXDir;
4 {/ G7 @' ?% g8 h1 H5 y" Y2 dvar newYDir;3 B) G  ^/ c  {* C, g
/ g1 o/ N! k( C8 v$ c- N" I
function initializeBall() {- I: Q- k6 _; C
   if (document.all) {7 {8 ?. K! L7 N1 S, S! K
      xMax = document.body.clientWidth
+ f$ t$ a- s0 I4 P1 U+ b, m      yMax = document.body.clientHeight
5 Q7 e- q* h$ R/ h5 E      document.all("supertext").style.visibility = "visible";
# ]* a, d! Q0 n, ]      contentWidth=supertext.offsetWidth
6 y. S) {2 T1 f      contentHeight=supertext.offsetHeight- Z7 u- c2 P: d' a4 \! U# E
      }  j; J$ F- C; ^" [
   else if (document.layers) {7 L& V- I& x/ Y. l; h( x
      xMax = window.innerWidth;5 j" Z  L* ?/ i: F! Q& E
      yMax = window.innerHeight;
: `" g) |8 t& R5 G# N) G2 @      contentWidth=document.supertext.document.width
7 S0 l6 V8 A( b; R' V: g3 V      contentHeight=document.supertext.document.height
; Y) d* a7 \) o) g      document.layers["supertext"].visibility = "show";% W5 [4 r& h. w$ J8 c& {/ g
      }
; f7 x  G$ \+ s* m  C6 G7 V1 }) J   setTimeout('moveBall()',400);0 |  @' b' s; V1 s
   if (hidetimer!='')8 O) F) o! b9 F
   setTimeout("hidetext()",hidetimer)
  B6 q% B$ }, O   }
) b$ Y& k6 D5 C. v$ l8 ?8 h
1 k2 k% U* ]' @7 S3 [function moveBall() {
& D; x& E" W) K- d7 P   if (superballRunning == true) {" G+ l# G' }" Y- G" s& i: u
      calculatePosition();5 }; F4 A) }4 a0 W
      if (document.all) {
/ d6 G5 W9 V( \& e% g5 E6 o8 l         document.all("supertext").style.left = xPos + document.body.scrollLeft;" D2 Q4 E4 W5 r5 B) W6 D0 E
         document.all("supertext").style.top = yPos + document.body.scrollTop;4 F# U, Y, d# _; d6 p, D
         }) {2 b( z+ `, G5 N; A4 P* B0 b
      else if (document.layers) {
* T* i% C. l# S$ O  T         document.layers["supertext"].left = xPos + pageXOffset;) U, F# H& a# C0 i8 @  s
         document.layers["supertext"].top = yPos + pageYOffset;7 @% N7 B6 r& F' c
         }! ~/ T$ u9 R3 {* ]. ~
      animatetext=setTimeout('moveBall()',20);
8 ^, D6 n8 X% q8 N: g      }
! j% J) Z: y& _+ m" u0 H   }2 ^+ w+ r, y) H
& m1 |* y$ h& q$ E4 A1 b
function calculatePosition() {: L& H# m) T, O- x
   if (xDir == "right") {
9 n1 d2 e/ J# F0 c      if (xPos > (xMax - contentWidth - BallSpeed)) {
: c! Q$ C2 A! v4 q- T( X; V         xDir = "left";4 h( S$ Q7 f6 ]5 C+ p9 }" _) k
         }6 E3 r, s- S  p. z1 p3 N& B; h! z
      }
8 P7 u) u: k* f# {" G6 i! H- P   else if (xDir == "left") {
: t1 `) a# M" T! H      if (xPos < (0 + BallSpeed)) {
: T/ E! r9 W& O. y: S1 y         xDir = "right";& e7 r/ F% U7 \6 R: x
         }8 M: f  |. _/ h4 _2 \! _1 c2 Y
      }. J9 s3 C" i  V$ u" P& X
   if (yDir == "down") {
8 M1 O" p- g/ I% }; j% s      if (yPos > (yMax - contentHeight - BallSpeed)) {
2 H4 i7 ^) H4 d# f' \/ R         yDir = "up";# R; r; ?9 l; S. @3 ]0 l( f+ C: T/ f
         }
7 @3 y' H1 c" h3 r. S( X7 {) Y: @      }
5 N) ]- \2 S" A$ `) e# n2 v, o   else if (yDir == "up") {5 c% T3 `' {( s# m
      if (yPos < (0 + BallSpeed)) {: }9 S1 w9 d  A$ a
         yDir = "down";2 i9 w) i( x9 k+ ^* J. V  o$ N
         }
- |6 Q1 D5 P1 e- Q3 l& J) d      }! V) ?8 m3 \; D4 R/ }
   if (xDir == "right") {. J* F7 d# A$ X6 [* ?* J7 n
      xPos = xPos + BallSpeed;
- S3 w3 _1 X& ?- q      }2 E' I! g; S6 A+ h6 z- R
   else if (xDir == "left") {
$ `9 ~5 a6 p5 @5 E7 ~3 \      xPos = xPos - BallSpeed;
( y5 @" v1 }# i# e1 u- P: h      }
3 p3 V3 r* }( w& p2 n3 E   else {5 @& G' |/ _# J8 P
      xPos = xPos;6 F2 ?! I5 }  R3 |5 c# M
      }7 R) `6 A- A4 U( N
   if (yDir == "down") {
9 [1 t. m2 |$ q1 Y      yPos = yPos + BallSpeed;, H3 ]$ @$ b) C
      }9 g# R) l  n; K
   else if (yDir == "up") {, u% c# f# p1 S
      yPos = yPos - BallSpeed;
' J9 ?' a* {+ ^* z* w$ L6 a3 Q' P      }7 {/ R* X/ s; w; \- e2 ?- R
   else {" v0 R5 n- Z6 y5 V& o" ?7 g% @
      yPos = yPos;5 L, K1 a8 t: y. P' a- B1 ~
      }$ F0 V" t5 U. w9 X- ?
   }
0 p7 ^  p4 ^7 @3 \- ^* Q! L/ G. ^& S, U
% O: @  x3 V3 f% y1 l; S' Mfunction hidetext(){; Y, Y; K" A) G  d' {$ I2 K& \
if (document.all)
6 {! h  P' Q- Qsupertext.style.visibility="hidden"# y$ A1 E) L1 b4 x
else if (document.layers)
" i% p$ b/ z8 f$ Wdocument.supertext.visibility="hide") m5 v+ J* |7 S
clearTimeout(animatetext)
/ g: d) c  H+ K}5 Z! U7 w9 `9 P$ P6 J

* v% f' g+ R6 P. s$ o  O6 @8 F5 E' [if (document.all||document.layers){  a/ H9 C8 ~7 F+ Z" Z6 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 }+ t) ~2 U+ {; N5 Ywindow.onload = initializeBall;
: _8 [* b" S' J. Z5 r8 M% U: fwindow.onresize = new Function("window.location.reload()");
; o; o! Q& {  \( ^; Z}" o+ j! e+ F! _, F

; Q7 u( [' k  }/ `1 h' Y</script>

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