返回列表 发帖

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

<style type="text/css">
" R* I3 {5 G+ }8 p9 c9 p* E- Q#supertext {( e/ r- ?; _* n9 k) S
position:absolute;
0 V; D5 ?8 [* E. Hleft:0;
2 i1 z: Z. l; ?2 ]top:0;
2 n: f) n9 p9 \% p! Y; i: |visibility:hide;9 N% D6 c( f; I- ^
visibility:hidden;; r" T; U( S; m) ]
}  B/ _# x' r' q" g
</style>( A2 Z( z  u; R" D; `0 j1 c% n
<script language="JavaScript1.2">
: E2 U! ?1 |) Y0 V. V8 A) L<!-- 改变下的字体的大小。颜色-->4 f) |3 M& G! @, p$ M& _/ H8 B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
$ W5 P7 l0 ]5 W7 Pvar hidetimer='';
. i" k& T- m  Y5 T<!-- 改变下的弹跳速度-->
9 C  d# x; X. I# Evar BallSpeed = 20;
7 }# o' [- d% d' f% Vvar contentWidth;
/ K& W9 D. x6 s8 Cvar contentHeight;1 N' A* ?. f+ z$ U
var maxBallSpeed = 50;% K% \+ ]% N  h

+ `3 f; e- o- z$ t6 u6 Y
) V/ S+ H' K3 k, Ovar xMax;2 J/ k: C, q+ G" f" ?) n! c
var yMax;
, f4 v9 I4 E# ?, Y( v1 \3 @var xPos = 0;! _. \! ~: }  L3 J  Z, O
var yPos = 0;& f, G! o& l" y. J  q- f# C2 `+ t
var xDir = 'right';
, \, i9 X2 \/ F, A3 A+ Nvar yDir = 'down';
. T1 M# T, O& ]6 rvar superballRunning = true;, }6 s0 R& s  S6 z) [' l
var tempBallSpeed;5 i& H2 s$ q6 n0 O) F
var currentBallSrc;8 M2 C5 N* L$ Z' W
var newXDir;" z2 t, x" \7 H' j& N+ m( @3 d7 M
var newYDir;
* m( q6 w% u# @
7 \( ^$ W* n1 e$ h/ x& Ofunction initializeBall() {) s" C; J$ B% s
   if (document.all) {
+ H$ b$ o* |1 W, e+ y! ]1 v      xMax = document.body.clientWidth
+ I5 z5 N# w6 d+ \      yMax = document.body.clientHeight
! A% f4 u* a: d% ?      document.all("supertext").style.visibility = "visible";
* {; {9 l0 D7 S( w      contentWidth=supertext.offsetWidth
* e8 j" O; |! ~: F; j5 P      contentHeight=supertext.offsetHeight* ^' o, K) |( j  ^% R) F$ w8 M7 @
      }& O4 w: j6 X& w4 |# P& Q
   else if (document.layers) {
3 ~6 w3 T8 P4 n9 ]      xMax = window.innerWidth;3 }$ \9 w8 O- E8 B. @" X. j4 B
      yMax = window.innerHeight;8 l; E$ c8 R. X" l! j$ [4 A
      contentWidth=document.supertext.document.width: x. [. a% V* A
      contentHeight=document.supertext.document.height, H3 c* [; b2 L! R9 ]$ j" P# I
      document.layers["supertext"].visibility = "show";$ i* h) ?; h' |% ]$ D9 `
      }
  W2 h. D) }+ y   setTimeout('moveBall()',400);
$ s; K7 q' q" E1 b7 c- O   if (hidetimer!='')
, ~7 B$ ?8 c; y3 S   setTimeout("hidetext()",hidetimer)
$ d1 T$ }& O) i# G   }2 U/ ]8 q! }* Q

% M1 c/ `7 n* ~+ Ffunction moveBall() {) @; k3 ~$ ?7 c% F
   if (superballRunning == true) {- {6 L3 ]  _& Z" m) d" w
      calculatePosition();1 Z* V6 Q( M5 V$ c
      if (document.all) {
5 x0 ]+ @; u9 u  t' s1 z* A         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 @3 s! o/ c% r
         document.all("supertext").style.top = yPos + document.body.scrollTop;8 z& l) ]5 o3 o. k% _5 v
         }' K: n4 G* l/ m6 \0 x3 ^
      else if (document.layers) {
0 ]# \* V% C: L* ]         document.layers["supertext"].left = xPos + pageXOffset;2 \; f: T2 Z% z. L* a. s& e# p
         document.layers["supertext"].top = yPos + pageYOffset;
& `  r3 H* E2 N; b         }
6 N, Y0 A5 n* \2 W      animatetext=setTimeout('moveBall()',20);: T- R0 [. D0 D6 V: k
      }/ w. T, t3 x, j6 ~* k9 y% C
   }& R( w8 @* x+ a3 P
8 O4 c+ Y4 R' _& C
function calculatePosition() {
) Z" ]) L( D# ?4 ]( }; H# l. u   if (xDir == "right") {( U6 s5 N, @/ X3 n, o
      if (xPos > (xMax - contentWidth - BallSpeed)) {2 D3 t$ l8 v' f5 I  d2 f6 Z! w8 F
         xDir = "left";6 ]0 k$ P) Q2 \+ m
         }
