返回列表 发帖

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

<style type="text/css"># X. N. Q7 ]# F0 N9 N# T- J
#supertext {5 d; _4 I+ j( v5 g1 z
position:absolute;9 J* Z: D  n+ A5 g
left:0;9 x; }1 `  x1 c. w6 ^5 |9 k; P
top:0;+ v* j/ U9 i0 r3 b5 a
visibility:hide;  V/ ~5 v# P$ j" T! L. K3 O
visibility:hidden;# x- u* \/ O) r: @
}
8 L/ F7 y; h" v9 E6 w$ p9 m</style>
  A4 A* V$ C+ A- Y, x) R  w7 `; Z. c<script language="JavaScript1.2">
8 F$ J* V9 O- Y- C/ x9 E6 @  T<!-- 改变下的字体的大小。颜色-->
( d8 E8 r$ Q5 E5 G( J. F( lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 \6 q* r8 m; H  H5 x& nvar hidetimer='';
7 I. w7 J# f7 Y5 I<!-- 改变下的弹跳速度-->8 m1 r1 t/ j) J1 O) V  Z. _
var BallSpeed = 20;
% h* ^; D2 V2 Y) h. o2 U$ ]  J* Yvar contentWidth;
: @# z; U) {) L3 K0 e; J$ }0 uvar contentHeight;
) x, f' h4 k8 D2 h1 b! _var maxBallSpeed = 50;
: F+ L' P2 g3 A# R+ f5 F- _% G# J+ J
$ ~  B/ L0 c# t5 g& E
0 J% Z4 c& H, p: `, i& i- Zvar xMax;% x; g  P6 r* A1 ~# u
var yMax;9 d) d; A% T) @) @- S
var xPos = 0;
; {0 h2 r" O* d" Dvar yPos = 0;
4 V/ a. O, l4 Y0 @( ^% bvar xDir = 'right';
' U- t6 F( g9 [- k' u! F  m9 F  kvar yDir = 'down';4 A5 L7 C5 y% x" ?5 S3 s
var superballRunning = true;" ^2 j4 j5 m  V- L7 R! T
var tempBallSpeed;# w$ J, v/ v: c% o4 l* z% e
var currentBallSrc;
6 R8 N. N& E) b0 O- `9 B7 \var newXDir;0 D- F5 j' p5 ^5 r8 |* `' [
var newYDir;0 ?# F4 m2 v7 d9 v' n& @2 _: x+ ~
* I( L5 G! V, D  W% R# G( |
function initializeBall() {) e  z/ {, p/ J- m7 y8 Z* ~
   if (document.all) {
& k6 a& t) y" K" `9 S1 K$ ~6 h7 R0 c      xMax = document.body.clientWidth* g' N3 @, N& r9 O7 j
      yMax = document.body.clientHeight: C5 W1 b5 y$ F' t
      document.all("supertext").style.visibility = "visible";
- M1 k* F! G/ [: d2 y& ^      contentWidth=supertext.offsetWidth
6 \% Y( p& q. J+ ?7 T3 i4 A- R      contentHeight=supertext.offsetHeight
- z* F" j& c& L5 v$ G1 l      }! V' P4 y8 @) t6 T4 U0 Z7 z
   else if (document.layers) {! q$ E! H" b3 {- S
      xMax = window.innerWidth;
0 j% {; m6 i+ v      yMax = window.innerHeight;, f/ M1 ^& ?7 C; D3 g* I
      contentWidth=document.supertext.document.width
1 x2 M2 c6 W4 [: ]! _' q+ p      contentHeight=document.supertext.document.height
9 f* @$ ^- c! m- X3 B  H      document.layers["supertext"].visibility = "show";
. v5 l2 Y3 j* C0 e      }0 [' s# p$ D; C( X0 K* g6 C
   setTimeout('moveBall()',400);
: d- P; N1 t! u, y% _; a0 v2 b, B   if (hidetimer!='')
  k/ E" |) ]" r% l   setTimeout("hidetext()",hidetimer)
' f8 K/ _4 N* j# ~- h   }5 F9 }+ `2 N2 }7 w, Q2 ~5 A
. r' B) H) f, ?
function moveBall() {, M$ M0 |9 _% i. e( E, E' w
   if (superballRunning == true) {# |, C, Z( _$ D7 n1 t* r$ m. Q
      calculatePosition();3 T1 w: W5 K4 S) }
      if (document.all) {
! d' u# Z; e* h  g2 h+ C2 o         document.all("supertext").style.left = xPos + document.body.scrollLeft;( q# G) A+ w% z7 W7 F' p- R
         document.all("supertext").style.top = yPos + document.body.scrollTop;5 J$ L. y* t# p8 I/ M
         }0 U8 K5 s* D5 N* v
      else if (document.layers) {4 w) ^# M8 K+ K1 m8 a  S% K
         document.layers["supertext"].left = xPos + pageXOffset;
& u$ n9 B/ Q$ Q3 E0 G. [; X7 @         document.layers["supertext"].top = yPos + pageYOffset;* F6 B( d) H; e& d
         }* H9 g  ^' v1 t! C
      animatetext=setTimeout('moveBall()',20);
, L! E" f% a' d! ?1 o9 l      }+ Q$ m/ u$ m4 T* p/ t* c
   }
  \8 S, b# b# I
- d6 z' E; M$ Ofunction calculatePosition() {
& }7 s0 m1 y& i$ q   if (xDir == "right") {( N/ A3 _  S, u2 l
      if (xPos > (xMax - contentWidth - BallSpeed)) {
$ O. @, h7 c- s! D2 s( X         xDir = "left";7 I$ O) s. h" R% Y% `1 I7 n/ q
         }, i. p' U4 ~6 B, T3 X$ \+ @
      }
5 w6 `2 r/ c7 r   else if (xDir == "left") {8 A. T3 w  t8 l' |8 s. X/ F5 |$ K
      if (xPos < (0 + BallSpeed)) {
3 p  z* P9 n' d8 P         xDir = "right";! D' d' @) m. Y) T3 O2 @
         }
* ^$ z, a) H& A1 [9 Z      }6 s- U6 Q8 B8 a
   if (yDir == "down") {
4 {! t1 y% c( I. C9 n2 x, b) b! `      if (yPos > (yMax - contentHeight - BallSpeed)) {
; \$ T2 L* }: k8 a0 u         yDir = "up";  n& z! r; n7 Q. Y
         }
( d' z" F0 U, s7 V1 T$ ?1 ^      }
( F5 ?; j$ z  r- }# C8 C   else if (yDir == "up") {9 I. y4 N' [+ \
      if (yPos < (0 + BallSpeed)) {
2 B3 j0 L0 n5 ]" Y         yDir = "down";6 N/ J0 m' V+ T+ P
         }
) y3 d/ l' o/ x1 |      }% b' ]  [4 d0 W4 v' z$ z
   if (xDir == "right") {
: r% B, \* {/ N0 Z7 P/ T; w- ^: r      xPos = xPos + BallSpeed;
  ^% \# k3 U- w. x. ~      }( E- I' @. @9 x& w( o; J
   else if (xDir == "left") {
2 m  I% G+ B* ]. V* g      xPos = xPos - BallSpeed;
: L' f, r8 d3 I# J$ G' @+ @$ D      }& ~# }! B% f. Y, T1 E
   else {) c+ K+ ]6 Z' B7 ?: i+ E, x
      xPos = xPos;/ G' s5 o2 d, |' O3 b
      }
