返回列表 发帖

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

<style type="text/css">( c7 ~1 i, O. H
#supertext {6 Q8 h; f( V" ^/ H* g3 \; T
position:absolute;  {- u, I& @5 a8 `3 M
left:0;+ @: E& m& s5 m/ ^- T+ y
top:0;, T* P( P- t' R0 {! e
visibility:hide;( S* T, J2 d- k5 L# ~/ h% ^9 U
visibility:hidden;
! F2 X7 \( o7 w8 X: c3 q5 [9 p7 x5 L) b}
# B8 ^7 y- R6 A- D7 j</style>' L. s* M6 @' y: ^
<script language="JavaScript1.2">
) ?% Y$ K, U2 S0 J  `  a: F, B<!-- 改变下的字体的大小。颜色-->! C8 l7 b8 m, f8 Q7 D' M
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) K. \0 i+ j; U8 ivar hidetimer='';) Y+ E4 L9 }% |6 k% v7 A" W4 Q& I
<!-- 改变下的弹跳速度-->
# A& w! N7 W7 g2 nvar BallSpeed = 20;
7 `. i# ?2 r) Zvar contentWidth;
( W  C- x: M5 T3 ^var contentHeight;- o" c0 E- }; V) \4 z+ Z
var maxBallSpeed = 50;: \% q3 A7 k+ x6 X! [$ |* U; @/ V

; W( R. M+ i5 Z( U5 N5 \8 S! H  j, C$ n2 J
var xMax;9 [) @: S/ i, z
var yMax;
0 H4 W( t; N% c& z$ k1 V! H( F: Evar xPos = 0;& H& _3 }# s* ?- Z( D0 f" R% k% F
var yPos = 0;
0 \  x- f( X8 m- }, i% gvar xDir = 'right';
7 N: u1 ]' y- P& `* H7 svar yDir = 'down';7 Y3 [; A5 s- X" x% B3 I- h
var superballRunning = true;
' N- \2 E; F/ ^: B' k4 evar tempBallSpeed;6 V' h) p1 W8 {3 H8 d+ P7 f
var currentBallSrc;  g. V$ J7 W% }
var newXDir;
7 v0 l2 H! d2 J) T) j0 ?7 evar newYDir;/ U; R) {# Q! s3 Q) }

# @( f6 m6 Q2 w1 @8 L# }1 D- Ofunction initializeBall() {  r* c& c' o  a" A
   if (document.all) {% l1 @& ~9 C0 U4 T  R+ W
      xMax = document.body.clientWidth
* E+ G' V# \7 |0 G0 O$ a* U      yMax = document.body.clientHeight
8 d& h$ B$ V" E' T1 O' i, d' }" z      document.all("supertext").style.visibility = "visible";- {/ I$ q8 {6 J8 V6 [
      contentWidth=supertext.offsetWidth- U5 C- f  y' k# B# G  E8 Z
      contentHeight=supertext.offsetHeight' y& C1 K% ~. l' @/ U3 m" D
      }
1 m+ g$ e: U/ V4 o! t1 l   else if (document.layers) {9 S1 p( _: X% V+ x4 P
      xMax = window.innerWidth;
$ ?) H; A& c3 j      yMax = window.innerHeight;+ _1 n/ T( B$ {) u' d
      contentWidth=document.supertext.document.width
% E, U; X# {  S* X2 A! Z! R      contentHeight=document.supertext.document.height
6 P- E) i6 L$ |  G2 {% q3 U      document.layers["supertext"].visibility = "show";
# W: M2 M3 N: N' D      }
7 j3 C$ B5 P3 S- r) p% T   setTimeout('moveBall()',400);! v" d  d, {, w4 G" R% v- ^
   if (hidetimer!='')
1 C  p  j0 Y, n& W& s$ F) o; i8 [4 F7 d   setTimeout("hidetext()",hidetimer)" H' V4 \* y, E  X3 c' y
   }  `0 ^4 ^+ V$ Y2 R$ R' E! P! N

2 j4 L& z1 b1 l# c2 Z# F: ?function moveBall() {
0 E: B5 E3 _: p* k! e$ v; D   if (superballRunning == true) {
7 X7 M% |( S5 \# M- [1 U! p9 H      calculatePosition();+ K) J" V! ]2 V' E6 R
      if (document.all) {
; s( a; B- L: N1 P         document.all("supertext").style.left = xPos + document.body.scrollLeft;
, u3 R" R9 }* J0 A: x1 o4 H         document.all("supertext").style.top = yPos + document.body.scrollTop;) y( Q9 i( e1 |1 r; `
         }
$ ]1 m; g( {( f. n, X      else if (document.layers) {) f8 B. [8 M- V0 g
         document.layers["supertext"].left = xPos + pageXOffset;
! a4 V+ L/ {: N: L2 X* |7 q/ H2 e         document.layers["supertext"].top = yPos + pageYOffset;/ ~& f2 ~2 x: c( N/ k, P! z  x) `) [- n
         }! p# \- w- T# E
      animatetext=setTimeout('moveBall()',20);' M9 V, @2 f( S6 ?9 @
      }2 A; E" {& p8 r: N0 b# H# i5 A4 B1 |/ r
   }" l5 J( J1 m/ ]2 j

0 x- A# J& P0 k! Y  e' \0 efunction calculatePosition() {, B8 K; S+ Y$ t( p4 C2 i/ E
   if (xDir == "right") {: x* ~9 ~0 O% Y. g. r
      if (xPos > (xMax - contentWidth - BallSpeed)) {" v7 }& a7 D- I3 k  e, B2 i
         xDir = "left";
/ Y) n9 t! y6 R. K         }
( k$ ~' ?) [' O7 E      }
5 Z" v0 ]$ [) o7 D9 ]   else if (xDir == "left") {- Y4 K( N% T1 t
      if (xPos < (0 + BallSpeed)) {
9 g6 f- X- h" _         xDir = "right";
* Z9 C# S/ |1 m1 [/ G/ c8 ?         }7 l3 c' e" |2 ~% k) B  P
      }4 P& E8 m3 [+ b* A. G
   if (yDir == "down") {
/ j7 s% G9 A! p; ~      if (yPos > (yMax - contentHeight - BallSpeed)) {# `* K1 y& m0 i; h
         yDir = "up";. _. }! M% n5 T( _1 \
         }: o4 ?0 d- ?& F5 S+ G
      }
; _: G( z' f& S, o# F: D5 k* O- R' m   else if (yDir == "up") {. s3 H  G( ~) s1 C  X* s2 R+ J; x
      if (yPos < (0 + BallSpeed)) {/ b1 x' P& ?  W
         yDir = "down";. @# I& s4 y5 J9 [5 ]* u( k
         }
) c$ N+ C! |; u4 r8 Y6 o+ X      }: t. n/ m8 p) C( f" j
   if (xDir == "right") {2 ]" r+ x9 u% q
      xPos = xPos + BallSpeed;
, \. b. \/ q# ^& d, H3 }      }
" C- w/ N5 ~+ D& L8 u# E* ^+ v; H   else if (xDir == "left") {
1 o% P  g6 U3 E2 f+ }      xPos = xPos - BallSpeed;
8 L1 e7 w5 z6 z      }' j% h- s: \/ s& c  ]+ v
   else {
% y* [2 S# z2 J$ @      xPos = xPos;
% n% X1 l& a  L: `9 J      }* |9 o& u1 B' Q, a& c+ ?
   if (yDir == "down") {/ G% h5 Q# F  V+ l; d+ \  M
      yPos = yPos + BallSpeed;
! v+ Y! a" E; I8 W3 c' X      }
' H9 @* O; X# {7 B   else if (yDir == "up") {7 U; x( j; q8 T7 Z1 [: _
      yPos = yPos - BallSpeed;
1 [* ~# Y/ U6 a# [7 t1 r      }
4 s3 k5 ^1 X- p5 _& r   else {  ?5 E  B9 U$ e/ v
      yPos = yPos;
. \1 V3 }- [: ~7 y; e" }3 E0 b      }) H! K2 @' y* n$ L8 _: r, k' L7 J
   }
2 S: P: }. ]1 v& o2 H- S9 i$ m! z+ v$ q* L6 b. v
function hidetext(){
( h+ y$ S$ `( l# R0 yif (document.all)
" ]) f" l4 Q8 |supertext.style.visibility="hidden"5 g6 q9 p  e, u; [
else if (document.layers)
0 {6 ~' N3 r2 _4 [0 E& zdocument.supertext.visibility="hide"4 O9 }* _- Y+ z4 C9 Z
clearTimeout(animatetext)( N  Q7 y# W* o
}
9 u3 x. w' A" s3 o# \8 l7 e- p# M0 a& |- y& z8 ^/ [$ \/ M: g! _+ F
if (document.all||document.layers){
# `6 ^/ L4 _# }document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')+ l& g5 i+ ^5 c7 j
window.onload = initializeBall;( K: U$ o4 x0 L5 s, D; `4 I8 O# ?: t
window.onresize = new Function("window.location.reload()");
; {- V, Z5 T% e}+ P+ u+ z5 d) v2 o& S0 l

. m0 s* c5 B  B7 |; x3 T</script>

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