返回列表 发帖

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

<style type="text/css">
% K7 `1 r' @' p/ `9 v" v/ s6 a#supertext {: T* o, l5 Y, p8 u3 j/ C: W5 q* v' s
position:absolute;
" X# ^' `0 g4 _# [4 F+ Sleft:0;
! T4 Q* k7 K- D1 Z2 F$ d' Xtop:0;
1 K1 I' P' A  L/ yvisibility:hide;
8 I( K- [4 k/ Y* Z1 h3 l: ^visibility:hidden;
- w# t0 s2 ^* @1 o4 c; X/ I}3 {" n# X$ y% y3 p3 {
</style>
) ]3 ?0 {+ X) f) F0 i3 M<script language="JavaScript1.2">
" [3 i: n  D6 w& M9 p, O; M9 }! c<!-- 改变下的字体的大小。颜色-->( }6 w! {6 f5 F) h4 K3 L- ~
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 r5 d9 Y/ R) Q, svar hidetimer='';
0 m9 x* R* y: M( D<!-- 改变下的弹跳速度-->- x+ U+ f6 m, v# N8 T
var BallSpeed = 20;
' X; [2 l  |7 p( f1 ~var contentWidth;
- U9 x+ y1 `! q$ Jvar contentHeight;
9 R4 s0 t5 A3 B& Q6 b$ mvar maxBallSpeed = 50;
) i* u( r" j6 T& E8 O: E$ ^
3 h1 L' H7 o& L3 }+ {; M' l4 N/ \+ M# ?1 ?9 L, X5 w( C
var xMax;
7 g4 @! ?) G$ m* Zvar yMax;
% l0 A+ Y! B) @. Zvar xPos = 0;
% x  p1 P, [: T, d. Wvar yPos = 0;7 q6 n% C- j" R8 u: X2 a/ `
var xDir = 'right';
* h( z! |% ^& ^' q. o- S- Kvar yDir = 'down';
- `6 [! ]% A& O' l# z- p& [" ?var superballRunning = true;
4 H4 o- b& T  d- Z; Jvar tempBallSpeed;
# M% L# ?8 y% Z4 w$ x* i# ^9 Cvar currentBallSrc;3 f1 I' v! U. r" j4 J+ R8 c) `
var newXDir;
8 q) Q  `9 p4 u8 a9 Jvar newYDir;+ y: ?$ o; p( C6 l* \# s' H

: T5 q! F3 V3 O, |( L) sfunction initializeBall() {
; B1 C) [1 t; Q3 j1 U   if (document.all) {
, Y! ~7 [% t0 {0 L  i      xMax = document.body.clientWidth1 V3 {0 R- Y8 v! b
      yMax = document.body.clientHeight* m6 U3 @+ M1 W7 ~$ A
      document.all("supertext").style.visibility = "visible";* X! ~7 o+ X0 a- b
      contentWidth=supertext.offsetWidth' k# d2 O! |; S3 t# y
      contentHeight=supertext.offsetHeight
7 _8 H5 w8 K( v- a9 Z  L& K      }
1 t7 o6 R- v) w$ Q  g* \8 Y   else if (document.layers) {; X# L9 {5 i4 r" ?% Z
      xMax = window.innerWidth;2 H- ]( V  j/ E. i8 `) T6 [
      yMax = window.innerHeight;  d' Y, I/ P& t; H' Z
      contentWidth=document.supertext.document.width
1 B* t3 l" X* l0 J$ m# ?3 k      contentHeight=document.supertext.document.height
& T1 M, ^4 c/ k$ s. y3 r      document.layers["supertext"].visibility = "show";
: x4 W4 g4 B2 l      }4 ~6 Q# i# `$ v4 a( i5 i/ C& X
   setTimeout('moveBall()',400);5 z5 Z9 O" G, Y' [
   if (hidetimer!='')$ a1 T1 W) w# _+ f
   setTimeout("hidetext()",hidetimer)
