返回列表 发帖

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

<style type="text/css">
5 n' U7 f  i) R8 D& F) A#supertext {" X5 u9 A+ u9 `, A
position:absolute;
1 G: T6 L' G$ v# h# H5 \left:0;
9 I7 h, e2 z% \3 ^# Z5 f! Ntop:0;
: \( G% q5 W$ G+ P+ H7 gvisibility:hide;) o% K$ N4 |& W8 j( D
visibility:hidden;
% q& Q8 a4 |5 z  [# B& z. P6 v}8 s+ @* H! M; }. H
</style>
* n. r# S. u& b<script language="JavaScript1.2">) q! e  C# T2 ]+ t# a
<!-- 改变下的字体的大小。颜色-->
$ f: V) l; L4 M* z8 k# Uvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 Q2 E& H' F1 Fvar hidetimer='';8 Y6 A# r) ^: B2 Q. S' \/ w
<!-- 改变下的弹跳速度-->, W5 U4 Z9 z' k9 ]. Z
var BallSpeed = 20;0 h6 z# j8 M4 v6 Y( k
var contentWidth;
5 M- D# x7 p, yvar contentHeight;& K; @# }5 D* \) V) K3 F
var maxBallSpeed = 50;
4 n8 x/ |* g+ `5 W' D7 o, i( c' R2 f
+ `5 h9 |5 k' S3 @% P1 G$ m9 C
var xMax;
4 L2 X/ h+ \8 V- N( E8 ovar yMax;
" N" }7 a  y/ W1 C4 R4 Evar xPos = 0;( N# |: ?, m; \3 x) P8 U
var yPos = 0;
* y7 X# R# r) S1 B$ ?5 W2 h( rvar xDir = 'right';2 l; H: b6 y7 z3 @! f; d$ E- I
var yDir = 'down';
  z8 F: @6 y+ R3 A7 ]var superballRunning = true;4 ^: B- j, M1 R% m8 k9 w
var tempBallSpeed;
( x% k' x; I4 |* wvar currentBallSrc;2 x$ g% ~% |/ H7 L! l4 g
var newXDir;
& [$ f, w) ]/ h  m3 K( nvar newYDir;
- B0 _3 I5 E( G0 }2 [% {; z: `% A
% J% a7 u8 n3 ~# P+ U5 Bfunction initializeBall() {
: V1 t3 @# o5 B4 h! P/ g   if (document.all) {$ e$ `- f, w6 p7 z7 {6 I5 r- b/ W% R
      xMax = document.body.clientWidth4 A  o+ r# F% G/ V* n# P, B/ R
      yMax = document.body.clientHeight
$ H9 U5 k( @6 ?1 v2 V      document.all("supertext").style.visibility = "visible";* t& z! H9 }8 d% o3 I
      contentWidth=supertext.offsetWidth
1 b' X' X) k, C' k      contentHeight=supertext.offsetHeight
2 ^- ~: o6 J) W! z. T/ B7 ^      }7 ]+ B( c0 A& M' _% R
   else if (document.layers) {
1 t% }- D2 X) S$ j8 R      xMax = window.innerWidth;
& v1 Q7 k, B( B      yMax = window.innerHeight;
3 N. s* P4 F0 O/ ?" X+ R, P      contentWidth=document.supertext.document.width1 n' x: `; O; C( |3 o& S
      contentHeight=document.supertext.document.height
, v7 L$ O/ T+ G& n0 h. G      document.layers["supertext"].visibility = "show";
8 j3 D1 ~! \6 |, T3 Q, \  b! ~      }) o* G1 U1 V1 I" o# }" [& H7 y
   setTimeout('moveBall()',400);
# ^5 w( e  x* T5 J/ _' d   if (hidetimer!='')
9 z8 }$ |3 i. W+ ?9 `; d- x* k   setTimeout("hidetext()",hidetimer)
2 P. D, [3 L5 A+ w0 l; U   }1 e9 n7 o0 ]6 ^5 t

- I# u( {5 h8 I! t; R+ h% Z; Mfunction moveBall() {* M% ~/ ~" Z  Z- u0 U" R+ a
   if (superballRunning == true) {+ W7 {: s  J& @4 U  v. N
      calculatePosition();
3 I1 w; d& S% t$ y( x- X      if (document.all) {
( h+ Q# K. h4 f- ]/ _         document.all("supertext").style.left = xPos + document.body.scrollLeft;
3 w( N- q9 G% K8 ~' ^; c         document.all("supertext").style.top = yPos + document.body.scrollTop;
' Z7 g# b. v& \         }
3 q4 d, ]# e+ V      else if (document.layers) {
9 e! ]3 r3 [; _6 q8 V         document.layers["supertext"].left = xPos + pageXOffset;2 W# R  X  [" J% l+ P" _
         document.layers["supertext"].top = yPos + pageYOffset;" F: v& X# f5 J' |- [
         }
7 J( }7 H; t, T2 g+ K      animatetext=setTimeout('moveBall()',20);
+ S; Y; x3 }. d9 i2 \) k      }
. N0 }4 ^% G5 M1 F5 A$ N  |! Z/ a   }
% ^' M3 q4 j9 G: E- ]7 w% l+ k% O1 \
9 {- D7 e+ l' y1 G7 ]function calculatePosition() {
7 l1 N, q, ]& O8 f" R   if (xDir == "right") {" ~: v" b: I6 m+ B
      if (xPos > (xMax - contentWidth - BallSpeed)) {
3 B" c- U1 e/ y- R; D2 E7 p0 E% f         xDir = "left";
7 i9 R+ m) d+ m% x5 j( N2 v         }: |: u! O9 i8 [1 n% J( w8 t/ k$ C
      }
% R: S# N% i" W* p" c7 g: @" N" j   else if (xDir == "left") {  \5 N- n( u9 O. k  x
      if (xPos < (0 + BallSpeed)) {3 [! v' D. \6 _1 o% g" k; v9 ]3 U
         xDir = "right";0 B: t1 L* k6 _0 Y$ A( x' _- n$ K
         }* p9 M& V4 H0 R( s
      }1 K4 N; R1 n( t. U# o5 z) t
   if (yDir == "down") {0 ]/ s& R+ }; F8 @* ^
      if (yPos > (yMax - contentHeight - BallSpeed)) {
" m1 M6 o# m9 u! K# l0 u         yDir = "up";
  J4 n& D1 z! X2 s# s- \) `3 ?         }! \; r: {4 u) p
      }0 e- F8 {- t$ t* E% s
   else if (yDir == "up") {
& b$ K8 {$ d. h) G      if (yPos < (0 + BallSpeed)) {& M/ p! W" Q9 K
         yDir = "down";
2 N( J8 ]  M1 J* t- Y" k: c$ t         }6 G% c2 h' F3 B, E/ A9 |$ k+ ]
      }
' f" P" M8 j% d7 W( |- c9 o: [   if (xDir == "right") {
2 |: M+ W0 l9 k; }' ~( t      xPos = xPos + BallSpeed;6 A6 ]' X/ Y3 Z3 p5 c
      }