# ]4 b* `# n  l6 K! Z& b4 e      }
- E! Y$ `/ v8 T; J  k) {- L# n# i   else if (xDir == "left") {
, U$ h) t6 }. m8 \* O7 k1 y; S      if (xPos < (0 + BallSpeed)) {; J9 c# Q, W( l/ X  r
         xDir = "right";  s0 {; I6 U. V( a; H& q
         }
7 S' E  V$ d! r) b1 J6 l! V      }2 O  S/ A$ ]4 U4 W2 k
   if (yDir == "down") {& p" N# B, P2 f* @- F0 {
      if (yPos > (yMax - contentHeight - BallSpeed)) {9 d  V; J$ e4 H2 U8 ^1 \% {! U
         yDir = "up";
& S# u9 D8 P$ x- M* v3 `0 r         }
* z7 ?' L4 M4 f5 j# A; K$ p+ l8 a      }% Y( y: v' R  L' i) Y8 j6 D" }
   else if (yDir == "up") {' w: G/ p/ Q  E# L5 e3 n; i/ u
      if (yPos < (0 + BallSpeed)) {
, ^! D' R2 L# K: X! Y( l! h8 K         yDir = "down";
) N' y% ^. l) P& j7 D         }2 M  v0 e. J3 u
      }1 ]$ H2 T: Q4 r" C
   if (xDir == "right") {) Y; I; b; i1 _
      xPos = xPos + BallSpeed;$ u( Q! g$ Y7 B7 s0 h6 Q) S- i
      }
# ~5 ^" P4 x5 |3 ^   else if (xDir == "left") {7 s% _8 l* }3 @1 m  ~  m( U3 z& h
      xPos = xPos - BallSpeed;
8 O5 i, q; R. n, t, j      }
. \* z# n2 e7 K$ ~  X( ~1 l   else {
8 d9 ~9 d5 P) j) s1 Y) d      xPos = xPos;
, [; r0 j4 w" [" Z* p% ~0 [4 B/ ?% R      }' S6 `. E6 u! d
   if (yDir == "down") {- K% V3 D$ {+ |
      yPos = yPos + BallSpeed;1 I) Q7 H3 a: P8 X. e
      }
: l9 w0 E1 d  i- c   else if (yDir == "up") {
3 T$ J  h) s1 w" r4 w% P      yPos = yPos - BallSpeed;( }6 k6 H; h9 y8 ~0 X
      }
9 e$ S- K  Z6 h( N   else {8 u: ^- U! l; \. `4 E) y/ N, k7 c" P
      yPos = yPos;
3 [5 S; q2 z0 |( j5 ?* R      }
* ~, L% u: v. C1 J3 h, {' {   }
1 w+ @: s6 K- o; G3 K% j* D
) m( i: c4 l1 ]# U% y4 s+ ^function hidetext(){# H" ]8 y0 _: w$ H) B! _- |' t
if (document.all)1 X5 ]0 Q; S  S& H) s5 c
supertext.style.visibility="hidden"- i0 ^) L8 u6 R* L2 Q
else if (document.layers)
4 i4 |0 ~9 s. w( l( d0 y: t8 l' Hdocument.supertext.visibility="hide"# t( K: q% X' _* X9 B, l1 X
clearTimeout(animatetext)
$ x; M. h9 o# `0 ?1 ?}5 S( j* `- @1 j' Y! z" k7 @

9 q( e( G) }* n; Sif (document.all||document.layers){& L! x; |  R1 @+ |# {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 w  X3 z, _( e0 Cwindow.onload = initializeBall;
  T8 N& |, n8 P1 R9 i0 ~" Bwindow.onresize = new Function("window.location.reload()");
5 S; B/ f$ ~  _' W# E}
( ~% J! m7 y- [* b, }$ ~8 T( o9 B
</script>

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