返回列表 发帖

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

<style type="text/css">& _$ t3 w2 M( q% R; ~1 Q
#supertext {  n/ r0 B+ E* S' C) i+ O5 S
position:absolute;+ E8 p; ~6 F' p$ t4 S
left:0;
0 @5 F) z% B' [# _top:0;
/ Y1 w4 y6 K# n9 svisibility:hide;
% w* D' P: v3 C& k& [visibility:hidden;: l$ J/ n0 N& q
}" g/ ?* N  l$ |, c* A% S  b
</style>
# g) p6 U2 W; E% A<script language="JavaScript1.2">
$ u0 U% i, K2 q% W<!-- 改变下的字体的大小。颜色-->$ W9 _; ^" |% @' l3 N$ g
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, }, S5 @! f1 Cvar hidetimer='';
/ B. u( B/ n% {  d& f# ^  Y# d3 E8 }<!-- 改变下的弹跳速度-->
! ?! B% S  h9 F% Q3 V5 o1 Zvar BallSpeed = 20;
, p4 b6 W, Q  V0 r: x; w/ D7 ovar contentWidth;! ~/ s1 {4 M8 `/ Z6 t; x5 w' P+ ~
var contentHeight;
+ D4 a6 _1 u+ t1 h2 Nvar maxBallSpeed = 50;7 J$ b4 o8 A7 F# c+ {4 g) `

. }2 l0 h8 {; }$ c; f
5 y3 f6 |9 Q+ \; G0 {( s" Pvar xMax;1 v% y( Z+ V4 x0 O" G& X& ]
var yMax;
9 ]: G1 {1 X9 F' V, M4 P+ L  gvar xPos = 0;
4 f$ o: u7 ?1 k2 Fvar yPos = 0;& r9 Q" U' G/ E; I6 ~
var xDir = 'right';
7 e- C) [) I7 {7 y8 t# T$ i$ tvar yDir = 'down';" a+ _) J! H( {8 N" c( p& J2 S
var superballRunning = true;3 t% G; C0 I/ R2 J% s2 C; [. \$ Z; D
var tempBallSpeed;$ e# {1 q/ t" K* t* r
var currentBallSrc;
0 r8 M+ N0 _. i& kvar newXDir;
1 q9 P5 g+ n/ }& u0 m% Bvar newYDir;% ]0 D& n- p, q+ Q' g! M. @: N

" M0 d: @/ c* X4 @$ d/ dfunction initializeBall() {2 y4 \  X& \" X. z, o" m) e
   if (document.all) {
) S! _" t6 D2 l$ s6 j, s      xMax = document.body.clientWidth
, \: R, Q$ |5 h; L2 E      yMax = document.body.clientHeight3 A" g! \' X8 {
      document.all("supertext").style.visibility = "visible";
$ U; R& e+ m- e  p  {' o4 @      contentWidth=supertext.offsetWidth6 H8 h; o* ?6 k" Z. U
      contentHeight=supertext.offsetHeight+ b) [! `& d; L& K6 ?
      }' k' N4 b& R! H7 e
   else if (document.layers) {
3 E4 T' D) c6 {8 U2 Z      xMax = window.innerWidth;" Z4 T  O6 H  Q0 f( ~
      yMax = window.innerHeight;) [' L. l% v5 \
      contentWidth=document.supertext.document.width
& P$ n! W4 A0 {2 v5 s9 v) h      contentHeight=document.supertext.document.height0 A. h& {$ ~; \) x9 ^
      document.layers["supertext"].visibility = "show";# Z9 q7 w6 g- @( L4 A1 g% A
      }
- F0 R1 @" B# A1 F' S$ p   setTimeout('moveBall()',400);! h6 u* M, Q5 \+ Y
   if (hidetimer!='')
- h& A' I4 e) W0 K$ S: Z   setTimeout("hidetext()",hidetimer)! {/ c( {) Z# |$ m5 L7 B" p+ K& }: q
   }
1 p& D; i+ b8 }& c0 {8 }# i" U
0 r4 \* s8 O8 |& Ufunction moveBall() {
0 u6 p7 y2 k& v, k4 I+ T   if (superballRunning == true) {
% i& y: \# b, @& J/ j* i% E      calculatePosition();
; q+ Y& F" i; v& ]! T/ r( W      if (document.all) {
1 g5 }& O5 ~: O  M5 |4 O8 J+ L( I         document.all("supertext").style.left = xPos + document.body.scrollLeft;+ g7 @0 I* ^) a* W2 E
         document.all("supertext").style.top = yPos + document.body.scrollTop;- g0 u% x! Q9 z. `( C6 m! L
         }: r8 Y% ~6 R( `' {4 J1 a; p7 l
      else if (document.layers) {$ D) B7 Z8 v5 p% a. C
         document.layers["supertext"].left = xPos + pageXOffset;
$ e* s) W; o1 \* K' }5 L' \( A         document.layers["supertext"].top = yPos + pageYOffset;
( b1 T* J! x' d* N- Q9 G& j         }
! u1 k3 G6 a' I      animatetext=setTimeout('moveBall()',20);
4 @6 w# u* M' Q6 t+ K      }6 K+ `" m* \9 q0 n1 y$ H
   }6 ]4 t2 Z& R4 k; _4 B
0 \: F. M+ h7 E7 W$ h3 @: v
function calculatePosition() {" J. u8 t2 D) x" j* D$ F
   if (xDir == "right") {8 @7 S0 _$ W3 {6 o1 ]! G9 y
      if (xPos > (xMax - contentWidth - BallSpeed)) {
7 Y" w0 F4 d3 B( ], a/ I         xDir = "left";1 Y9 s9 I+ f( J4 L6 P. W
         }
1 x- m* |& A8 d( R0 ]2 l4 e      }2 y' W8 V; _! w; U! H  U- W3 M
   else if (xDir == "left") {& W: Z1 U1 l( x6 M$ x' A! b
      if (xPos < (0 + BallSpeed)) {
3 r# ]& ~. U- e3 D- @$ n         xDir = "right";
0 `5 V% M$ z* u3 Y         }0 b  @4 J4 e+ w0 s9 @
      }
3 {* R! v- j( Q   if (yDir == "down") {
* J9 }! p$ e7 b' A3 X% q8 J/ D      if (yPos > (yMax - contentHeight - BallSpeed)) {% z% Z  z* N6 \  [' h' {+ p
         yDir = "up";5 c4 a% r( p2 v. z. ~
         }
/ ^' f. H+ R# W# j% B2 z      }
4 r. L* y( e) V9 K. w   else if (yDir == "up") {
! r: I9 f9 S* O* j" ]- V      if (yPos < (0 + BallSpeed)) {
* c: Y. ^! P4 u( [' J) \         yDir = "down";
, z: W" f7 C/ f/ x' L9 x         }. j4 n! Q5 ^- }) f
      }& {  [! Z9 u, n% o: ^
   if (xDir == "right") {
3 F4 L1 J- ~- y3 W! Y      xPos = xPos + BallSpeed;
9 h2 k" ]# C7 i# `& v. k) z      }+ @' W3 d- R+ x4 N9 n2 v
   else if (xDir == "left") {7 R9 R0 d/ |  g( |2 r* |
      xPos = xPos - BallSpeed;
: m2 T! h, c  ^7 f, y2 C      }
% r8 X3 G& ~  Z( k0 P/ O* U   else {. c/ O% c2 b  x
      xPos = xPos;$ c) o  ~+ w+ S8 c+ O! `6 f
      }
; T: [# C& k( s* M4 y   if (yDir == "down") {9 t5 [" \9 Z7 y1 y
      yPos = yPos + BallSpeed;8 Q; f. ?8 E  O/ Q
      }+ R. q2 ?$ N1 n- P- c( @- p( T
   else if (yDir == "up") {: x5 s1 a. ?( V8 Y9 \; C
      yPos = yPos - BallSpeed;$ |/ Q* F. K9 Z# I
      }1 |+ u2 Q% u7 ]7 o* r. N! V- O
   else {& G1 h8 ~4 _/ R3 H$ w) Z# k: p( [$ J
      yPos = yPos;
: j* Q1 l4 s* T  l  h; Z      }
2 F& J5 G% [2 R- _; _   }3 H* |. y4 D$ Z4 H; v

) s+ M% `- h# ^% j2 |; n! mfunction hidetext(){
% i6 l' g7 T7 O7 N) m' g, V. i1 _if (document.all)
( [* S* l1 O( `3 Gsupertext.style.visibility="hidden"! T& ~( z0 X6 r/ R! \9 U, F
else if (document.layers)
. U& f8 t1 N' Y  P" xdocument.supertext.visibility="hide"+ k/ t2 f! _& Q/ ]
clearTimeout(animatetext)
) S6 R+ R: k3 k- p' |  L}0 `( }: m8 j& @4 d8 b/ T
% w5 M3 F% z, A& L5 N2 F
if (document.all||document.layers){
; b: u. e1 T# ], e0 e# sdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 p# g) @8 |! [5 w* Q$ Y
window.onload = initializeBall;
4 }1 y5 ]' U! H" ?% \# Lwindow.onresize = new Function("window.location.reload()");$ y* e7 t# i2 i/ c5 _7 U) d
}
" @8 H7 I/ \" c
) G, t# t8 ~5 ^# |, ]+ _" U</script>

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