获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">0 [4 O3 T* i# n0 _1 B
#supertext {
* \4 n* E, E1 E; w& [  B6 dposition:absolute;
" _2 x! K" S- Jleft:0;- D6 Q, Q7 I- V1 @0 c) i- z
top:0;5 w  N  Y- K3 O- j9 u4 l
visibility:hide;9 `/ t. z; \* }' j8 C* r% H
visibility:hidden;
3 [- Z: q- S7 a& a}
# T0 j# w9 T2 A7 G0 {7 f</style>
6 m8 A" O( [/ A5 p- V$ B<script language="JavaScript1.2">
4 n0 ?+ ]& X5 g. Z<!-- 改变下的字体的大小。颜色-->
+ k: a* w( ?/ |0 \4 y* {% h* U: _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% b$ p9 o* U8 B1 G2 w: T8 w
var hidetimer='';8 R0 Y+ v8 ]: V6 n6 F" K
<!-- 改变下的弹跳速度-->' Q" H6 J4 [( U; x8 l+ \! X- }3 y
var BallSpeed = 20;
- K$ d3 t0 K& [  l$ [* ~/ X& w" vvar contentWidth;$ W/ x% W* U% P% t1 n0 \9 B
var contentHeight;: K3 }: `5 a! x: n& M
var maxBallSpeed = 50;0 w# n$ {+ m$ ^$ {6 V0 }

