返回列表 发帖

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

<style type="text/css">$ w! T: t) g1 Q# a0 w5 n$ J
#supertext {, q5 c; x7 v" h6 j1 U* D( u
position:absolute;4 n: o% g4 N& S$ T7 g
left:0;
4 Q3 @. {4 B+ ^- Q9 L2 R. _top:0;
. L# i! i8 D! t; o4 Xvisibility:hide;
0 ?4 s8 D) }' Q  Evisibility:hidden;2 H  l0 y5 o! E* j% p/ f
}
& v/ g, b* L3 k% B</style>- I* g* a1 K; |" L, O" p* F
<script language="JavaScript1.2">
" @9 a  U5 ]& K. v<!-- 改变下的字体的大小。颜色-->+ w* @1 }/ F/ T8 ~
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. e1 X4 M6 b/ U; }: p$ Z" {4 evar hidetimer='';
$ h, @1 l+ X5 z, @<!-- 改变下的弹跳速度-->
5 g, ]# x2 k9 Z+ q2 K' X6 Xvar BallSpeed = 20;" o+ O  N9 [. C
var contentWidth;
# O* b9 Y. ~/ U* ]' S8 i/ G; Gvar contentHeight;
. u: h" g, k$ o. f' a5 Pvar maxBallSpeed = 50;, ~# A% _# k. ~6 b/ k

