返回列表 发帖

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

<style type="text/css">* g" l8 U; C' Q0 G! p( ^0 s
#supertext {! s. p2 p) I8 U
position:absolute;1 m6 b7 a4 V0 R  l" Q$ L
left:0;- J& w) {! A9 j6 q4 k0 C
top:0;
2 H9 y: a% s0 N* l5 L8 P& _* evisibility:hide;
3 T, O$ j+ G! s" n' y* evisibility:hidden;
# m! Y( A6 w* c2 Z}8 G8 D4 h2 w( s
</style>' ~# U- x: O( F% Z$ n) K6 T
<script language="JavaScript1.2">( z: D' @; V9 s- ~
<!-- 改变下的字体的大小。颜色-->
1 P  {( ]- K) o( @+ [) _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 O8 s6 Y9 `1 S/ Jvar hidetimer='';
6 @* Y+ ]4 U* [. U, E4 C9 ]) p9 G<!-- 改变下的弹跳速度-->) z" @7 }& t) d7 B! R5 l  o
var BallSpeed = 20;
* ?) i; N# s6 a; t  \8 F4 Xvar contentWidth;5 @7 A% i( m$ @' j8 ?) z
var contentHeight;5 z; j5 V8 U- O2 \# r" j( {7 J
var maxBallSpeed = 50;
: N+ N% ?; O' w- f1 t; j, ], L+ o9 q. c+ a0 A
2 y- {- C& d  k6 x
var xMax;
/ ?1 ?" h: F9 K/ }# q! X* N( xvar yMax;7 j9 L) E2 b: l" K* e
var xPos = 0;
! V. a1 ]% Y9 p9 }' L6 d' ~var yPos = 0;
% f. w1 k1 O7 H" L; Z' k( \( ?var xDir = 'right';) V+ |+ P! Z% d
var yDir = 'down';( n4 E: ^: c. |5 Q
var superballRunning = true;. s& A8 [3 [, h
var tempBallSpeed;
9 q6 M- d- `, g" e1 I+ [5 a, dvar currentBallSrc;
( ~. t2 i* }, ~% Z' Dvar newXDir;
& N5 a0 F9 W- q2 c/ `var newYDir;- \$ l( H) D  d0 r9 F$ Q- |
5 x. g# M! [8 ^+ u
function initializeBall() {  e; b6 H. ?0 z3 }- U
   if (document.all) {/ ]! O" o  l1 w  g
      xMax = document.body.clientWidth
( p, ^" V  P+ e0 C+ H  U  b1 F      yMax = document.body.clientHeight- O' I$ R7 q! R, j% j9 _
      document.all("supertext").style.visibility = "visible";' d4 L6 c+ u( N1 C7 h
      contentWidth=supertext.offsetWidth' K! A0 M* d; E! A% b8 ]4 l
      contentHeight=supertext.offsetHeight
# c9 j0 k1 {8 {- G* j7 @      }
3 i$ \' L) S& z# {% y   else if (document.layers) {
7 G) Q% L1 {! }) G0 D      xMax = window.innerWidth;$ N' V; s. a8 z2 |! }7 ?! Z
      yMax = window.innerHeight;
' V( \- s& u: x8 M2 N. r% h      contentWidth=document.supertext.document.width$ X, l2 d# o9 O" D5 r$ G/ \3 k
      contentHeight=document.supertext.document.height
+ H0 ]% N, O7 m3 M2 f      document.layers["supertext"].visibility = "show";0 A, s$ Q, N  r+ }: D% j. H
      }
* U3 L' }6 y( T+ B' V9 N, n   setTimeout('moveBall()',400);
; e. ~1 D4 Z; i9 y; T   if (hidetimer!='')
# @6 f' _. T) R! i   setTimeout("hidetext()",hidetimer)7 A  q! S. q" U- s2 k
   }2 Q  l: I8 H1 J
; f+ M) {% U/ i( X. B+ E
function moveBall() {
% H- S9 b! ~. p2 t9 G   if (superballRunning == true) {
* a- ?* m5 ^( I# g) n      calculatePosition();" c7 ]8 E, Y4 w" _/ [/ T! @0 M/ q
      if (document.all) {9 C# R( z$ z8 ]# j; z% ^# u
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
: X  o/ k/ G  V. l         document.all("supertext").style.top = yPos + document.body.scrollTop;
* G$ P8 Q* a% d5 T5 j         }! d* x+ e/ Q) ?, h" K
      else if (document.layers) {
. L' s, C% t+ p% @* M         document.layers["supertext"].left = xPos + pageXOffset;( l) S: b, \1 s3 k# |
         document.layers["supertext"].top = yPos + pageYOffset;# k( g% I. N- o4 V; K3 {
         }6 h' I6 n; b! ?' V, ~; v6 K" L9 r
      animatetext=setTimeout('moveBall()',20);
: G5 b& u6 A% E      }
$ X6 G! j) e' @# l- ?0 U   }
! l2 z& O" S% A; v, J% m8 A( O( v: }9 [- W! l# B0 M
function calculatePosition() {; r' S! _: _* S% H2 P( i
   if (xDir == "right") {; ?9 e0 x# Z  j. n8 K, z5 h
      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 w9 g8 x8 ], z         xDir = "left";
, x0 {# R0 g1 `2 e0 _  k         }
' n: N9 \3 S% L- r7 _# D      }
' Q+ q- P6 U. O. x  f   else if (xDir == "left") {6 @4 k7 J6 D7 m' v
      if (xPos < (0 + BallSpeed)) {) n; T8 n( v$ Z7 G2 {
         xDir = "right";1 k2 _! @) O/ s5 c" E" ~/ v- F4 d
         }' [* T6 y  |) O$ V1 S* k
      }+ L1 `- A+ ]. q4 R
   if (yDir == "down") {: j# e2 S1 F7 D
      if (yPos > (yMax - contentHeight - BallSpeed)) {, x7 _6 }# B- Q. o
         yDir = "up";' h" n- c# n, A- w; X
         }! G5 q+ z, w% _8 }5 {8 ?
      }
" ^9 q' s5 R0 j& M: z# c   else if (yDir == "up") {5 r1 G9 s+ t7 O% [4 L" Q
      if (yPos < (0 + BallSpeed)) {3 V! L% `5 {) j/ {; _: U
         yDir = "down";6 f$ f" M: w$ i+ {3 g" z, _* n' W
         }
- H- g- L9 R, o! K1 o7 L1 r      }
0 |! l, ]9 W' G  `' C% e4 ]. d   if (xDir == "right") {/ |, N/ P* c; ]" p9 p" _
      xPos = xPos + BallSpeed;9 @  d$ F8 Z4 d* H9 ~  {
      }