6 P6 u) p: |$ c9 O   if (yDir == "down") {
1 k, g. `5 L* N7 k* Y0 J9 [. |      yPos = yPos + BallSpeed;7 t3 V9 r- X6 j; A& \8 X3 }
      }
' t8 N4 I' I) B   else if (yDir == "up") {( h. |% ^! A4 b! X5 l; E) A
      yPos = yPos - BallSpeed;
: W/ v7 N6 J) F      }
6 }' O. w1 ^( e! F5 _2 I7 Y# V   else {. R6 P8 ~% `! M  [
      yPos = yPos;
. m0 V" \& ?6 A; n      }
6 x" \+ l# a/ o* ~9 Y' c! `   }
' e+ S+ {6 f" J7 e1 `% q/ m; N$ [/ E: }
function hidetext(){. l) u  h/ x4 x# l% `
if (document.all)
  p" ]: ~8 \9 u* z( d0 Y7 t9 X! ysupertext.style.visibility="hidden"0 A; Y8 N' W& I3 F
else if (document.layers)
2 D4 j! |7 [- W# C+ m" J3 c6 [document.supertext.visibility="hide"
) H# d$ e/ Y% S3 [4 gclearTimeout(animatetext)
7 q- e8 p4 I' W7 O3 [$ J}
/ Y/ Z5 P& @+ M: M+ U( @/ L) H; M" y8 G
if (document.all||document.layers){4 {+ V( F! p; j/ n) W, v
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
( i7 ^9 b1 i/ [window.onload = initializeBall;$ ~: q3 ^. K" g0 s3 N
window.onresize = new Function("window.location.reload()");5 Q# H( v: D" B  C7 m
}# o  z: u6 h+ d$ I

" @' f* q2 B# m0 X! J$ l</script>

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