返回列表 发帖

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

<style type="text/css">0 a* V( H( O$ }) M1 X# q
#supertext {( u* E2 D& t6 X) d$ k1 W# j2 @
position:absolute;! z2 ~  h7 f. ~1 W& A- F' i" h
left:0;3 p. f6 Q+ g0 r  p
top:0;6 ?/ r% y( G: ^' S
visibility:hide;
) S- b9 u. @( M- L' ovisibility:hidden;
5 X; Y8 C$ E1 n}) d! L; r2 N7 X( [- Q# G
</style>7 _% r6 N0 W# ?! v# z2 T5 z
<script language="JavaScript1.2">
* M& I) `$ t% X- b* q<!-- 改变下的字体的大小。颜色-->
* L2 a0 f2 i; k: t6 g7 Qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 x; }3 r& a8 Hvar hidetimer='';* `) }  o2 _, P- k2 v+ @
<!-- 改变下的弹跳速度--># h( i' o9 ^" }2 N2 z, j$ n  g
var BallSpeed = 20;; J! y3 ?7 u; A5 P- _! P
var contentWidth;! W; S% j4 v' a8 v5 L" q, r+ f
var contentHeight;& I0 x0 ~" X' Y# B. v& [5 z
var maxBallSpeed = 50;
9 W( G5 J( M7 S; L" d4 q1 `; u3 r' s

6 y& K9 H0 ^! _" S8 z) `var xMax;6 o# U; \6 a! W
var yMax;
$ X7 ?6 q+ t1 V4 X& [3 l* nvar xPos = 0;0 e7 r) x. _& \: ~! n# ?+ \
var yPos = 0;7 D. M0 I! j5 g. K) n
var xDir = 'right';
  t9 Q6 }3 _. H8 u+ _- ?1 g: zvar yDir = 'down';
