返回列表 发帖

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

<style type="text/css">( i& o: C; w3 y
#supertext {
- a! d5 Y( Q7 j* wposition:absolute;; f- b8 g3 n1 V& @9 _( S: b. P
left:0;
5 O/ d! K$ t/ H" N- }top:0;
; D* f  k2 `8 x7 M( N/ T  Bvisibility:hide;
* _2 l9 a# S1 [4 \' Mvisibility:hidden;
  H9 j" B4 }  _; _9 D}
0 L. l. D3 \* K+ v</style>! S7 J# v+ B  S$ c9 |- H. q: J0 q
<script language="JavaScript1.2">3 `6 b! K+ ~" k5 H, i, C
<!-- 改变下的字体的大小。颜色-->1 n' C5 m" J6 s! j, k
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 i- N- I2 {0 A  E4 `var hidetimer='';
8 |) Y; x4 Z& o. B1 M<!-- 改变下的弹跳速度-->
. ~- ?% ]2 h5 ]  Cvar BallSpeed = 20;6 X( `2 i+ n1 [( A1 f8 d, [
var contentWidth;
; V- M7 C" |# uvar contentHeight;
7 g' r2 z# \1 N' y0 a7 N# l6 w% fvar maxBallSpeed = 50;
* q" ]' O; g6 ]* q( e! E% M' n+ J
( U* C1 c5 W  l; M# H0 Y
: f/ ]/ o; \  `# b' Cvar xMax;
2 l* T& W$ o2 N' F: C5 h2 f4 lvar yMax;" Y; S8 W% u9 Q  i
var xPos = 0;0 H- g' @7 \% Z+ e0 }
var yPos = 0;
7 L: [# ~# _9 I3 \8 o& o9 b8 dvar xDir = 'right';
9 `- ?6 [1 N6 ^) Xvar yDir = 'down';
7 U  @/ V1 Y/ ?: G! n) jvar superballRunning = true;1 L; x3 P8 x4 K% e' ^, d4 W% _: f. X
var tempBallSpeed;
/ Z5 n5 q6 A& R; \& ]9 W- cvar currentBallSrc;
5 y5 Z6 m4 \: O$ I' K1 e5 Dvar newXDir;9 l: U1 @6 |# U' s
var newYDir;
. q% ?. f# ~, e3 a  x
4 }: z2 o7 N5 w) p' I. w& ifunction initializeBall() {1 K7 ~! z: \1 g& R- Y
   if (document.all) {
7 `) [; i" q$ v" U9 y      xMax = document.body.clientWidth7 l$ Z6 `% u( S3 w/ C; x9 x
      yMax = document.body.clientHeight
) o, q6 @9 e! J- |, n      document.all("supertext").style.visibility = "visible";
" ], T* r0 Z3 `5 I# U6 J$ p- s6 I      contentWidth=supertext.offsetWidth
6 H% i' t. f- Q8 k2 f' q6 a5 X& ?$ x      contentHeight=supertext.offsetHeight' z/ r. I+ N7 X) {
      }3 v/ ?9 G4 k' x0 z
   else if (document.layers) {
3 f- c  @4 a3 g* L      xMax = window.innerWidth;; Y" M; E9 r+ c" z. G
      yMax = window.innerHeight;  u9 E$ }" w7 l6 ?3 C
      contentWidth=document.supertext.document.width
& ]- d; z* H7 ^( X/ |8 \      contentHeight=document.supertext.document.height+ s8 i; N& P; X! x8 ]4 p* e5 Y1 r
      document.layers["supertext"].visibility = "show";* U" o& l' `( l8 _: A
      }
  E4 C& {7 r- g5 F) h) k   setTimeout('moveBall()',400);4 |. P4 a9 b$ V/ w+ N
   if (hidetimer!='')1 h, b5 x9 A. \, h0 k2 W
   setTimeout("hidetext()",hidetimer)' K- L8 N" m9 z! U5 B( q; v" z
   }
