返回列表 发帖

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

<style type="text/css">
# w7 L& @9 s: r  P/ C#supertext {
9 l3 t- x" J  {position:absolute;" s# x3 {3 X. v2 O& }: K5 t& n  p
left:0;  @7 a3 b0 Y: h: N5 B# ]0 K2 H
top:0;
- O/ W2 ~8 J' [( Xvisibility:hide;
+ H" O2 {7 F7 [' Nvisibility:hidden;
# m8 L& \! f: a; y4 r0 A}
+ ^; |5 Q( y5 y( s( s  o</style>
- L% G2 Q2 e( R: Y<script language="JavaScript1.2">
6 Q2 Y5 W% u- M; T# L<!-- 改变下的字体的大小。颜色-->
5 @' p" x% [9 s0 T. p% i* svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 _3 }  p& ~' Mvar hidetimer='';- B$ l9 q% X; t$ S6 U, {& [
<!-- 改变下的弹跳速度-->! e4 Y" P: ?, M+ V
var BallSpeed = 20;" v: b/ L+ W% T6 }8 K
var contentWidth;
4 z+ j, ~- N/ I% j7 w: A; wvar contentHeight;% K: W* |' }0 Q- m: B
var maxBallSpeed = 50;0 p7 k8 N' ?4 q

5 K& g$ q$ h+ O$ @/ v
* d; u; n# d8 G8 Y! Y7 a5 Jvar xMax;
% ~8 {+ @7 {+ j/ ^" Avar yMax;
# v* `* G0 X. k  vvar xPos = 0;6 z/ u/ c  F0 }2 ]
var yPos = 0;! P2 C! ^3 i' {  ^4 V
var xDir = 'right';1 C# s+ J# O! c' M( k  ?
var yDir = 'down';
  x& x7 l+ P! s! h  M5 Q4 bvar superballRunning = true;
& P" }/ `8 U3 S8 U. qvar tempBallSpeed;' K; J/ A7 r0 F& i2 }7 ^  {
var currentBallSrc;
6 d4 q3 J0 n1 D6 bvar newXDir;
1 E, F* O' U! I# d7 `1 K8 vvar newYDir;
0 [/ e: p) f( G2 l6 f% H
8 A% z+ N, M/ ^. @2 l  H$ f4 m% L0 efunction initializeBall() {
) s1 X( h/ y3 [7 t9 x! r1 j9 i/ f   if (document.all) {
2 R: K& E" E, }4 D$ W2 u) d6 Y3 ^      xMax = document.body.clientWidth) E9 e6 d  P. r
      yMax = document.body.clientHeight
! O3 Q& e0 F7 c& n$ I7 I4 ]1 {* N- h      document.all("supertext").style.visibility = "visible";2 R% c9 o5 L4 [6 a, j+ W
      contentWidth=supertext.offsetWidth) z& D3 ?, ~# w6 C7 o
      contentHeight=supertext.offsetHeight
& L8 h; b5 T5 e) N% Y      }8 c5 V8 [7 p. g) O3 E
   else if (document.layers) {
+ V: r- s3 r3 E5 r. E" ?) n      xMax = window.innerWidth;2 _" l, S& f  U+ j
      yMax = window.innerHeight;
9 E7 x( v! \. q& c      contentWidth=document.supertext.document.width/ R0 G# A6 g3 w! S
      contentHeight=document.supertext.document.height0 o9 p8 p6 g  {) T& _" T
      document.layers["supertext"].visibility = "show";
% z) z6 C+ ]% X2 e/ W      }
  t5 b5 d" r. j- ?+ ]! e* a   setTimeout('moveBall()',400);
7 d+ q/ H5 A+ d, d2 ]   if (hidetimer!='')
* Q: m4 g/ D$ e: }3 n: @1 U( x   setTimeout("hidetext()",hidetimer)
  @  W+ E  R+ M  s   }
% f* h( j4 R/ ~# M# A
$ g8 [) L3 X& T, x! |$ k/ ufunction moveBall() {
2 e0 u* F+ u( \/ W8 W) t0 H   if (superballRunning == true) {
: f3 j& ~7 ]# [% r1 O: j+ f5 o9 E0 t      calculatePosition();
; U; v. y) O$ {      if (document.all) {% J7 p1 C0 [+ y& G1 m, U
         document.all("supertext").style.left = xPos + document.body.scrollLeft;- B& {+ o, _$ [4 U- J8 W
         document.all("supertext").style.top = yPos + document.body.scrollTop;8 m* z6 E: o& |* ~2 h
         }
4 f6 k+ K- X8 k      else if (document.layers) {
7 i; n  y& b0 z! |& Z3 j         document.layers["supertext"].left = xPos + pageXOffset;9 ?; ]4 l6 a: O# Y
         document.layers["supertext"].top = yPos + pageYOffset;
" u- C6 V9 ]7 Q3 O: [, T0 `         }
4 h& E: J1 g1 u2 z; p3 z      animatetext=setTimeout('moveBall()',20);
% [4 L) h/ t# i! L      }
( h1 D( [9 j9 K+ ^( H0 @   }
! Q* ?; P+ b( Q1 G# G" {4 ~, j) N2 T6 B' Z
function calculatePosition() {; U$ n, k" O9 U0 q4 w3 F
   if (xDir == "right") {$ E& v% a+ i" w/ u# O  ^: T
      if (xPos > (xMax - contentWidth - BallSpeed)) {, C5 O6 R7 ^/ S5 Q) Y1 g7 Z
         xDir = "left";+ H* ~/ }! B) g; l) g! d
         }
8 e8 f8 v+ ?* T6 o5 V! ~      }
" M2 {  _  o( V# x* d9 B   else if (xDir == "left") {
- a/ I$ _- E  q1 N! X+ [# e      if (xPos < (0 + BallSpeed)) {( H& `5 R( A6 ~- Y, D
         xDir = "right";( \* d) a4 g: G6 a
         }# u0 {, O) j* E# n
      }
, N/ \' V5 g) p! o$ g* v1 e9 O" ^   if (yDir == "down") {+ V; }# h, F; j1 U. |# h. ^
      if (yPos > (yMax - contentHeight - BallSpeed)) {5 R: B  D  }3 i- q. U. E! D$ W7 n
         yDir = "up";% |5 j, A+ g1 k$ e$ P6 z
         }
( x% ?: W$ X" R9 R      }
* J4 C! |/ ~/ e2 J  T/ i   else if (yDir == "up") {/ `/ l: A8 y4 A. d# R0 p# o
      if (yPos < (0 + BallSpeed)) {, U  L- k% m" D1 D2 t5 C% H
         yDir = "down";
: `7 p3 T/ ?/ G         }  f. `+ D$ @4 l8 o
      }  \4 D) K0 R/ V9 P9 I
   if (xDir == "right") {
8 W' h! W- c( }; @2 J; t      xPos = xPos + BallSpeed;$ W. J/ p5 X- F5 A6 y% f+ W
      }5 L2 T, j* o; v; b( ]( }& j. f$ e3 W
   else if (xDir == "left") {
& V6 z: E* @* z" c; ^4 t4 V" {# R      xPos = xPos - BallSpeed;
0 d& \9 \" Y, |$ e& {7 _      }' f  X7 p4 x# M2 P
   else {2 M9 o9 C1 H3 |' m5 t, O
      xPos = xPos;! e) ?) T3 V2 M# j
      }
! C6 u8 ?* W! k, H' ?( Y' @   if (yDir == "down") {
( H  n/ @- ^$ f3 Q% h- P) s      yPos = yPos + BallSpeed;
+ |: [" C8 ~$ A4 f8 T. F9 Y- F3 N      }6 X/ O. P. h, d+ o  i, Z4 I" [2 T
   else if (yDir == "up") {
$ J1 m' P3 @) f; v/ H      yPos = yPos - BallSpeed;
4 Q6 }4 Q8 E( b% z% S" K9 i& F      }
* R: m/ _' a+ F" {   else {
% P8 w# H" @1 v3 ?      yPos = yPos;  J1 P& Q) `- X; \
      }
* s6 F  m* Q# J  `  s+ G6 l   }  ^$ \5 S: v1 z' H" \
: l: L& C% N7 Y2 q9 M
function hidetext(){9 C" Y3 i# v" L/ S. y
if (document.all)/ o; P+ M$ J. u# P
supertext.style.visibility="hidden"9 ^0 ?+ |( s; h- y3 C8 {" ]
else if (document.layers)
1 _7 h# g9 \, ?; wdocument.supertext.visibility="hide"
( C0 J# T# n1 }5 B! ?' t3 [# Z2 zclearTimeout(animatetext)
+ D! b: w2 J2 \/ _2 _- |}
* m& F9 @; B' [  p! a/ W
' R$ M% ?2 W( x% S. Q# A( Y* fif (document.all||document.layers){
0 B8 M2 @9 \, h+ _2 l; L( bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), K7 {" P# S8 H5 e* i
window.onload = initializeBall;
0 r. {, `" m; }8 Y+ I0 k; A: twindow.onresize = new Function("window.location.reload()");# V5 n" w+ v- `& H! U0 X
}7 Y0 M  B$ P; ^
3 A; J' @3 C$ ]
</script>

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