返回列表 发帖

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

<style type="text/css">( }) A# U/ t. D8 X. P
#supertext {
& x* F: f. m7 y0 g7 f. iposition:absolute;
" s: ~: t5 J" M- Nleft:0;
6 R5 t- I% w8 B! x8 |0 ktop:0;3 |6 e/ P5 s. }% [. i4 d
visibility:hide;
& ]) A/ P& w! o. ~( W9 k+ `9 ?+ \5 o, Avisibility:hidden;1 j7 S; w1 {5 a! C8 t1 V5 N
}
3 M: R3 L$ Y. |$ w) x0 K/ ]9 ^</style>& a1 K0 {* ~8 R$ a: Z0 G  o+ A
<script language="JavaScript1.2">
! B8 x! R& _+ U% |<!-- 改变下的字体的大小。颜色-->$ u5 n, v. V8 G6 R( V
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ w8 j$ r3 F) {6 e# h) X5 k/ avar hidetimer='';
1 _6 G9 S) m: j<!-- 改变下的弹跳速度-->+ t7 ^7 v" K8 n
var BallSpeed = 20;5 b; u% }7 G( }; C: _& H
var contentWidth;
# f+ N6 r2 S5 i, }5 _$ {' S0 svar contentHeight;2 @3 T+ c7 i' O6 M6 D/ [) @- o. O$ b
var maxBallSpeed = 50;: F, \* ]2 O  d0 b1 ]: q& r0 u4 J; u  u
8 J" p- m% w$ F9 d; Y( r

$ R, |; i2 I. N5 O0 z1 qvar xMax;, f6 N3 n' c& e/ U1 p  n( _0 Z5 Q
var yMax;+ t3 C# {$ J1 A+ D
var xPos = 0;
5 k. |) Q( K5 U. I& e1 `; E' lvar yPos = 0;
5 r% v, ]1 n/ Y: R& @1 W" {var xDir = 'right';
5 P0 W3 e' w7 {. D% Fvar yDir = 'down';
6 l  [; C- c5 d, ovar superballRunning = true;
# c) A1 M8 `6 O9 k' D8 H; ?9 Zvar tempBallSpeed;
. C7 j4 S* W# vvar currentBallSrc;
4 w" X/ l; d8 l  P( b; D, Qvar newXDir;
$ p9 k% U/ M6 D5 \' `& P* }5 z4 D0 h: Mvar newYDir;
' w, |+ Y) b1 V6 K9 o( k6 C. o% E& K5 o6 |1 Z7 v
function initializeBall() {
# T8 _0 N; C7 ~% c- y# X   if (document.all) {
* N  m& N8 {& [' Y5 z3 t      xMax = document.body.clientWidth
: N1 A# x$ ?, G4 z      yMax = document.body.clientHeight
; T  _6 W& X! |) k$ U, z      document.all("supertext").style.visibility = "visible";* x/ l0 e7 n+ W3 F# a4 {
      contentWidth=supertext.offsetWidth
) L8 k& `8 Y* A$ \7 B) a' l      contentHeight=supertext.offsetHeight
: C1 n( S" q8 D, k' a6 N! C# ~      }1 u* L. u: z* ^6 e  j' ~0 u+ ^! U
   else if (document.layers) {3 I4 g0 Q; H4 a1 o3 Q
      xMax = window.innerWidth;
% x' x0 h% U+ z9 X) m( |/ V+ u      yMax = window.innerHeight;
" \' K9 X1 ]4 ?1 z      contentWidth=document.supertext.document.width
7 v  c/ X0 W0 e: _0 N      contentHeight=document.supertext.document.height( |- G/ `$ R$ F% G
      document.layers["supertext"].visibility = "show";- U7 Q: h9 q; G# M6 z# h
      }
+ A8 Z& A- U  s- U9 {   setTimeout('moveBall()',400);
1 |* p& R8 H+ z' P, E6 W2 D, G. a   if (hidetimer!='')
8 i4 \) R! \2 l% c$ ^' w( P. o   setTimeout("hidetext()",hidetimer)+ q5 e/ P- }. G; y0 ^% i& W' N
   }1 n& b; f- `: ~& O
: K8 D( O5 C4 @/ {) o% g' g
function moveBall() {3 n9 a* ~* K2 ?2 E  i. [. q
   if (superballRunning == true) {
/ j0 y4 L" V4 R6 ^. P) e, l      calculatePosition();0 Y5 ]* l/ i$ g" E( c) O% J
      if (document.all) {. E' p# ?' _2 c/ k) a! q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 A* U7 U6 Z2 G' C9 T8 _4 n         document.all("supertext").style.top = yPos + document.body.scrollTop;
* Q) c3 o" f; e, x& n% }1 x! `         }+ v) |$ |8 d% h& t! X/ W5 j
      else if (document.layers) {4 {  F+ m9 g- e! g
         document.layers["supertext"].left = xPos + pageXOffset;
- [& q! u1 ^1 o" f" B* X         document.layers["supertext"].top = yPos + pageYOffset;8 y' d. S7 S. o9 g" u/ Y: d
         }
3 k( z/ ~+ g0 a7 ?% h6 T      animatetext=setTimeout('moveBall()',20);
& j. C0 T* m* |      }
/ a( f- U# B, ^# i   }; e6 C+ p3 n+ e
, w3 _& ?, j: M3 C5 _; N9 b' T
function calculatePosition() {
4 p! X( U3 d' a' ?   if (xDir == "right") {9 x% u" P2 k! n% k
      if (xPos > (xMax - contentWidth - BallSpeed)) {+ S* j2 s5 k; t5 c# L- ^, I! I
         xDir = "left";
6 T0 q, G" a! I+ p& ^) \- x         }
- Y3 v4 D* l6 N      }0 A  ^5 I3 X( d9 a
   else if (xDir == "left") {
: N5 v. ^: N& E5 ^  B" T3 D      if (xPos < (0 + BallSpeed)) {0 n8 ?" c2 _! K0 P4 _- G
         xDir = "right";, l" D2 A$ {$ U9 W- I
         }2 B( S1 _2 U9 a6 \
      }) D  ]- h' C# A
   if (yDir == "down") {1 a* O" v! g% y& }5 p$ e
      if (yPos > (yMax - contentHeight - BallSpeed)) {3 L2 ?1 S/ z( P$ s
         yDir = "up";
* V2 M. S# z; S! {3 o+ w         }
9 _- R+ k& H; A% X      }
6 Q( C7 K8 _& z; q   else if (yDir == "up") {
# t- i7 P4 z+ a6 M% J* C3 M      if (yPos < (0 + BallSpeed)) {9 f3 k4 n! I3 ?
         yDir = "down";
! A9 Q' m1 i. f; J) t% T7 a% {         }5 {  F) p, I" H! F5 X& N4 ^! k
      }
. B! D2 i: |. G7 S4 U2 _( h9 g   if (xDir == "right") {
" \4 N8 D/ I0 K! |) L      xPos = xPos + BallSpeed;+ p$ K- {) g. a& F: X9 |  `/ f
      }
9 v8 T( q% n- d8 y% q# v" ^   else if (xDir == "left") {/ C! b7 I, h) Z% ~& ^" ^$ A
      xPos = xPos - BallSpeed;
3 ?, v. [" m* `8 k( C# F      }: g8 x$ k, i: Z- @2 p8 T% P
   else {8 e. I* Y& k/ U( D9 M  K- J
      xPos = xPos;# y0 M. Z% q' ]. u
      }7 A$ ~' L; m( ?7 e' F3 @
   if (yDir == "down") {
( n" x) c9 |0 T# ?& N7 N  i      yPos = yPos + BallSpeed;
9 N# z5 Y+ A0 \3 ^6 v, H5 Q      }) R, y" S/ M9 F6 u' C8 K+ {
   else if (yDir == "up") {- J: V, |1 ]- ]4 p+ F
      yPos = yPos - BallSpeed;
( I' _' b5 r6 w5 @( K, I      }
+ T' \& C: [, L8 [" R% Z   else {
2 C. ?# m0 o! }; ^9 A      yPos = yPos;
' L6 H, G+ q- w7 f5 y* _$ k$ `      }8 M3 Z4 ?6 Z3 T6 m
   }
. U; S5 v. k% t
* }) k* X% x- d+ }function hidetext(){& U: u( m. C; d1 _$ J
if (document.all)* s' Q, ~9 x# J2 S
supertext.style.visibility="hidden", a0 \6 V- C# q$ T" c6 }2 C7 T
else if (document.layers)/ y: X5 ?1 |+ y5 {
document.supertext.visibility="hide"* R- I$ g$ M0 Y* y5 X6 k: t
clearTimeout(animatetext)* y+ ^8 R8 g! \7 y1 u9 }
}0 d- o- q8 D! Z' w: @( z- B3 T
1 P8 u/ v$ W' ~( E+ L
if (document.all||document.layers){1 d- |+ {' W& o/ Z: h+ l
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ s0 [  A6 s9 {. f0 X
window.onload = initializeBall;
2 H7 W) T, R( ~7 K) [( qwindow.onresize = new Function("window.location.reload()");
" r, E4 u7 j" y}& T$ Z$ @2 \$ h
) O, u! m9 b( a. S( _
</script>

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