8 {! m: u) S; ~# }
6 i' I' d( E4 c8 T0 Nfunction moveBall() {
1 V* Z2 {' z8 u% s   if (superballRunning == true) {  q6 S2 F3 k! g" j
      calculatePosition();
, a' T, S# n  l      if (document.all) {8 M( C" ^9 p7 B' q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. V2 ?( I2 z$ j0 h' [         document.all("supertext").style.top = yPos + document.body.scrollTop;
- Y( W- Z5 U0 V- D, q1 f$ i  M; |         }% |3 O& A5 @) {
      else if (document.layers) {
2 h: X8 a0 s! U* k  s         document.layers["supertext"].left = xPos + pageXOffset;
% S/ G( |5 ^; q. i& ^, w         document.layers["supertext"].top = yPos + pageYOffset;. O& D$ [6 F, o' y. \  g- {' Q9 g; Q! ^
         }7 A5 @5 F2 I+ g. H. h
      animatetext=setTimeout('moveBall()',20);
- h+ M3 c7 U/ h; f2 `" F      }+ q7 |6 C; |% P% _0 C5 Z
   }* a6 S( G4 a4 X. Q

+ w8 }6 Z' i6 p0 zfunction calculatePosition() {
1 w+ w- }% A& S2 O7 ~! }$ ?   if (xDir == "right") {( p  q) J5 \+ p& c$ c- _
      if (xPos > (xMax - contentWidth - BallSpeed)) {
0 Y' S% H' r6 W, v" \9 K         xDir = "left";3 f  t; e/ b5 F; X
         }
1 B1 S" D; K, a, X; [      }4 Q/ q8 \' I  A& D0 w& N
   else if (xDir == "left") {
- A$ M% L$ }4 O( h- I      if (xPos < (0 + BallSpeed)) {
. s0 c' M9 h9 i* g- b         xDir = "right";! G' J2 i- n/ G" |$ {. g
         }0 G; k( H$ s7 T  F4 r
      }
5 r+ P: p/ c7 s6 g; U  Y' Q3 y' t   if (yDir == "down") {
* m; x+ l3 a0 u# a& T      if (yPos > (yMax - contentHeight - BallSpeed)) {
" Y+ W/ X) Q! b8 ^* R7 u% Y         yDir = "up";4 W; S/ g  |0 x% X8 k! m
         }
" F$ I: d/ T4 x- a; H% q. f      }# A2 O# u2 [- U3 u* i6 M# Y
   else if (yDir == "up") {
4 q, d+ V- V/ H; F  L! f5 B, v      if (yPos < (0 + BallSpeed)) {
0 D& ?0 C+ }9 ]2 w8 Q8 }: @         yDir = "down";
% L. e* d2 \; m1 J3 B; [         }0 D+ S  l! @$ O
      }
" B$ g" c" P1 M; v% X7 ^   if (xDir == "right") {& H% S; _3 B7 U$ k
      xPos = xPos + BallSpeed;
) C: ~# {- M! t( ^9 e2 L      }6 w: o+ ]( k& G
   else if (xDir == "left") {
( ^5 m8 f0 l1 @8 g      xPos = xPos - BallSpeed;" e, B7 ~3 q& g1 Q2 _) N
      }
6 t9 e. S! g! ]   else {
" R. w% C7 e! Q+ h, O      xPos = xPos;% ^# h' O( _/ s3 ^. m
      }
. Q! R  @8 e6 F6 T   if (yDir == "down") {
0 g: _6 x' x" V  T5 ^      yPos = yPos + BallSpeed;
4 F; {; ]- \$ q4 |/ x; Q( \% f      }% ]) @& u) A' A  Z- h/ n; R; R
   else if (yDir == "up") {4 O$ Q2 J% ~2 D
      yPos = yPos - BallSpeed;% r+ R0 w% y) N" |* q, r2 C! G
      }
2 R2 x5 X* Z: o3 s! x. k4 O- \   else {
0 N- M, T9 s$ A1 h0 r* M4 D      yPos = yPos;
+ c/ D% c7 u" H9 h9 f; `0 `4 @( {      }: g- A  C6 M& q  L& s2 @
   }
2 Y8 B7 b9 C  b7 K* m6 Q: D& t
/ i9 T: Z1 u* f) B+ o1 lfunction hidetext(){
7 [9 C% f! D7 ~1 |" pif (document.all)
6 r' P* Y- L1 u7 o' L5 Isupertext.style.visibility="hidden") _& _- o( {, ]- M
else if (document.layers)3 ~$ i$ }9 o/ m
document.supertext.visibility="hide"
: j) W/ D5 }# F0 d7 jclearTimeout(animatetext)
, b; N4 C  s* h( I5 _* p9 U) t7 R}! P# c# w0 `6 z0 n
' v) h# [2 v4 }5 C7 |& t
if (document.all||document.layers){0 ?+ D3 V4 ]! C* r5 u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ }9 C% G# J: r+ }1 g
window.onload = initializeBall;
5 ]' I1 o+ [  ?window.onresize = new Function("window.location.reload()");" J  A3 d" l9 T5 d. H
}7 \& A; ~! }, |- H* e

1 j  b! D2 Z# B! k" k$ O</script>

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