! T% r8 B$ I& w4 ~/ G- D   else if (xDir == "left") {
, K+ d" i3 r, a1 ~      xPos = xPos - BallSpeed;' a; l' V# H0 _5 q2 S
      }
8 f+ d( V1 q2 n* d( `5 J   else {' Z+ Q5 D$ V2 Y8 H2 ]
      xPos = xPos;& I, H5 N+ d( j! v; P
      }# k& W6 C( f2 y; Y4 V% p# m4 O9 r! Y
   if (yDir == "down") {
4 r6 c: N4 B, L      yPos = yPos + BallSpeed;* V+ o8 q, o6 k+ B! j
      }, f$ B! Z+ Y: T/ Q' m3 w
   else if (yDir == "up") {6 k+ Z: a& i: k- v$ S+ Y
      yPos = yPos - BallSpeed;; \6 P  v" G  D- \$ z- s1 N) _
      }
  I" ~3 Q" N& K7 f   else {7 r8 H$ r5 M0 n
      yPos = yPos;8 U, }3 X, ~, i( \
      }
3 l$ G' d7 u3 j# R( M/ l# ^. F   }
# k% g/ a; Q' v; U# D+ j1 K) t/ I1 L" J
function hidetext(){
1 I2 x( P; ~2 h5 u/ _if (document.all)$ M1 s5 [2 Q. u2 u! s- ~9 @
supertext.style.visibility="hidden"2 t$ p% o% N6 z$ j" P& `' X4 o8 w
else if (document.layers)0 b7 c$ h( [9 v2 j/ ~
document.supertext.visibility="hide"
" S  [' V$ H7 P0 y7 {( k4 rclearTimeout(animatetext)4 Z$ @! D' g3 S3 x2 b. r
}$ u6 v' U6 t1 e- M7 e; h2 h
  @9 B/ ?# g9 l. ^6 [% U7 y
if (document.all||document.layers){
% b; Y5 E5 F0 ^. {) H, e& Cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" b) J6 |; s& Twindow.onload = initializeBall;
% s, Y2 g6 s! Wwindow.onresize = new Function("window.location.reload()");( T) Q0 X! t: a) Z  U
}) W1 ?  A( f7 y, f

/ @+ |5 D3 `3 Z9 Q( `. X4 D  u</script>

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