: U! ]) ^" Y$ n6 h   else if (xDir == "left") {
/ X$ L" n$ |" q; T1 d      xPos = xPos - BallSpeed;
: p8 I+ V& k4 f7 [- b      }
) }, v+ v4 F7 j: Z5 B# L   else {8 C* l0 q. w- q+ |( G& Z
      xPos = xPos;* W+ H- t' ~, |1 j3 F: E
      }
& i  a8 f7 X+ T   if (yDir == "down") {
! Q) J6 L3 S; A      yPos = yPos + BallSpeed;  E6 g7 x/ D0 ^9 B/ _
      }% |7 u7 O& S& f3 d* J
   else if (yDir == "up") {
  p" }7 H( i4 e1 p3 l      yPos = yPos - BallSpeed;
. T# z( C1 H0 v$ Y4 `& k      }
: K. z+ s, i1 ]+ w/ ?/ K   else {
  u) u3 L/ Q# l3 ]      yPos = yPos;
' w  ~; j' N" R( W! k- Q  o4 Z9 C) e      }" j% l% u8 ^% @! Y  b, z0 L
   }( R% |, i# W: a& |: A

+ F5 V' x( Y. y- ofunction hidetext(){
$ U3 o) S( _" C8 H  O+ Q% P9 Vif (document.all)
: V) h& R  Y1 A- T/ csupertext.style.visibility="hidden"6 C/ `7 @1 r6 B# @) ~; q
else if (document.layers): A& I4 O* o; f: I
document.supertext.visibility="hide"
; Z0 V, b* }# |9 |+ gclearTimeout(animatetext)8 N; `& e7 A7 I' k" _% E; q
}: j! S/ D" o) l7 @1 y* L( y
! h' [8 [" ^& |. B6 }% d
if (document.all||document.layers){( X% y* o2 R: E9 R# z2 L7 ?- F7 c5 ^
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 l3 n/ y; l7 u  K
window.onload = initializeBall;& t. [* g& e' ]
window.onresize = new Function("window.location.reload()");6 E: g7 }: B  i+ N. F* @1 P
}6 n# O7 M# `6 Y$ I& c9 M

* Z6 ]/ g4 m4 P3 M) |</script>

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