% J' p) F0 V4 W/ e# g
( S3 ]) [6 K9 D4 p0 Evar xMax;4 E. y/ A, k  D1 R# E; n
var yMax;, K  Z9 K1 X7 a+ v5 L3 S
var xPos = 0;0 O( @7 P2 @' {/ Q' ~
var yPos = 0;
! P% a+ G/ F- C, s5 M# avar xDir = 'right';* L8 V5 y4 g! t# s  @: S
var yDir = 'down';, @" F* L/ f$ z( }0 Y% l2 m
var superballRunning = true;. S* N& Y1 C4 |
var tempBallSpeed;
0 G8 y4 `+ m* ^' {6 W$ I! Fvar currentBallSrc;
9 m8 O7 Q! r! `+ hvar newXDir;/ i; f% G& U8 f7 U9 y! [2 @; O; i
var newYDir;. a' a. d" o$ G" I  w6 G
. m& Y  i  M6 z$ s6 n
function initializeBall() {
7 Z- [+ X* q3 g2 W; t0 F8 [   if (document.all) {
& s3 |( T" v" d- h      xMax = document.body.clientWidth6 e3 O6 V" e* o) U' z0 e3 c! R, G
      yMax = document.body.clientHeight/ D6 G- T4 S; D! C- ^0 R, V
      document.all("supertext").style.visibility = "visible";  I8 M% n. J# S! u- h. Q5 F9 h5 a
      contentWidth=supertext.offsetWidth
) K9 f5 c* _! q+ _( a      contentHeight=supertext.offsetHeight
9 o0 d! ~3 _, I% @5 N      }
9 u0 s2 o; j! }7 k! \/ |) B   else if (document.layers) {) P) `/ G6 }# i7 i0 Q/ {
      xMax = window.innerWidth;
1 `, U4 V( L  I' n      yMax = window.innerHeight;
5 x  T% R( s' n; ^& c+ A, Q      contentWidth=document.supertext.document.width
" B2 ]! s+ a+ B: q% o& O      contentHeight=document.supertext.document.height* j% T8 s% h* Z8 `6 E# o8 M! |
      document.layers["supertext"].visibility = "show";& D8 [% W/ H3 d. ~2 P3 U5 [8 y
      }
; k- c/ V/ M3 q; J   setTimeout('moveBall()',400);7 b" r5 {" ?6 Z+ G% S
   if (hidetimer!='')
8 o' x4 e* P$ D# {   setTimeout("hidetext()",hidetimer)
1 I' V; N5 [: g. Y2 c: k9 P   }; y2 W6 s- \2 m  A
, a: C' g0 ^$ R, c% b4 Z
function moveBall() {+ l6 e! |8 X- H5 z; s
   if (superballRunning == true) {
+ j" z, Z: b) K& f% Q8 T0 @. O      calculatePosition();7 I3 M" o. s/ i7 \
      if (document.all) {" h5 A+ x3 N6 m4 C
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 k( h" v: `5 b- |' t         document.all("supertext").style.top = yPos + document.body.scrollTop;; o# y! s, {8 i, M
         }
8 B8 p$ t1 ^5 B# g      else if (document.layers) {% u. ?9 y9 U! D" }8 h3 Z9 j! O
         document.layers["supertext"].left = xPos + pageXOffset;1 k" C' D, T' C. J
         document.layers["supertext"].top = yPos + pageYOffset;
2 k% z$ C1 R, t  m0 n* i5 X  \' w. _         }4 e2 I* T  r; Y+ i
      animatetext=setTimeout('moveBall()',20);
* a7 T" O8 a. u: ^8 s2 G- O      }* M0 p' |% z  t4 d
   }
) n; S) k+ w1 H
6 T9 L, ^/ d" C( l# Ofunction calculatePosition() {8 a5 |/ x: x. f# P: X
   if (xDir == "right") {
# B) G) T- u  k, @5 f3 W) l& Q! C      if (xPos > (xMax - contentWidth - BallSpeed)) {* `9 I3 g9 w- D7 Y- Q. y( |
         xDir = "left";9 X; J7 O& w* t: X! C1 p
         }$ y1 p: ]. \- t6 W0 @6 I6 x2 s
      }- ~. C* i  n2 b
   else if (xDir == "left") {
3 t" R5 d3 P$ c( p8 ]7 w      if (xPos < (0 + BallSpeed)) {$ z* d: N( h7 k2 {. X: @1 B
         xDir = "right";
% a! A* a- W4 A7 w% ]7 u         }& T& Q( X/ F7 p1 w+ q3 l$ T% }
      }
: E% D4 @1 k. M' S6 Q4 e   if (yDir == "down") {5 h6 `9 }1 s# X7 P
      if (yPos > (yMax - contentHeight - BallSpeed)) {
3 K- q9 O2 M, [6 o3 |& y! K4 Z6 R         yDir = "up";" `3 J8 t0 m4 u1 L, z  B
         }5 y, _2 U" W; A) B8 D
      }) l) ^* G" f" T" U4 K
   else if (yDir == "up") {5 R6 B4 {& e, m+ c. m  j
      if (yPos < (0 + BallSpeed)) {
2 Z+ k! p+ M- p2 l) M+ N) H         yDir = "down";7 R5 I# O, H' u) q& h) W, d; t, t
         }
$ k$ c7 {, _. O8 s0 b( Y$ A      }
  i, W' l6 U: A' A! T   if (xDir == "right") {8 B3 i( W" s' C: C
      xPos = xPos + BallSpeed;
3 }. n! `( w3 C      }* o  }; G/ ^5 L& Y" U/ d
   else if (xDir == "left") {
3 B2 _( v1 }1 i7 `: r6 h9 R, T9 _2 G# P      xPos = xPos - BallSpeed;! y( I) ^3 f  M' Q
      }, D5 c: q* ?: f9 N2 b  I
   else {/ U/ s9 [; a0 Y- X; Y4 |
      xPos = xPos;
' S2 @: ~- \$ p: o& p      }. d# E6 n* i) v6 y
   if (yDir == "down") {. Y- b' z, R" q. P( v
      yPos = yPos + BallSpeed;
- y: s* r* Y' t% e      }$ X0 C/ ]4 F' ]. p3 x5 N
   else if (yDir == "up") {
- g4 j& Z/ K( i) j: q3 h# {7 W0 [      yPos = yPos - BallSpeed;9 u2 s: p- k( r% {) D3 g
      }3 n* k4 u% @$ u% ~; u
   else {
' E- c) {4 @4 X; Z% }) X- t      yPos = yPos;/ d; P  p. {9 Z# _) `
      }+ V) m3 N! t  p2 S" L6 p( ?; Z  S, e
   }+ f) ^9 R' I0 F8 J
7 q! P  V8 W: I+ t
function hidetext(){
/ i9 F! P: k# \1 Lif (document.all)' [6 J0 j# Y7 Q& u9 A
supertext.style.visibility="hidden"  X5 Z! v: l( G/ R0 E+ @
else if (document.layers)
; p$ F% h% ^9 S& d; e1 @document.supertext.visibility="hide"2 }3 w+ Z& `* o& T6 g- |2 s' {) W
clearTimeout(animatetext)
- j' k# X# d/ v- d  n% b}  r1 `. ~) f) K0 S3 K
6 t8 D" B8 \* q- ?! x) N
if (document.all||document.layers){$ m! X- S3 w5 U7 T/ @
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 y3 @- f4 v0 rwindow.onload = initializeBall;+ b: d7 n: Z! u$ ~
window.onresize = new Function("window.location.reload()");
2 l/ n2 d* I  U& n( }}
. S9 @$ r* o2 E! m7 J5 l
) \: x/ C" e# b8 L* t3 o, O</script>

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