返回列表 发帖

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

<style type="text/css">. U$ n$ t) m/ w/ A8 u* [
#supertext {& p6 o1 `. o/ r" w& M9 m
position:absolute;
5 s7 E- r. N3 U2 ?: [! h6 Z! a/ A0 Mleft:0;
6 g( Y/ J+ {" K* B& r; V( v3 T' a0 ttop:0;8 H' s9 V" O& Y, [2 p
visibility:hide;6 D9 J1 C, N: h; ^5 o! D- r
visibility:hidden;
( U- ]: T7 z( T. v) D}
3 R- }! w# J) }8 M) R1 \</style>. K4 Z! e! g* k3 Q8 @
<script language="JavaScript1.2">
6 ]  \: d6 M3 S<!-- 改变下的字体的大小。颜色-->: ]' Z+ c/ U0 t+ X/ W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', K0 k2 u! O5 j* k
var hidetimer='';
6 i+ o! f! {  w<!-- 改变下的弹跳速度-->8 t" o5 y: }; {& V- |
var BallSpeed = 20;
' h, [: C$ Z2 c8 pvar contentWidth;4 d7 [9 Q( B9 z# f* k
var contentHeight;! C8 [, ~. W6 g2 J
var maxBallSpeed = 50;
! z% k% q, K2 I& t% \# M" }% m) T8 I) t4 j2 Q1 T/ W

4 m' a6 y7 m! J. H. q* Z  T5 Bvar xMax;# C! k. ]+ t! l: ~( U& q1 o
var yMax;
; c5 L/ S( u" E' a& pvar xPos = 0;
9 z! ]+ K' x9 C: m! {var yPos = 0;2 ]: v$ K. y0 n/ N
var xDir = 'right';: D/ t" K) _$ Y; j5 j' o
var yDir = 'down';
7 s8 ^' O; g7 G+ {* j3 mvar superballRunning = true;  i" X$ E1 s8 I3 T- `/ j* g( n% r
var tempBallSpeed;
( ]' ]* @& a& u! X3 a/ \var currentBallSrc;
8 L. K2 j! ]$ Cvar newXDir;% j0 q4 O6 F9 C" m/ i
var newYDir;0 r2 Y+ g0 a! ?: E2 b# w+ C

* Z9 t8 `7 M; H8 E0 a2 Ofunction initializeBall() {
1 C  [" j& I. g$ M6 h$ [   if (document.all) {
4 f, ]0 l% M9 l9 Z      xMax = document.body.clientWidth; l" o! z6 E( @2 W5 J
      yMax = document.body.clientHeight
! G+ U5 ~0 ~0 ^3 L& Y7 w+ \5 {      document.all("supertext").style.visibility = "visible";
, p! }0 ^, v/ m      contentWidth=supertext.offsetWidth/ [# U2 `$ P9 [- j
      contentHeight=supertext.offsetHeight
9 V- B. t5 B0 I      }
7 {( p" y: w& O7 y% j! _   else if (document.layers) {
6 g  e+ h9 Q$ |# o/ }      xMax = window.innerWidth;
3 Z2 ~( Q- ^5 P4 H; _7 m      yMax = window.innerHeight;" |; n' E, @( W) p* x
      contentWidth=document.supertext.document.width1 u5 D4 b) O! ?( q" ]) N
      contentHeight=document.supertext.document.height# v9 p2 _+ r$ L# M9 q
      document.layers["supertext"].visibility = "show";
$ Z2 A* N0 R: h1 ^- X9 P      }
, i% {& ?0 N2 g4 e. w3 J   setTimeout('moveBall()',400);' t$ A. v% u- L' E# `
   if (hidetimer!='')/ o2 O) W1 x6 y# C( E
   setTimeout("hidetext()",hidetimer)
& J' s2 ~8 S" ^% ?/ N, _  _) Y   }9 D; ~6 \7 s$ Q2 H. `0 ?; E

. E- O9 z& N4 C. _function moveBall() {% t. J! a# v  g
   if (superballRunning == true) {
! N$ u% |  q) q: g1 m" V      calculatePosition();0 p* M  }1 c; c' {6 p
      if (document.all) {, j- N# J% h' |6 [  Z( [
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
4 w7 N1 I* h" N( P         document.all("supertext").style.top = yPos + document.body.scrollTop;
" m/ T( |1 |2 }7 X         }; R6 r6 a' z( t, U8 J& J6 t
      else if (document.layers) {/ e' V) a- F9 r! D5 k+ u, v
         document.layers["supertext"].left = xPos + pageXOffset;/ Q4 }9 n2 W# ~4 W: d9 T" M
         document.layers["supertext"].top = yPos + pageYOffset;
5 \0 p, t" q2 @/ ~         }
9 M4 e; w2 g7 E; ]      animatetext=setTimeout('moveBall()',20);& @2 p" U1 K% P" T
      }/ X( l. S: H8 ]
   }: }+ h  W% Y( m3 F
% q& }/ X6 ~1 _# Q
function calculatePosition() {
6 p# K" E, g! {2 U' p   if (xDir == "right") {2 [6 E- Y5 m9 z% y
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' W, ~7 @7 U1 M# R& q. \# j         xDir = "left";
7 r% i& q  b8 b; T0 Q9 Z         }( N6 F! ]% o, [+ ?
      }
# L$ g6 ~2 Y* @* ^   else if (xDir == "left") {
: v8 q% G- x: t4 h7 ?& q% }) n      if (xPos < (0 + BallSpeed)) {
$ B  G% S" x* z5 k% Y         xDir = "right";% e  k! T+ D, N+ E, d0 l( q& G( t7 R
         }
