返回列表 发帖

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

<style type="text/css">% Y) {: ~' j( w: t
#supertext {
3 A6 z' J! `" ~5 j/ Aposition:absolute;" S3 Z+ `- f' K! C
left:0;
( ?# S( G  k; _1 K+ ^top:0;
" k) t' S. ^- I- m4 ]/ J  Lvisibility:hide;
( m1 P6 O3 |; v  K4 dvisibility:hidden;
- B$ L. T0 ~' V  V}
% H' I* [  d% M) c# `</style>  O: |) f2 X$ P% V6 }, c7 d
<script language="JavaScript1.2">
7 }. Q9 {8 [# i6 |+ [) @( D) g<!-- 改变下的字体的大小。颜色-->
1 o7 j- n3 p' `var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 m7 }: B; \+ |var hidetimer='';# @" v/ p. S; o
<!-- 改变下的弹跳速度-->
, g+ g/ G9 o8 w& I) {var BallSpeed = 20;8 A0 u( C4 z* L2 W' U9 g
var contentWidth;
  z5 Q1 n/ s+ o: T4 l5 {var contentHeight;! u  C: r+ r" V8 v; H
var maxBallSpeed = 50;" c$ H" Z! _; m4 e. B

0 v8 v, S$ M" c4 e$ @; y( f! ?' V: F! w+ J1 I$ p1 t( u9 m
var xMax;
5 ^- _" A4 P. j+ Rvar yMax;
9 }* z* F% W* L, n. o) tvar xPos = 0;0 X! ~% n; Y5 h  `
var yPos = 0;! c8 o" P7 R' D9 l
var xDir = 'right';
9 ^! Q2 q+ |  P4 Y. B( G: m: Bvar yDir = 'down';, Z5 U2 @1 R5 D; E
var superballRunning = true;) k$ X8 A; l7 u
var tempBallSpeed;
' z4 R- M, {8 t" Z2 p- fvar currentBallSrc;
$ ]! G5 E9 A( qvar newXDir;( o9 O$ f- @2 e' d  k
var newYDir;
" a' A7 X& _4 K* f
6 C" b5 R9 ^( W  R5 V( Dfunction initializeBall() {
" ~' w) y6 w% |. _   if (document.all) {
. D( p, g: Y6 m/ L4 `3 Y' g      xMax = document.body.clientWidth$ b& S! k; Q5 y
      yMax = document.body.clientHeight
! a4 W" M3 P4 B$ e      document.all("supertext").style.visibility = "visible";
; Z1 v, X- V! O4 r7 d      contentWidth=supertext.offsetWidth
% U' l% C$ V- P7 o, \3 k      contentHeight=supertext.offsetHeight# c3 R% W: u8 _6 w, g
      }
; Y$ {/ `* u) ?% l9 s   else if (document.layers) {
, d) Q: S( `! F1 B) F- N6 x      xMax = window.innerWidth;
" @! n; H9 h% i7 _4 B# e% ~      yMax = window.innerHeight;
$ s1 T" y" ?+ V  l  L      contentWidth=document.supertext.document.width
/ q1 a# g0 s+ W      contentHeight=document.supertext.document.height1 `7 w8 j) U2 |+ W
      document.layers["supertext"].visibility = "show";6 A3 S( W5 t# H( z
      }
: E% T$ _" j5 p. z1 F, z0 |5 H   setTimeout('moveBall()',400);- @/ u" K) a% x- S0 s1 h
   if (hidetimer!='')! a7 p0 ?& U9 w7 g
   setTimeout("hidetext()",hidetimer)
6 x3 E* ?* s( M' D' q/ ?& h   }) i" U1 |8 z- E  I% j

$ D) t  ~, _8 j1 _" ?function moveBall() {
/ V5 b+ w; U5 W   if (superballRunning == true) {- ]  R) d+ [! X, V  s
      calculatePosition();6 y8 z3 V1 X7 Z  L- o9 Z9 R3 A9 [2 T
      if (document.all) {
2 b2 `* o) G/ D+ `         document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 Q6 b# p0 s7 A1 _- p3 @6 t, T+ \         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ R; j: Q/ t- D" P, k% b         }
- G2 a6 {! P' D' R) i$ @      else if (document.layers) {
- j1 u5 {3 F) T7 F: t/ A( H5 M1 b         document.layers["supertext"].left = xPos + pageXOffset;! Y% C5 t. r5 ~- D- c& g8 N6 c
         document.layers["supertext"].top = yPos + pageYOffset;7 j- g" h; s' J. t) y
         }- Y+ s" ~0 T- H6 N& m- d2 s
      animatetext=setTimeout('moveBall()',20);# ?& e4 g) B7 O5 h' e! [, r: {
      }, f6 O* [+ V! c: _( Q) m
   }
# A3 w( q, l; w1 o/ B7 X: Z5 B- }# `( B% h7 p
function calculatePosition() {, \, ]' }. F$ @  p* h/ t
   if (xDir == "right") {
# N+ f- S3 g$ H+ s* @      if (xPos > (xMax - contentWidth - BallSpeed)) {
/ M9 y& k, A+ G. r, N# _         xDir = "left";
) \+ f! t/ i- O" n8 H# @" U; S         }& L: E9 q! a4 m2 t5 x, _4 ?8 H
      }# o' k3 m5 a( [: d
   else if (xDir == "left") {" B' @+ A0 H9 h* X* ]1 ]
      if (xPos < (0 + BallSpeed)) {4 i0 D- M, @; |
         xDir = "right";
, c2 z- o9 o6 P+ W# ?1 w         }8 }- X8 \2 `3 v1 u( x3 r( d
      }
) r$ [7 r# F. [1 \; S6 c0 `; u   if (yDir == "down") {7 e7 t4 T& n. A) e/ M3 l" U( b
      if (yPos > (yMax - contentHeight - BallSpeed)) {
% l  {4 _9 o: I2 M         yDir = "up";
5 A3 W) {( j, B# W         }
' c1 B, B& @1 Z- K7 {! [      }
: c& [* G+ s* y4 T5 m* `- `+ C! t   else if (yDir == "up") {! k% ^$ D' t, Q1 i0 `) W
      if (yPos < (0 + BallSpeed)) {6 B5 n$ T# D/ X" b( A
         yDir = "down";
7 m% ^6 M; e4 p, L4 ?9 g% X         }' W$ m7 t  r7 {$ l3 o
      }" Q. w- j" g6 j" L& b
   if (xDir == "right") {
. |  X! S& u# O" K/ i2 y      xPos = xPos + BallSpeed;# j  a/ r- L' f
      }  j) d9 g1 T" N8 @* O6 u
   else if (xDir == "left") {5 }- O$ b5 b" z+ p8 u8 j7 x! Z' {
      xPos = xPos - BallSpeed;) l$ f% ^, G' [
      }
% e/ m. o* \" k/ B) H# }   else {
" l4 X% e5 U  j. _4 T      xPos = xPos;% G; U8 E0 }- `1 [
      }0 `# g) U& h2 G
   if (yDir == "down") {
& L/ Y/ }2 f) b; R7 b0 |      yPos = yPos + BallSpeed;
# D  E( v0 q1 h, y' t) |      }0 c5 h; [7 Y* d5 v
   else if (yDir == "up") {' b2 b/ d: ]# \- m0 u7 H
      yPos = yPos - BallSpeed;
3 ^8 ?3 f2 L2 i0 B      }* o# [) \+ A1 ^
   else {
( h, g2 m, V$ r2 {7 @; o      yPos = yPos;
+ ?; `0 p, h- i& A: n      }- E! N& i/ ^. F! T9 }
   }  l! o, S7 `' s

" t$ J+ O1 w# T" d) \: Tfunction hidetext(){2 I: L* y& g0 G, m$ a
if (document.all)
0 H- K, L* r" a5 b, Wsupertext.style.visibility="hidden"8 f. L2 T  U) Y
else if (document.layers)
1 Q$ Y5 \# E/ J$ O  y/ kdocument.supertext.visibility="hide"
$ p/ Q8 _7 `9 x, c, W% TclearTimeout(animatetext)
6 N, ]5 h2 @, s, [" w* f+ e}
, D; }9 ^- Z2 S, w0 q. s9 s, j1 g) w, z3 r2 j- Z
if (document.all||document.layers){: A9 ]  {; y# I& \% E4 `1 a' G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) o9 {! P. q/ y2 `3 x  p( G/ [window.onload = initializeBall;9 z. K0 E9 Y6 G: ?5 w7 Y. s
window.onresize = new Function("window.location.reload()");
/ k5 p- h1 V* D5 R' ~% o}
) l0 {/ j8 s) C- B8 r7 B- ?" v. c) u% n, g
</script>

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