+ F9 m$ r! G) V$ |1 [- p- G% {( d) b; C$ c
var xMax;$ B0 v$ R9 _' [6 I
var yMax;4 R. {0 c( n9 s0 H, b; p, y3 i
var xPos = 0;
( U% x; o6 m* t7 r# m( p' a0 w# v5 hvar yPos = 0;4 Q/ e' x2 ^) v! J  _# ?1 {3 y
var xDir = 'right';
$ I: f. r+ @5 o2 \var yDir = 'down';
8 g+ H, p8 ~0 e# Dvar superballRunning = true;
8 [; B5 ?$ `) q3 @: pvar tempBallSpeed;, b7 G+ ?  {  @- L2 h5 |
var currentBallSrc;) E* N# r' K5 f* [
var newXDir;
0 ^0 @8 b6 G# C* y$ Z6 Cvar newYDir;
: L: Q9 |/ q3 r; d( J  N1 y9 y5 b' n+ N- k* t* |/ K8 o
function initializeBall() {
4 m9 P2 l, l+ m- z. I6 j1 {: `   if (document.all) {
- |% ^) F$ ]' n$ [4 @0 H      xMax = document.body.clientWidth" z1 ?4 W) [6 w( b; q
      yMax = document.body.clientHeight
/ T7 \* x  ?! ^/ |# ^      document.all("supertext").style.visibility = "visible";
& U& X' w# x6 `& D- W; Z      contentWidth=supertext.offsetWidth
+ P( H6 y' ?2 o* E& g      contentHeight=supertext.offsetHeight
; P6 z/ Q$ |5 _8 B7 J2 W      }) E& j7 \* s0 v0 g
   else if (document.layers) {  F' {- K5 _; |8 H  g
      xMax = window.innerWidth;: o- K7 l5 f2 d7 J) C: @& {
      yMax = window.innerHeight;) K" j* V$ w) f) n8 W! D+ y
      contentWidth=document.supertext.document.width( y; G# Q# q/ }1 x
      contentHeight=document.supertext.document.height
0 `* X. m! M7 @% f% g$ z! n! I      document.layers["supertext"].visibility = "show";
- b& H2 h3 K1 o$ P- b; a: V4 y9 p1 z      }
$ ^, G) L6 y2 I; Z* S" T1 R   setTimeout('moveBall()',400);. }5 i/ F& x6 s. d6 w
   if (hidetimer!='')
) _7 g5 q$ M) C9 B   setTimeout("hidetext()",hidetimer)5 ^. Q) ^# `7 \( y+ Q& n, Z
   }
/ y  l$ {" B" K9 o8 _& j
& s! @6 ]# W0 o/ Cfunction moveBall() {
8 G8 L( W8 O" d6 I   if (superballRunning == true) {
, @% g) H6 @, S; g: g      calculatePosition();" L* ?4 ~% g+ K  D& G+ O
      if (document.all) {$ g4 I  b% a/ G- w. B
         document.all("supertext").style.left = xPos + document.body.scrollLeft;' L9 I1 x. ~0 R1 ]6 n" G
         document.all("supertext").style.top = yPos + document.body.scrollTop;8 k% A( i. l! L: X6 G! `
         }: W& D; f; \  Y4 B+ _
      else if (document.layers) {
# B4 I9 R9 F4 [8 G. r         document.layers["supertext"].left = xPos + pageXOffset;9 g0 i, ^& S; t2 X! {" U
         document.layers["supertext"].top = yPos + pageYOffset;9 s! R* N# o- p. }/ C
         }- I2 D6 n4 W, E% z
      animatetext=setTimeout('moveBall()',20);
5 d( L% F+ b" A% l/ A( e0 p6 P      }0 D( d0 z" h0 m
   }
- V7 h0 W" a/ d! V
1 Y# p" h9 W- E) R$ ~9 I" yfunction calculatePosition() {- y+ U' {( c- l# @+ t
   if (xDir == "right") {
# x# E1 `% }1 e$ R7 \      if (xPos > (xMax - contentWidth - BallSpeed)) {
; B. ~( |+ S' r) f( N         xDir = "left";' i0 f6 d3 Y  K1 ^9 z+ I4 x' y6 g
         }4 g# f* b* R5 K' ]- I5 n  N
      }
* n( y, @9 K0 P; N" Y0 ~   else if (xDir == "left") {
( K; c5 o6 H$ f: j8 T: |! Q      if (xPos < (0 + BallSpeed)) {
1 [+ H+ e: h) H: @, o9 C         xDir = "right";6 Z( ]" W2 H& W/ N2 O" ?- P
         }2 o1 m* d6 }2 W4 g+ T0 I; @6 s
      }5 G, N2 _- }5 D0 r
   if (yDir == "down") {0 w: I! e7 M* }
      if (yPos > (yMax - contentHeight - BallSpeed)) {
" H: W/ K' k" Q% U0 A, e         yDir = "up";& y2 W) d9 }; j$ ?
         }
: V& T' S, {( i; _      }
% r2 x8 P4 y" Z1 f" v   else if (yDir == "up") {) e9 Y4 r4 M; [) ?6 N
      if (yPos < (0 + BallSpeed)) {; J2 A2 i5 Q6 g+ {: H
         yDir = "down";4 i) [9 R- y/ R% ~! A
         }  L8 C" n+ b. Y$ ]9 F6 M0 z6 B* v
      }2 \; m5 Y% A8 s$ b! q
   if (xDir == "right") {
5 I: f/ |  H. l$ ^4 K% J      xPos = xPos + BallSpeed;6 Q6 h) [5 o1 P3 V
      }% ~. [2 j- s0 A* h4 F
   else if (xDir == "left") {
- H6 p2 ]# D2 z' k9 M5 g* @      xPos = xPos - BallSpeed;& _$ R; ~1 {2 P2 d+ M
      }
4 k! A/ k, J: C6 |0 V+ Q7 W* c4 l. R   else {
$ B2 N6 P5 u9 G4 h      xPos = xPos;
/ Q4 C) j9 h, U8 t      }! o9 J# ~9 B/ p8 j5 d# n
   if (yDir == "down") {
% k* J2 u% R2 L6 d  E      yPos = yPos + BallSpeed;
9 f- }& c# v4 t/ {* L      }: V, w$ @  b* q9 T3 D
   else if (yDir == "up") {
/ S. W2 X7 R% Y( l+ S8 V      yPos = yPos - BallSpeed;! }- y. L2 p- E3 l9 O! |) y
      }0 {( w- ?; W, w  Q1 S
   else {
! o: g8 B9 b( q! p. Q8 n      yPos = yPos;
0 R7 {  A% r+ Q4 G+ N+ c" l1 s0 |      }
* l/ @/ w' z% E2 C4 c7 J+ ~   }
: O0 k2 w& _3 H2 T
9 F+ e5 [1 H4 x  \' |function hidetext(){" _7 M6 G3 K6 Q2 _7 L+ M0 D
if (document.all)
7 R+ y: x. i, W, e: I+ }supertext.style.visibility="hidden"; j! D" H" c+ l
else if (document.layers)
$ B% K* w0 ^. {6 ddocument.supertext.visibility="hide"7 S& w, @% L8 A. Z# `
clearTimeout(animatetext)
: r! L% h" i6 \; ^}
+ X$ H+ b- |/ }2 V( X" O( N5 e/ _
9 ]' k+ I2 ]* X( p/ R. B% Dif (document.all||document.layers){  R" t& S) U* {% W/ O
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* f% a; h6 D  ~  y& twindow.onload = initializeBall;
3 y3 q- \5 d( @7 gwindow.onresize = new Function("window.location.reload()");
/ H: d- L- o; h# q$ m}
0 ?7 Z  K+ G/ ?" Q7 y, r; t
0 @; Q1 z( Q! U8 [</script>

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