( Q6 C- c1 I( U8 V6 V, M' E( ]   }
, J" X2 l9 c4 G0 G3 j, m- i6 _7 E
" |, H; z# s% K6 [3 Ffunction moveBall() {4 m+ \  D0 J% Q
   if (superballRunning == true) {: x1 C+ Q& ~/ V2 t& q2 s
      calculatePosition();
- q$ @7 H" V% e9 `4 \      if (document.all) {
9 L7 R+ ~3 r3 \9 U# A         document.all("supertext").style.left = xPos + document.body.scrollLeft;% K* H8 D3 M3 Q& ]5 X
         document.all("supertext").style.top = yPos + document.body.scrollTop;
# o& a3 X: j) ?) u' v% }8 Q         }/ G- p- c- e* Q9 J' Z2 e8 x
      else if (document.layers) {% h2 w7 I4 P7 Z4 `( R: G! Q. B" ]
         document.layers["supertext"].left = xPos + pageXOffset;
9 Z( B6 v, |: g) y/ B* \         document.layers["supertext"].top = yPos + pageYOffset;
8 E  k0 U+ _! }, W         }# Q) P+ t; {5 X$ @: T
      animatetext=setTimeout('moveBall()',20);( w, c+ ^( u7 Y3 s$ r4 ?* C/ X4 q& `
      }
- S7 ?: X2 L$ }7 l1 q6 @   }. ~+ E0 p/ k& B; n- v
# q' g6 {0 m7 E$ v4 K. C
function calculatePosition() {# g! `: T8 [# \5 r9 h4 k
   if (xDir == "right") {1 s: `  H/ w* K$ s- v
      if (xPos > (xMax - contentWidth - BallSpeed)) {* D/ T- a0 T! N9 Z
         xDir = "left";
6 h6 M# e+ z  S* |         }
4 Z, b5 u% P# I2 @3 Z- o& A4 e      }
2 c9 O; e/ ?% `2 D  ]; z   else if (xDir == "left") {: o+ }  N$ y# E# k7 N. [; G
      if (xPos < (0 + BallSpeed)) {
- Y/ ~' _0 A9 o/ S. m' ?1 Z; ]4 X' i# F         xDir = "right";( b1 r5 a! a) s  N
         }
0 D) ]1 ]3 \; o( e6 ~+ D4 s      }3 x; x' {8 j7 O0 T! j$ R# S
   if (yDir == "down") {; v; k: o* r8 q- r
      if (yPos > (yMax - contentHeight - BallSpeed)) {
% H" k$ Q. T& e, p         yDir = "up";
1 H" F8 d5 R; f' w: {         }
4 B. n+ w- R8 l      }0 L7 u- N% L- T
   else if (yDir == "up") {/ d/ s  [5 C; m# V5 F3 M( M0 X
      if (yPos < (0 + BallSpeed)) {
+ q2 C% U& P. Y9 O( ~; f         yDir = "down";
% b6 a2 @5 G0 [8 z/ n         }
* E6 h9 v2 z5 i0 g* U% J      }' s. }$ g; R4 b/ q. T/ |8 E9 o+ }" U
   if (xDir == "right") {9 ?4 o2 U; H5 M- ~
      xPos = xPos + BallSpeed;$ j* a+ N6 X: l$ r$ u
      }
: L% z# B5 i3 h: x   else if (xDir == "left") {& S8 T4 P9 D( @# D/ ?+ j
      xPos = xPos - BallSpeed;/ T' U" Q/ V! ~
      }. q- D( ]; u) v- A4 m/ v$ y# Z
   else {
9 L8 Q0 b( l, P7 r# q% ~0 Q      xPos = xPos;; g: v, y, R, k9 o3 E# m" E; g; w
      }/ `; g& p; U  n+ h( V) h6 c
   if (yDir == "down") {
8 i, H" p- [6 l0 x  k      yPos = yPos + BallSpeed;
* `$ A  s! F" k6 l2 b2 g6 r      }7 H  @+ p7 a0 h) D, H
   else if (yDir == "up") {! b8 g) R0 q, y) w' _
      yPos = yPos - BallSpeed;/ m' U2 o7 G: A8 u  M
      }/ c1 U7 ?( D3 E9 a
   else {
8 S  J; L  K9 y3 F& ^2 R      yPos = yPos;/ L7 Z6 \8 q9 z! n; B7 B
      }
6 x9 K8 }" F- j# V; @# g' K) F   }0 w/ Y/ C. d! ~4 N0 W; Z; d7 v/ V/ i& {

& i8 w) ~; }1 m, Nfunction hidetext(){
( d! I0 r/ m5 @* J" u% f: T1 W" b2 A; n) mif (document.all)
7 g/ Z$ T, {  d- ^supertext.style.visibility="hidden"
5 C7 z6 k* W7 Selse if (document.layers)
7 O1 q% O0 H7 N+ y" z8 ~document.supertext.visibility="hide"
. T/ O1 H8 m6 ]  M/ `+ O3 ~clearTimeout(animatetext)( X* Z  n  x' h" I
}
5 s2 Q# D  s! d3 n  {1 ~4 r
1 p4 p0 V% n- M* yif (document.all||document.layers){# k0 P6 U" ^& M' a2 S
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! t0 A" X& |" B3 I; \$ qwindow.onload = initializeBall;
0 S- L6 c& i  l" o3 k0 Twindow.onresize = new Function("window.location.reload()");, ~! }5 P+ |+ W# s  K$ n3 p8 x
}
, ?* \& x5 E: P2 ^* B' L9 L# l  k. q$ i- U! \
</script>

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