返回列表 发帖

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

<style type="text/css">- |& o7 G* i" X7 R& \+ |
#supertext {) ^! a& U! [5 N  B, E* A- @
position:absolute;. t( M# d& ?0 P' D- a
left:0;: M* u- O; O; G5 O' j
top:0;
) K. H  v1 w8 R% k0 B* n/ O/ Fvisibility:hide;
/ x  p! T- t2 Lvisibility:hidden;. o0 V0 ~* ?" H+ b
}' \; D6 ?2 d( y6 Z7 x( Y, J
</style>9 ]( o# p% j4 g) T+ D2 R; \9 f7 ~
<script language="JavaScript1.2">
! `  o  U( Y1 {, I' D) X<!-- 改变下的字体的大小。颜色-->
  v2 ?5 d4 s) F/ x5 B9 Lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 L0 E/ A! m( v9 Y9 u- X/ T  W  H
var hidetimer='';
$ t  d6 N5 G' R. N" c" Q& Z" `<!-- 改变下的弹跳速度-->; z: V8 O. [' m. p0 j7 _! n
var BallSpeed = 20;
- e4 H: V8 f; ^, ?% {' a' Nvar contentWidth;0 [5 A' F( N) j! R. c  r0 `; A
var contentHeight;
/ B# O" a4 q/ D0 ]+ E" q: k2 o6 b/ Fvar maxBallSpeed = 50;
5 J5 r+ w  |5 @" N
8 ]/ W7 ~$ F0 @* A) s& u9 E& [, q; @/ J6 ^' t+ @2 X8 H0 ]
var xMax;
) d1 t7 Q- S+ @var yMax;
9 T2 z- I4 V: Q! \, l4 K! q) Wvar xPos = 0;1 P6 J% Q) a' P: Q( X; k. l& w% H
var yPos = 0;
4 ^( }' O0 w% A# K% Nvar xDir = 'right';
& I. x: w2 a' p  u" a) g9 ovar yDir = 'down';& [+ W4 b0 R5 Y, B8 v! r+ h
var superballRunning = true;
4 a3 K6 [" X8 D& |var tempBallSpeed;! i% A/ d, P5 r1 u7 B
var currentBallSrc;! P5 W  ^" R, M  l% S' q1 k3 ~
var newXDir;" n% [$ m' C7 @- A7 Z
var newYDir;6 n! g, f  w& e
' V: E7 K6 o/ W/ a- l0 G0 b
function initializeBall() {) G4 `# ~2 |# q& |3 O, {- _
   if (document.all) {
% {: a( r7 R. h* ?( j      xMax = document.body.clientWidth
* h2 b7 e2 b9 W% d      yMax = document.body.clientHeight. A, b0 D, c: |
      document.all("supertext").style.visibility = "visible";
1 j$ q: _/ t8 w( C/ f      contentWidth=supertext.offsetWidth0 x3 z8 H/ ]2 {) S. w
      contentHeight=supertext.offsetHeight
* b  ?* b2 V1 Y  q      }" W$ {- b. X2 C' ]6 _) Z* d7 [
   else if (document.layers) {
9 }3 ]$ F4 P; C9 C      xMax = window.innerWidth;
1 S  ?; N5 U$ M0 g; g      yMax = window.innerHeight;
% r# r2 c$ r- S4 d% q# p+ k0 O      contentWidth=document.supertext.document.width
& X) A  e: r3 n5 M& ]: f1 P. R" Y8 K      contentHeight=document.supertext.document.height
3 z4 Y! u. m% e3 f1 [7 \      document.layers["supertext"].visibility = "show";
6 R$ y: L$ v+ e/ {      }
0 t2 \6 U1 u6 ~( d0 G- g; i   setTimeout('moveBall()',400);
3 ^4 u' ?5 Y+ ]/ S5 y   if (hidetimer!='')' j' U3 V1 M" p2 `4 Y( g: V; a
   setTimeout("hidetext()",hidetimer)
. Q0 l+ L+ C' x3 {) c$ q   }& f4 d5 T1 f) q' b! p( v/ {
' V9 _% f" ^9 r6 ~! K
function moveBall() {. U  O) g( p+ u
   if (superballRunning == true) {
0 H/ N+ q9 d; G" b2 V' a      calculatePosition();- J6 ~' j# B# [
      if (document.all) {
/ m$ M. F& L3 f         document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 V! F1 V: H, Q9 Z         document.all("supertext").style.top = yPos + document.body.scrollTop;
- Z; G- j, T0 b& X& S/ u- ?/ q         }
. G0 |( [; A' T5 c' v  `  ]      else if (document.layers) {
$ e- G) [5 \& T" R, d5 n         document.layers["supertext"].left = xPos + pageXOffset;
2 n2 w9 }* s6 z7 m+ S1 ?+ [" R         document.layers["supertext"].top = yPos + pageYOffset;
0 Y' k# v0 q+ V1 H         }) \" c, f6 @2 K& M- O
      animatetext=setTimeout('moveBall()',20);
& i6 z- v) }, e- q      }9 }9 d6 v3 o6 ?; L# d. }+ k% g
   }, S, _8 O' H7 U8 D$ s$ A0 T- c

8 B% R2 [7 d7 n4 ?# M7 r* Sfunction calculatePosition() {, Q) E8 X" V$ h- ]: y0 u2 b
   if (xDir == "right") {+ w4 S  X5 q( ^! C; T
      if (xPos > (xMax - contentWidth - BallSpeed)) {# A. B, v* |; X& L9 N7 o% I" A2 Q
         xDir = "left";
9 B* w% }$ r- M6 ^         }
1 j7 U- K% F0 J% {( B4 ]" @" h+ [, g      }
3 ?- W7 t1 M! B- f# h   else if (xDir == "left") {
# W' P1 E9 X6 i* k      if (xPos < (0 + BallSpeed)) {
$ m1 R4 ^* E1 ^5 A4 |         xDir = "right";
% X# [9 L/ {. A$ i: R         }5 ], p# c: h  _( l
      }
: r# x/ h* C4 z* v3 @& y   if (yDir == "down") {8 w1 K* a8 t/ l  B- O6 |' {3 k
      if (yPos > (yMax - contentHeight - BallSpeed)) {+ y3 \5 [0 g2 k7 R- x4 S* i/ g
         yDir = "up";" Q# W* V- Z$ s+ H8 G3 n
         }
1 o+ {) d% Y! F+ w* C      }
! y9 `+ H* B; O$ `" V3 Q   else if (yDir == "up") {5 n4 `- z9 y' |# K6 f; N
      if (yPos < (0 + BallSpeed)) {# f# a& j; D4 B- |
         yDir = "down";
% T: O; c, ^* @" y+ c/ V% }/ e         }
6 w% H1 v$ e; R7 S6 O, r8 [& v      }
5 Z+ i$ i2 E8 U0 b6 y9 S8 v   if (xDir == "right") {
8 I' b4 Y7 J5 A1 Z3 Z  p      xPos = xPos + BallSpeed;7 I$ y+ s0 t, U9 {
      }% X, R+ _% i; O
   else if (xDir == "left") {8 {/ P) Z# [, a' z
      xPos = xPos - BallSpeed;1 Y4 {: w6 V& E$ Z
      }+ g4 E3 M8 k' ]
   else {$ w3 {' @3 t3 l/ h
      xPos = xPos;
5 n+ l3 s/ T  ?8 z5 a, {6 R3 v      }
1 N$ e9 K' I- }   if (yDir == "down") {/ ~2 {5 ^% U  ], A
      yPos = yPos + BallSpeed;
, A. |5 s0 i( a; }0 q  [* x      }' h# k% g% k* @' A# A
   else if (yDir == "up") {
+ E  g+ P- A$ R' S9 _      yPos = yPos - BallSpeed;% i) h6 w1 q4 j3 H
      }
/ F) W- q' ^: A6 x; q  O( B   else {
# `6 d# B6 _* S/ f9 c) L      yPos = yPos;
) m+ A) k' w6 K      }, _  `6 J8 S$ E( g+ `3 o; o
   }
1 F: |- s4 N+ z+ b; t
4 g0 c2 ~, Y; y6 \- Qfunction hidetext(){) t5 J$ {' b' m* z  e8 w7 I
if (document.all)6 L% s1 J( o7 O. n
supertext.style.visibility="hidden"
/ c" @- i8 D! b* C- p) delse if (document.layers)+ i; S/ O. \( ^
document.supertext.visibility="hide", t' o- k* z, w" c
clearTimeout(animatetext). Y2 X/ y4 X9 [  G$ L
}
7 G+ R- }% v- p) q6 Q+ e  x9 s5 B# e/ z+ M1 F6 P/ F9 M( d: e, {
if (document.all||document.layers){
" f  U, J' I3 j6 P; }document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 u# U$ ]3 J  d( jwindow.onload = initializeBall;
% D; C- H" Y' F7 V$ Wwindow.onresize = new Function("window.location.reload()");
. T0 ^* }0 U) O+ Q}
6 B" M5 \3 _8 C" J3 G& Q
! U: X- Y+ ]- I, L) f</script>

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