8 S, @2 d, A( j& L2 I- g0 P7 [      }
* b8 b4 q6 d7 R- o* Q- i   if (yDir == "down") {
7 m' K& k$ K0 P! g% G      if (yPos > (yMax - contentHeight - BallSpeed)) {
: {8 O9 z6 c  T/ e0 t         yDir = "up";
. v5 @0 ^* T/ D$ A" r/ u3 W         }' X" X' A4 r: [: F
      }
- x; V# y9 m; A3 n: g   else if (yDir == "up") {
: K1 [# G, h0 f% V: G      if (yPos < (0 + BallSpeed)) {
/ p: h% M! S) |; o( X         yDir = "down";# c+ W. h- \. _4 F" s
         }
  {& q5 a% p, x      }
6 X! w9 |* b% l3 w& Q   if (xDir == "right") {5 h4 V  k! D, [* p* s# a
      xPos = xPos + BallSpeed;
  p' Q; S( n( A9 |0 W' w      }
$ F8 h+ }3 g5 p' g1 k5 W0 Z2 ^. {   else if (xDir == "left") {
. r# [8 m3 u5 |6 Y      xPos = xPos - BallSpeed;4 b' I6 n# K' V- l- O. q
      }
3 ~' g- `7 S) S( [# h/ A& C" Z   else {6 R8 y/ q5 H" ^  S7 U9 R
      xPos = xPos;
, S& h7 _) R$ u! r( P      }
. Y. j& G* G* I# D. R+ {   if (yDir == "down") {
% n; U! ~% ~* m& P0 J* @& n      yPos = yPos + BallSpeed;4 B, v  C. B* @
      }+ ?5 r; X7 T7 s" E
   else if (yDir == "up") {
$ u) z: K+ L  E9 f. D, _      yPos = yPos - BallSpeed;' u9 W; x- I% I1 z# P
      }) K! s5 P/ E5 L
   else {
# e3 v' E  J' [" Q/ J% i6 r      yPos = yPos;1 h+ h0 d( Q& X
      }
' ?; H5 o) L/ N  {# O) Q! ^3 c4 a   }' a- Y# O2 b; i/ L6 B1 X2 w

2 W! m/ {- W% Y3 T( H( _function hidetext(){( u/ g8 x& M6 K
if (document.all)
2 u$ ~7 W, K5 v, l; rsupertext.style.visibility="hidden"
/ I( }5 P% k$ ^* O0 zelse if (document.layers)
9 |) U6 t( T5 a3 e2 gdocument.supertext.visibility="hide"
# Z( h5 Q! |4 M+ {% z7 g; V1 ^clearTimeout(animatetext)
7 b7 y  d* N- W7 d# p}
  H8 e+ `1 ]" j5 h" O
& Q, ]9 H9 Q+ @; O- |4 _if (document.all||document.layers){7 o0 |% R( {1 n% D: r5 {) }* i! R
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& s& E( J6 y  |2 [
window.onload = initializeBall;
. R4 w! Y3 Z: M7 r: dwindow.onresize = new Function("window.location.reload()");( ^3 L  x1 d5 R$ p% y9 }7 C% w/ |
}
, V" L  N" \* E  p5 t. f7 @) @& [" U) s# I
</script>

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