0 [$ }% a) i5 d) ~  P3 {- jvar superballRunning = true;" f- F6 \2 l& d3 l
var tempBallSpeed;
; p/ S2 b0 b, e# r% {var currentBallSrc;: m3 \* r6 z$ ^. U. t
var newXDir;
. |1 p! \# j. {9 n$ ^- uvar newYDir;
: \1 S7 x& ~/ b; ]2 V6 r# @, I0 C, H# n3 y' R+ Z/ \
function initializeBall() {4 ]- v5 u" i  V  F, Q8 C* R
   if (document.all) {
; E+ g5 z7 y- i% D7 |7 e. l      xMax = document.body.clientWidth. |0 U! L0 {- B6 \4 `& N9 U
      yMax = document.body.clientHeight
+ U4 L7 E6 b' p% C  u      document.all("supertext").style.visibility = "visible";
1 h  u# R5 R0 u) x5 \+ _. |# v& Z2 E! `      contentWidth=supertext.offsetWidth
) d( y  e1 g3 ~+ [* Y7 k      contentHeight=supertext.offsetHeight
. w* m$ ~7 A( b; h      }
1 @/ }/ j( w% E( V# S$ ~. p: M" s3 L   else if (document.layers) {
) d" O5 w- e( i' s      xMax = window.innerWidth;& v& e2 L+ z) j+ D5 z* O0 E
      yMax = window.innerHeight;5 {4 N( U, b- C6 Z* F2 D
      contentWidth=document.supertext.document.width
, `! i/ t3 {. N' B0 ^      contentHeight=document.supertext.document.height+ N# h( u8 c) G+ S' \& p% [6 u
      document.layers["supertext"].visibility = "show";
% h1 Z$ X$ g* W, e, g. ]  X% l      }% A( z5 m- D" X8 h9 S- @
   setTimeout('moveBall()',400);8 e( d! u( Z5 u' ?
   if (hidetimer!='')( [3 s6 M# u6 c% b  S
   setTimeout("hidetext()",hidetimer)
/ [1 _3 q$ P8 H- t! x8 H   }
3 z& l% i3 k/ [2 f, E
% Y. S( C" q' l* _function moveBall() {3 ?! a, e3 _9 x1 W
   if (superballRunning == true) {
3 L$ E- X4 ]2 |) r7 v; u3 L      calculatePosition();
) ^- V) k$ P7 N! W" I7 o" f      if (document.all) {
* s# ?6 }( T7 ?# |$ ~& w         document.all("supertext").style.left = xPos + document.body.scrollLeft;
* b8 P) V( C- \7 X         document.all("supertext").style.top = yPos + document.body.scrollTop;
1 `* Y) F8 J( K0 g         }
+ h+ [9 u0 E5 h9 c      else if (document.layers) {. e, P* D! }2 Z0 ]' N0 ^0 M
         document.layers["supertext"].left = xPos + pageXOffset;7 J. o, c- \1 g
         document.layers["supertext"].top = yPos + pageYOffset;
4 b7 g3 G3 z6 \6 b         }
! \& D: d+ V- t' p4 f      animatetext=setTimeout('moveBall()',20);
! X/ W7 M) u8 D% x. q      }
2 B( a) o4 e8 J( Q9 ~   }
6 a+ m+ T8 m3 }% k) v. S6 V/ a) T
function calculatePosition() {
7 l% B- h" k8 S) |1 h/ K   if (xDir == "right") {8 A% f2 u- I4 B8 @& W$ I3 X
      if (xPos > (xMax - contentWidth - BallSpeed)) {
, U# p* \' x, V2 ^( T         xDir = "left";
0 \$ f, f! d7 d% ~, ], `2 O, y         }
# I' K& o% ~. _" i' Q/ e# f      }3 W- T) P5 [8 t* K
   else if (xDir == "left") {0 a3 {" z# @2 P* {
      if (xPos < (0 + BallSpeed)) {! h2 a7 ?5 K5 I4 H7 g1 S9 g6 H* U
         xDir = "right";" L- G, T' H: O# w7 m: A, N$ V
         }
/ V& T9 V5 `7 E$ N# A1 {( D0 D      }2 M  ?. k! S% X
   if (yDir == "down") {+ L2 t9 P: Q9 ?& N2 Y/ p+ K
      if (yPos > (yMax - contentHeight - BallSpeed)) {
- n( k6 \1 T& J& J         yDir = "up";
; H# y5 n+ a% U/ p( e( o         }9 ?( m' @" K) T# k
      }
- }' ?' W. r4 o) ]7 J* X4 C   else if (yDir == "up") {! i- v& t7 Y3 Q( U+ g
      if (yPos < (0 + BallSpeed)) {
( _; o) W4 p4 s. d; G( E5 `         yDir = "down";  L$ b. a/ \7 S+ F5 Q/ [: X( s9 L# X
         }* P. e! k" L3 C5 i& g+ q% j8 _. H
      }
1 I6 M0 _7 s; }   if (xDir == "right") {1 c% R8 c' g* j
      xPos = xPos + BallSpeed;
* I" r( c0 C+ _% _  g      }
8 m- i: L1 b: d. o6 ?' e' P" r   else if (xDir == "left") {
6 Y; a, x5 A( u+ ~7 z      xPos = xPos - BallSpeed;. |; w* j( Q. P! d) Y' h; }
      }
6 ]3 _0 }# N( j   else {
- T; l! n# u4 Y! Y      xPos = xPos;
( D% h& ?1 @' x. v- |      }
$ e) i' Q/ Z. w( Q6 Z7 r   if (yDir == "down") {
2 A4 @0 O" _- D: j. G' E8 b7 g" ]      yPos = yPos + BallSpeed;
5 o) o% w/ M$ v8 U      }! \% a/ |' W! b6 f" c& S/ b
   else if (yDir == "up") {
7 E/ n' e; P( Z6 q$ E; R      yPos = yPos - BallSpeed;6 w7 ]4 V' T! E* W/ Y9 J
      }- P- \/ l% n  ]: v5 K3 S$ |. q
   else {6 P* x/ {, {, Q: ]6 o4 p- v* v
      yPos = yPos;. d# P% C. Q5 Y2 h+ ?: `
      }
: l* }* @2 P1 k4 F( I   }: _7 Z/ E! t6 D/ Y. V0 K

+ p2 F3 H; A6 {- J2 Ofunction hidetext(){
9 e5 s& ?3 s& j' b' d) g" Cif (document.all)
$ N, ]! L* T2 l+ K7 f, Wsupertext.style.visibility="hidden"$ J  {" s8 y* v: E/ u7 \
else if (document.layers)
4 e* u* {4 H1 ndocument.supertext.visibility="hide"
3 l3 D3 T- B1 X+ q+ j8 fclearTimeout(animatetext)0 H9 W2 \3 N, {3 V# E% h) Q
}
6 m6 ?2 }) ?" k) f# m) F0 G' s
1 Y! d3 G1 b6 C! Mif (document.all||document.layers){
# x, I  W' o# ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! l" p, n6 {8 Z6 z+ h' }$ W, ?window.onload = initializeBall;  a, q; O: L* G9 U
window.onresize = new Function("window.location.reload()");
/ K4 p- L) c! W}4 k1 i/ k+ U" N) x# I7 v
" h9 _$ C% o! f- O
</script>

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