返回列表 发帖

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

<style type="text/css">$ K7 b0 ]% P( [" `% u! O1 k
#supertext {' U$ H/ x" U& x' q
position:absolute;
9 l( a0 d- L  K% l2 n" A6 h0 b+ }left:0;
8 ^8 P6 l  C" n4 i& j9 H1 J' z1 Rtop:0;
9 V3 k" m: G3 H. B+ ?visibility:hide;/ r  _% _9 v, E' j' V% U6 Q, z
visibility:hidden;
2 |) ~  |1 T$ A/ w. f}3 M8 q% {/ Q( m8 ]8 C' v  e
</style>
7 M% u5 ~' @7 y3 N0 D2 y<script language="JavaScript1.2">
- a+ I" R0 b2 Y+ s9 p% @# @4 {<!-- 改变下的字体的大小。颜色-->, ^1 r$ n+ |2 V2 ]3 `3 a
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'  U3 t( m7 o; {0 w
var hidetimer='';2 p) Y4 i6 I& ]! q
<!-- 改变下的弹跳速度-->
/ H7 G* A7 f  ~  Mvar BallSpeed = 20;
0 D% [' G2 X* Dvar contentWidth;
6 Y8 @* c. ]/ Y7 kvar contentHeight;+ V4 z( C' M1 W
var maxBallSpeed = 50;
0 q" ^5 v2 I! D- \8 B7 n
* u# ], \+ H- _+ p/ `& H5 ]" W7 w
5 G, O# {# q$ c' \var xMax;
5 l9 p6 p  {6 \var yMax;
$ N/ v1 p: X7 m; [: @4 @3 r7 Hvar xPos = 0;8 A  |0 S5 ~( b/ h
var yPos = 0;8 w5 G. F$ m% {
var xDir = 'right';
6 e2 w' g# U6 _var yDir = 'down';" Q4 @/ ~0 X) G" M  x7 ?+ h
var superballRunning = true;
4 {" s# C1 [/ ?% b1 f% nvar tempBallSpeed;3 m6 G+ M' \9 R  Y# _
var currentBallSrc;
2 |0 p# D" z2 F8 J2 v) yvar newXDir;. `  V, _$ i; l# z
var newYDir;
) L+ n! O# c3 x
4 F1 D1 E. X2 z' b; n; d$ Ufunction initializeBall() {
# b3 S0 @& T: D; Q: [7 O$ J   if (document.all) {
2 P- |* @# D; K4 d9 b. g      xMax = document.body.clientWidth
3 Q6 y) T( X6 E+ t      yMax = document.body.clientHeight
: U" S$ i% ?0 J: y      document.all("supertext").style.visibility = "visible";
% H+ V" x  ]5 e' k, I# \      contentWidth=supertext.offsetWidth
! d( D/ G/ e5 ]* C/ v      contentHeight=supertext.offsetHeight2 L* T7 Z6 }3 |; f4 ^
      }
# ]. _, \0 g* k- `1 O   else if (document.layers) {4 m1 o& I' n- u1 u% v
      xMax = window.innerWidth;
5 p) u: E# x% K6 x: e; {; R      yMax = window.innerHeight;( i4 K3 F$ x3 q0 \+ L6 q+ R3 x
      contentWidth=document.supertext.document.width
; x5 A. ?( N( h3 _$ Z7 v      contentHeight=document.supertext.document.height
! }& V5 G. |' n3 w1 P# u) U4 T      document.layers["supertext"].visibility = "show";
2 \7 [0 Y1 x, o/ X3 s: \# u      }
- z& ~: V' o# t, O   setTimeout('moveBall()',400);/ |% R% l% z1 z+ K% I1 M
   if (hidetimer!='')
& L. ~3 v8 N. c   setTimeout("hidetext()",hidetimer)0 Q' S2 Y: o  q( h; O* w% J
   }! @1 v# M1 e! Y. l$ K  g& H

# Q* ^4 b2 q8 }function moveBall() {
3 V* A! @1 v1 K0 o   if (superballRunning == true) {
& N* X+ C8 I: _      calculatePosition();$ O& n$ j( Q8 f; ~8 y+ z8 u
      if (document.all) {" n; v  P0 Q' n8 b' ~3 E1 k
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
: d+ B5 h* y" R; b2 [         document.all("supertext").style.top = yPos + document.body.scrollTop;
& C" v4 D! f6 X* n, a         }
9 I2 ]+ N/ x8 o      else if (document.layers) {
+ P8 Y" f! T$ {' w         document.layers["supertext"].left = xPos + pageXOffset;
( _2 e; I; ?6 w2 o7 J; \         document.layers["supertext"].top = yPos + pageYOffset;
1 D  h7 _% l1 n( a% D; _         }7 o4 a* K* F! e1 I+ B  G9 ~% M
      animatetext=setTimeout('moveBall()',20);
& `$ ], Q1 i' D      }. x+ c' ^8 }4 d) W( I. T
   }3 i, ]. Y: @2 k# e  r( _7 v
0 i/ k9 @* |/ t% ^
function calculatePosition() {
- T+ ^+ g/ e" b/ P3 M9 w3 \* R9 X   if (xDir == "right") {, H! `' q, _0 O( H6 O. ]
      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ u) e/ N( X# W: s5 W$ @         xDir = "left";
! o) U# [2 y4 y% r( u- P, p& V8 g) s         }
: }( K9 E7 X3 R4 `0 j9 A8 g      }
9 g1 k3 {6 Z5 t: h( E   else if (xDir == "left") {
: h& H2 V) s1 b3 |* [; W4 z. C      if (xPos < (0 + BallSpeed)) {* P4 f5 R. Z& `" x; Y, x
         xDir = "right";1 H1 o- i4 X$ |2 L3 \6 @2 Q/ K
         }  K, M. d5 m- D( E9 p# m
      }% o; S  x% R) p( T/ P4 R
   if (yDir == "down") {
0 ?( D: {: a. c' x; E/ q. k' D      if (yPos > (yMax - contentHeight - BallSpeed)) {; @- q+ v( y# n' G
         yDir = "up";- m2 z& E1 \) a4 ~( L
         }
- E$ @2 n3 }, O5 B      }3 B, F# }8 K# p6 j* q% m# ], c2 j: w! N* f
   else if (yDir == "up") {( o& G8 e  h- `+ S9 E' J6 R
      if (yPos < (0 + BallSpeed)) {& H8 @% c, Y0 l/ j; Z- a# K
         yDir = "down";
! x) p- Y+ g1 [% g1 H- ~7 c3 l         }1 \- t, u0 k' h( u5 I
      }5 X) R) N! C4 B3 S$ g( ~8 H
   if (xDir == "right") {; K; W# A6 H2 K( X7 W: w! A8 \
      xPos = xPos + BallSpeed;
+ t+ e; I5 z( \7 c+ L      }
7 p% Q5 W! f0 p# w4 r' L   else if (xDir == "left") {
0 u; p3 E* ]' ~# V. m      xPos = xPos - BallSpeed;: b: d$ G1 r1 X6 k0 k
      }5 c, m- i, x2 C& Y5 C( l# u' {
   else {0 _4 l$ a0 v8 {4 T/ [% O
      xPos = xPos;6 a7 Y! t0 ?. _4 d  b6 D+ n
      }
/ k% h6 F( B9 p# S, X  P- h' Y+ J   if (yDir == "down") {
& q* H2 W+ c3 Z, b' ~* N      yPos = yPos + BallSpeed;" _2 J# z3 y- i' ~/ a# l5 p
      }* f2 t, m" f1 {# I( S0 a
   else if (yDir == "up") {8 r3 V, F' F' S3 |; J6 D
      yPos = yPos - BallSpeed;: }  \6 `6 N3 A9 Z5 Q- B% e4 a
      }, u) i6 S" ]7 x2 j) b1 N9 b. ~
   else {
$ U+ _  E& E" h# U6 O      yPos = yPos;
  D, q0 d# i5 c% ?& B0 C, B      }
" G9 O+ x, k7 ^9 G7 y/ f   }
- ^& Z# \& T' b
& I; e' k" X5 Y# G. M9 i" w: n" Ifunction hidetext(){
; k7 {' b+ a. qif (document.all)# g2 B1 k; n0 s! _' H& \$ S) A$ D
supertext.style.visibility="hidden"
7 }# [0 W( {- j9 J' |6 z# l  [9 Velse if (document.layers)$ n, M" a. `9 ^) V8 W
document.supertext.visibility="hide"
0 {5 L5 [" K% _6 rclearTimeout(animatetext): j7 ]1 h7 r' F) v% ?4 R4 o2 L
}
! T7 @% Z+ w; T" s  E0 Z* U: J8 @; I- c
if (document.all||document.layers){
0 q2 H7 [8 o1 {/ c& Cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  Q+ ]; x: W+ Owindow.onload = initializeBall;
. w9 }9 ^/ ~% E1 f8 x* Fwindow.onresize = new Function("window.location.reload()");
( E. x6 Z" ~; U}5 X) l. g! J0 g7 O. `

, E% x' J" @2 \; l</script>

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