返回列表 发帖

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

<style type="text/css">
0 u+ a4 X- O1 f$ a% i* B  [#supertext {
( C- q( s; c' y5 k/ F9 s, a% Lposition:absolute;7 ]4 z  X  B8 E* l4 p
left:0;8 W1 ~( n- _! U& T1 q. M$ r2 M
top:0;- Z/ ^. w  _8 c- t4 k
visibility:hide;
* Z9 y& `3 p8 z$ Ivisibility:hidden;
' m1 N8 k. H; E7 c}8 w& S6 J* Q5 ?3 P9 l
</style># v! a5 l  x% m3 Q; Y
<script language="JavaScript1.2">0 Z, ~0 ]6 f" k1 a$ ?6 J( p
<!-- 改变下的字体的大小。颜色-->
3 G: ^- w9 c; q# t# Dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 r2 G% R3 f# z+ C* |- z
var hidetimer='';
* u) r) W( @* c" r; [' X<!-- 改变下的弹跳速度-->
! Q- ~2 x7 `( lvar BallSpeed = 20;
$ `5 C0 ?4 i+ T9 ivar contentWidth;
/ D# u0 r3 j/ |! E- A7 o; \1 `8 ^var contentHeight;
9 F- e4 ~. a+ lvar maxBallSpeed = 50;4 M6 G' |% }) j/ X

3 N' g6 J4 ~- g0 [. p! p% m4 [" M; _( N5 H
var xMax;
" F$ {! `  {7 o6 Y7 z% t8 |- e: {var yMax;* M/ |8 z* O& Y- P. W0 {& i( h
var xPos = 0;
. t" s, o1 X9 h2 b8 fvar yPos = 0;6 }! u4 t* o' Y: z; m5 v
var xDir = 'right';& p, Z8 ?1 K9 N& v
var yDir = 'down';
  m! {5 v- v8 O, r, S7 ^4 V5 Kvar superballRunning = true;9 x! g$ r+ `! E7 e/ {8 b4 Q% m
var tempBallSpeed;7 ^5 w( r1 `( z+ T1 r# n0 F
var currentBallSrc;+ a- R, ]# O1 S
var newXDir;
5 V( ?: E; W) T; r% N8 U  Bvar newYDir;
# \& h" ^8 N/ f! ]# j9 B/ W6 I& E4 i- r1 J2 ^/ ^
function initializeBall() {1 ~: J% |- }. R/ q& S3 b( L
   if (document.all) {  r1 m- T2 X7 Z2 O; W2 |
      xMax = document.body.clientWidth/ x' [1 ?4 M# h" y5 w
      yMax = document.body.clientHeight+ K) B& H$ B: `5 q3 k
      document.all("supertext").style.visibility = "visible";
' y2 k6 R: H: ^: \! x# X; G      contentWidth=supertext.offsetWidth
9 Y* H: m5 L$ y2 |      contentHeight=supertext.offsetHeight
* y7 Z! {; m) P: g% ~  ~7 w      }9 z* J- Z+ h' n# Y
   else if (document.layers) {
9 W0 W: k1 _8 i/ _, O0 {      xMax = window.innerWidth;
  _4 t# Z4 k6 i/ q$ S+ ^# I' Z. k      yMax = window.innerHeight;
9 G' d  u$ T2 U8 Q5 K' Q      contentWidth=document.supertext.document.width. K& R) Q- w$ y. A7 U; Y- {3 ^
      contentHeight=document.supertext.document.height
5 I3 \- A$ k( j, e, ?" G8 t      document.layers["supertext"].visibility = "show";
! H8 U& n7 O* S# I' j1 a      }0 P; `8 j' Y8 F- i% t: v) Z( i# g
   setTimeout('moveBall()',400);& i/ C" k/ ]: B: x% l. \3 C
   if (hidetimer!='')
0 Y' T% x: v5 ^. f6 G   setTimeout("hidetext()",hidetimer)
% z2 s" ?: ?9 w2 g5 d   }
1 N4 G' w" D2 t& \( v! r2 d% V. O& x% b9 F+ G
function moveBall() {0 w; b- D; C0 Z* |
   if (superballRunning == true) {/ E/ B$ h% w# @1 V- `- P# n: D8 Z
      calculatePosition();
# i; c; B8 F, {      if (document.all) {
2 x0 U7 Z) W- N+ r% ?         document.all("supertext").style.left = xPos + document.body.scrollLeft;. u7 _6 a; p' L) X" E" o4 w: A, X& c
         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 k; n4 j! d8 O4 G         }
# `3 i5 t' c" ]      else if (document.layers) {" \) j3 ]! q6 [1 B! G; ]  e
         document.layers["supertext"].left = xPos + pageXOffset;
+ @7 L8 A$ [; O; g6 Q0 k# U         document.layers["supertext"].top = yPos + pageYOffset;. T4 I& q  O) M& Y0 w  G) z
         }. H" m7 Q8 A# A& M' s2 \. o
      animatetext=setTimeout('moveBall()',20);
3 x& g) _+ M, k! V9 F* M      }
. L; E2 w+ P% a   }
' h; S8 ?0 d5 y  D% ^: ]& I' I' q) F2 b9 X
function calculatePosition() {8 w8 t7 U0 [! l: l$ D$ h/ _% d' r
   if (xDir == "right") {
) Z8 {( D  L" K4 y' O5 b" K6 k+ @      if (xPos > (xMax - contentWidth - BallSpeed)) {
. c: z, F, o$ X# H8 k( F         xDir = "left";4 c0 }' w# Q& F# z/ i
         }
# D$ v$ c/ r# N1 P. e8 u2 J' h: ]4 n      }
- e  T% b, a9 [$ \   else if (xDir == "left") {, a8 `( q3 n6 w) {; Z9 F
      if (xPos < (0 + BallSpeed)) {
5 ^2 u) W1 n# |3 `6 V+ ~         xDir = "right";8 d& Y. ~0 i. }6 M6 ]' f* h- X9 P0 G
         }" z7 M6 w8 ~7 {5 t9 J/ x& u7 v
      }$ A( \5 c' Q- O7 ?
   if (yDir == "down") {; p# k" y2 a8 i0 I
      if (yPos > (yMax - contentHeight - BallSpeed)) {: ^; V; A* V$ i
         yDir = "up";( n/ H8 W7 R0 [9 v% A7 k( P3 u
         }
1 v! x' K6 o& u6 ]      }
) ?3 S! Y( V& E# x' H   else if (yDir == "up") {) y$ U! Y: z$ t
      if (yPos < (0 + BallSpeed)) {- J1 y+ a0 f, ?* @+ q2 b
         yDir = "down";
) u0 O+ Z  H9 x9 S5 W, U) ]3 S) @. t         }
7 f' k, c- z$ k9 `" ?7 b7 Q      }6 O- `  S  K# K# s6 ]
   if (xDir == "right") {
% A: @; y" q5 Q2 u: f. e, A. y      xPos = xPos + BallSpeed;/ u$ W( j/ I/ V& X
      }* G4 V; G* T, T% u" g
   else if (xDir == "left") {" @  ^- L2 k& A& W, y
      xPos = xPos - BallSpeed;$ J* B  v5 R5 B; n8 a7 U0 N! p
      }
! t( {0 J& X8 C! Y) H$ Y   else {
" k& Z" _" E0 e  {- B" y- [" u3 T' E      xPos = xPos;$ [% i) ^# ~. S7 k4 b
      }
) k7 [9 `# {1 i   if (yDir == "down") {
, o7 D3 m) {" q% X$ z      yPos = yPos + BallSpeed;
5 M; f7 h) }- I1 `1 ?      }$ u8 s! ]+ @: p, N& m
   else if (yDir == "up") {
( X  G3 ?5 j& D; g  _& P8 K      yPos = yPos - BallSpeed;
  Z' |2 N9 g% g# a0 P, e3 A      }
  P' V/ A% U! K" h! p+ I4 d   else {
0 M) t' L$ }8 V) ]/ [- A      yPos = yPos;
  m$ s9 X/ F! _9 W4 _: O3 ]) r      }) H( h. T7 w  F+ w
   }$ H; O1 s8 l- Q: O5 L4 P# s

6 m' M0 M$ Y" U1 q8 r' H4 |8 tfunction hidetext(){
9 L8 C1 E0 c3 @0 Zif (document.all)% ?; l, U$ k" _
supertext.style.visibility="hidden"6 ^5 q7 S6 r8 |$ p
else if (document.layers)
# z1 A5 B8 u4 y( Q4 S! ndocument.supertext.visibility="hide", W8 Y$ b! A) u
clearTimeout(animatetext)( G# ]- A( \% E- F
}
7 c/ I, {3 H/ }) Y8 h5 A4 S. h5 x! D1 G2 D) B: `7 O2 N: M
if (document.all||document.layers){4 X) [  j" A( }
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 |; Q8 U) S- {) `
window.onload = initializeBall;
# _7 P% a$ R2 h2 P% ?6 Xwindow.onresize = new Function("window.location.reload()");; x: s2 T; ]" g. H# O/ \" l
}
' e8 w4 |' \6 u  e+ ~0 K( M" e- x# k6 O6 y
</script>

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