返回列表 发帖

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

<style type="text/css">1 S1 J, r" G, ^( U0 y
#supertext {
/ f; _, U# K3 [. {' {position:absolute;! A% D) [; V" Q/ K/ Y
left:0;- T3 ~7 Q9 p8 N' k8 J6 k7 e* ]: [  l
top:0;* f6 Y' d0 T7 E% R
visibility:hide;
( F# o7 e& _! Cvisibility:hidden;
( o6 V: C! ~/ B  ^1 I$ i}
& D2 _- {- h6 n5 h% j" b- ?/ T2 A! W2 `</style>
' F$ Y! c0 O' `- `! O4 C* I/ O# ?$ r<script language="JavaScript1.2">
/ w  Z) E% Z6 @<!-- 改变下的字体的大小。颜色-->
) K% y2 V2 k& k" @var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'; h& C, r+ }7 B. i; N
var hidetimer='';2 y- }, U1 I- G* g+ ?: |
<!-- 改变下的弹跳速度--># o7 d* P3 W% q. G* P. C
var BallSpeed = 20;0 h! z- V9 z5 |1 N- y
var contentWidth;
& Z9 _5 k8 K4 E. ]# E( M% m) lvar contentHeight;
+ T$ J! g3 t& O/ _var maxBallSpeed = 50;
( u. J- s0 [6 @0 h0 w2 w* e3 L# {1 ^: h" H; R
2 d/ y8 s; J+ m3 j0 t+ x' K* y
var xMax;; T  C- y' U/ Z6 P6 f3 i2 @* \
var yMax;
0 W7 q9 k) f9 O$ v7 {var xPos = 0;; E( G$ n/ n" ]; p) ^. e. u
var yPos = 0;
) Y# f5 N* W$ o, _; Xvar xDir = 'right';- }% Y7 A. n  w
var yDir = 'down';
; m3 ^1 K  o9 M  ]2 E; kvar superballRunning = true;
" e) @7 Q, H6 |+ L% r4 W/ Lvar tempBallSpeed;
* ^" W7 b, b& Xvar currentBallSrc;
' N4 n1 E5 @1 F: i; y4 d( evar newXDir;2 J1 e' w" a( h5 V: b8 d
var newYDir;
; Z% c  q# A# @: b( J. u9 ~! x" v/ P. [3 g+ T
function initializeBall() {
  X  X; \0 V8 a4 Z   if (document.all) {
2 f- P, W; s2 A/ E8 s      xMax = document.body.clientWidth$ J2 e: o0 {  Z
      yMax = document.body.clientHeight" k6 _0 X0 j$ k  U: K0 o' B: T8 o
      document.all("supertext").style.visibility = "visible";) o4 X3 w* a( A$ a# D
      contentWidth=supertext.offsetWidth9 ^1 n0 d* ?: M) I( z. {8 D
      contentHeight=supertext.offsetHeight
. _3 z' P; f4 c+ }' Q' J      }
9 Y6 a+ q& h' P   else if (document.layers) {- d( s: m+ f2 d- P9 E$ ^0 a4 [
      xMax = window.innerWidth;
! z# }  d5 B. |1 s* x! a      yMax = window.innerHeight;
* B  l2 J% K+ S/ i      contentWidth=document.supertext.document.width# o$ K. N% R$ \9 G
      contentHeight=document.supertext.document.height
; h& X% M: \  x/ {3 w      document.layers["supertext"].visibility = "show";
" L+ J! S7 ]2 u$ B      }. Y6 a: |. x1 V
   setTimeout('moveBall()',400);
) ]8 G0 d# |/ H4 I2 m, }   if (hidetimer!='')2 x  _" A7 e, S' q  {  g
   setTimeout("hidetext()",hidetimer)
3 G6 c- H" ~' {) X   }8 X7 F: n- Q' q9 Y8 R: F! P8 I$ l& g
9 W, i; Q$ q/ l1 F! U8 r" N8 g
function moveBall() {
# Y) P  L) K1 N. j" O   if (superballRunning == true) {
$ v  c# R' `$ t/ ^      calculatePosition();
. l8 k3 Q; M( |/ v  e      if (document.all) {
5 h, M% n( }2 H) `2 h         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 g1 t9 F$ c) v9 H% R         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 b: M/ K1 z6 i* U' B/ C( t9 L         }  }& P) @- T8 J, {1 L9 V
      else if (document.layers) {
6 @9 L3 P/ B& _* Q         document.layers["supertext"].left = xPos + pageXOffset;! K3 B2 q8 L! `0 h/ d+ K
         document.layers["supertext"].top = yPos + pageYOffset;5 p! E3 {4 U; u; e/ `
         }0 C5 n* W( _# a5 |. |
      animatetext=setTimeout('moveBall()',20);
5 G5 c7 P. I$ O0 `1 r      }
7 F: g9 u1 Q* R# v   }
* }, W; z! o& |1 y6 j: _6 V1 J: x% W5 m# C7 f" S. S% p9 h( J
function calculatePosition() {/ q. ]1 A7 R  I7 P: G) d3 ?
   if (xDir == "right") {' b" \0 P1 w- x; f2 w; C* J& c
      if (xPos > (xMax - contentWidth - BallSpeed)) {
4 h3 l# D1 ]% o1 Z$ T         xDir = "left";: _, r/ i9 f5 e
         }
8 j8 @/ h- v2 e$ `      }# T6 C& r& W! ]# R  R
   else if (xDir == "left") {8 U- x$ C8 c8 a5 l7 x  K( [% e5 l: X
      if (xPos < (0 + BallSpeed)) {7 h) k/ E. @; o' `9 n/ f8 ]: E
         xDir = "right";
3 G( r4 E1 Y6 A2 J0 a/ r) T* C( p1 r         }
( x$ c0 H" W; r# _      }4 c1 B7 _/ v5 m5 T# i. i6 o
   if (yDir == "down") {, }, l/ H( g. @# K1 c8 W( S, a
      if (yPos > (yMax - contentHeight - BallSpeed)) {* z& [+ g3 u- M# {% b7 Z* K  l! g
         yDir = "up";( c9 r( M( _9 u
         }/ v( a. @: N* [7 Z2 `: G% W+ M
      }
- D0 f& l; }! `9 W( b/ a   else if (yDir == "up") {' o( A; g+ k1 ]
      if (yPos < (0 + BallSpeed)) {" }+ G' o4 F' y4 S& C1 ^
         yDir = "down";7 H* ?" v9 y4 k
         }7 t2 l" K- l0 W' w* c
      }
5 W3 A! H6 c; i  Y4 ^   if (xDir == "right") {) x: d1 K; Z" N
      xPos = xPos + BallSpeed;5 [  W( u& P$ e' \: ^8 Y# o
      }- N+ L& q  P' r) {& y
   else if (xDir == "left") {) A. p3 i/ G8 j/ e2 L$ N
      xPos = xPos - BallSpeed;* Y/ z/ ?) c& u! w) p/ q' y
      }8 B7 Y# x, d. c3 P9 w8 L* }
   else {6 M& y" ^4 P8 t2 B
      xPos = xPos;
2 n* i8 @3 _6 f8 i/ Y9 x0 n      }- Y# U! C' q. K2 Z0 g7 ]
   if (yDir == "down") {
8 P. P4 P% _8 E- f  @) k2 m0 c% S      yPos = yPos + BallSpeed;  v$ E/ h0 w2 v- n+ o, q
      }7 ^( @8 A% A: M! y
   else if (yDir == "up") {
/ o5 {; q. F  X) [* p* w8 X; P      yPos = yPos - BallSpeed;
0 x% B( n& J5 j, K0 Y" {5 |      }- t; g. B- k/ \$ N, |" F+ u7 X; A
   else {
$ L0 |5 V- A* z. y$ E  {$ Q, D      yPos = yPos;4 @: D2 Z6 a" H& ^1 E( \
      }/ z) ?7 @9 S  d+ i. J3 M7 A4 T' A
   }& b+ i3 k3 U2 M4 V" ^% n# e# t
7 y" n; I( E- }2 @( |
function hidetext(){
  q) I! r. U, |7 |if (document.all)
+ d# p: m- n0 K# Osupertext.style.visibility="hidden"; G! K7 l6 t7 R2 Y; }2 S
else if (document.layers)- e& B) G& i; ~- I& p, q' V! K% p, p
document.supertext.visibility="hide"
4 k9 Q/ h0 s9 |clearTimeout(animatetext)
# r5 a7 }2 m# ~3 Z2 ~}
# {8 O. c$ s$ D* `
6 p/ G! ]  V/ G, xif (document.all||document.layers){* ]8 ~: ~3 O: B5 @! H% x/ |$ |' o
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 g2 e6 ^: h: n  o. C
window.onload = initializeBall;
( c' _1 V' V7 V, n4 S- ywindow.onresize = new Function("window.location.reload()");' j6 V3 L6 X% O) K+ f+ n% H$ j
}
' u8 A* j# v9 E7 \' a7 Z) m- R7 r' q" h7 g1 g" ?4 B
</script>

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