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

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

<style type="text/css">
; q  q7 {; M" p1 a% H/ P#supertext {3 ?& r6 l; _1 n; J/ q4 s8 K
position:absolute;
2 m' h, d  b5 A* U( f# uleft:0;  S0 s! \( ]$ k0 V$ P, p/ m8 D
top:0;/ i7 G3 I: f3 w0 s. `2 V: o
visibility:hide;( S" P; n! K5 j
visibility:hidden;
2 X8 u% I& b( n" r2 r* S( O}
; f8 f: [  _$ q' h$ r/ P- z</style>
4 o  V4 g' T  N" d& P# N! G5 w8 z% E<script language="JavaScript1.2">
) u, Z, q# K+ p) F<!-- 改变下的字体的大小。颜色-->/ Q0 ]. r0 o) U/ l  {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& t1 _) Q- v/ l6 v6 r) L) }
var hidetimer='';
9 k. T- c; ~$ S9 K: ?* T2 a9 u<!-- 改变下的弹跳速度-->. H% W2 v/ o$ U. o% V, y
var BallSpeed = 20;
8 h- o/ R7 \% f0 |var contentWidth;6 i& g! Z" S4 C" L, M
var contentHeight;
8 p# l  ]" T0 m, A, kvar maxBallSpeed = 50;
( x# V9 y; z) o6 Y! y3 U! A7 d* j$ V( A( d0 c
* g# i5 G! h' m8 c+ ~
var xMax;
2 x4 e0 ^. X; {5 z. kvar yMax;
* {+ _" O' u& I- p! \var xPos = 0;9 N. z) B2 D5 k. p+ {$ h! C
var yPos = 0;5 o" l/ }. Y, K0 i
var xDir = 'right';+ X* p5 k* _  ]8 F2 A
var yDir = 'down';. x) K; b; [& A" y5 j
var superballRunning = true;5 d7 S' Z. w" r/ O, A' P: W9 X9 |
var tempBallSpeed;
- s1 l0 i1 I) X& i8 }. Nvar currentBallSrc;
4 A* G# ^) ~4 x" b* J/ [var newXDir;; o/ t0 Y9 p7 F$ d& T- H
var newYDir;1 `) {6 H' G; v; ^7 @/ Z

2 R* [6 ~" X+ X2 nfunction initializeBall() {
" g& Y3 ?4 d/ F8 M   if (document.all) {3 M. \5 F; G0 r
      xMax = document.body.clientWidth  i% a4 ~8 m& C* ?- ^
      yMax = document.body.clientHeight
1 X' y5 C, c$ w8 l. \3 P      document.all("supertext").style.visibility = "visible";: T7 m* S% q& y4 x! R# b
      contentWidth=supertext.offsetWidth
3 {) {- e) Q$ U      contentHeight=supertext.offsetHeight
% |  p. x! T5 U# ?: N4 Z2 B0 k      }- `( t! v7 `% [& V" I4 T
   else if (document.layers) {
* \- I7 H- I4 [5 {      xMax = window.innerWidth;
5 z& P" J& t# ?& M0 _      yMax = window.innerHeight;
( w' g+ F6 Y7 n5 c      contentWidth=document.supertext.document.width
& r) ]' f4 f7 T! j      contentHeight=document.supertext.document.height1 `% e$ N7 {& U6 ?* }) j, ?7 z
      document.layers["supertext"].visibility = "show";
' A* m6 i" q4 d: S  i      }6 z+ l: ~# R& r' p! ]# u; A
   setTimeout('moveBall()',400);/ u* M0 l3 W$ y4 x. c
   if (hidetimer!='')- P# [0 I: I: s# Y
   setTimeout("hidetext()",hidetimer)
9 n8 P! x3 U3 t' u: d1 y' r, o( G   }
' `* r  F& @' r; y7 b+ J- q2 }7 E( C" B: l9 \2 R4 I/ @
function moveBall() {; a& z' M0 G! p+ E8 G& c; x7 s. c
   if (superballRunning == true) {; D  l4 V) I4 z
      calculatePosition();
2 m' N% f, E6 @8 {      if (document.all) {
6 n  z3 ^# T9 }9 m! k/ j/ T: W         document.all("supertext").style.left = xPos + document.body.scrollLeft;! u7 K& N( R5 `9 j+ I* j+ P
         document.all("supertext").style.top = yPos + document.body.scrollTop;+ v, k7 c; A. d9 H9 x9 }
         }
/ }0 A' F" \# X, Q! ^" b$ W      else if (document.layers) {
! G; S0 J* t/ P. j# j         document.layers["supertext"].left = xPos + pageXOffset;
( C* \$ B: ]8 l  @, L8 Z3 T5 S: p0 P9 b         document.layers["supertext"].top = yPos + pageYOffset;
  t! e0 ?+ q( X) x6 o$ x         }% \: i; E5 S' M; T
      animatetext=setTimeout('moveBall()',20);/ [3 F/ P, ?! \/ @6 g4 k' v) |+ L( D
      }
7 ]) m. ~: n+ u3 }" ]3 a. {   }
2 y4 X5 [  v) k4 {) Q2 j, ^5 d( d3 _7 f) E
function calculatePosition() {
% r, m9 z8 Y$ n2 y  G) V( ]   if (xDir == "right") {6 i$ R4 y/ ?+ J, I8 y
      if (xPos > (xMax - contentWidth - BallSpeed)) {* }; k# \5 T) j7 Q% t0 [
         xDir = "left";9 l+ y8 N5 A" T
         }# ?. G. f' J& D4 ], l9 q
      }
  B9 p; D- S' J4 l; o3 w) k2 [   else if (xDir == "left") {
9 x- C& g2 ~5 l3 n      if (xPos < (0 + BallSpeed)) {
# f2 R% `( N4 A; a         xDir = "right";
1 j) _+ S# ~: K% \         }9 B. ~/ T  T/ v
      }
8 ^0 L0 D1 L% b0 }7 x% H3 z5 ~   if (yDir == "down") {4 M6 x: S  X9 o" M1 i2 R4 x
      if (yPos > (yMax - contentHeight - BallSpeed)) {
0 [" D& d# P' n. E, H5 O8 F: H         yDir = "up";
( `5 \3 f, ]3 }$ k! x         }
: k0 M! P  S& J* B; P' @4 P      }
9 }7 I: C  P2 ?: b. a2 V   else if (yDir == "up") {4 |+ k  D( E" [# ?; C8 h) \
      if (yPos < (0 + BallSpeed)) {
; U5 u6 a$ _6 O: V2 S2 Y9 C- G" X         yDir = "down";( N* k4 a7 J! N: A1 L  j/ o0 P
         }
( t& P7 d# _9 e, i; x( K      }) J' B3 u4 N- y8 z) w: a* g" J
   if (xDir == "right") {
2 x* w( x0 G) a% I9 X5 S      xPos = xPos + BallSpeed;3 h4 |! ^4 M) ?: i3 r+ C
      }
& L$ r8 _5 H, [1 {   else if (xDir == "left") {
* C' R$ m  w# o      xPos = xPos - BallSpeed;1 |5 @; T$ j# ^) g7 |
      }- G! G3 z- P& F2 R
   else {
# S! g: c$ Y8 W9 q9 v# W7 @' V/ [      xPos = xPos;
: a8 {9 d& m, M0 h8 K      }
2 `7 p4 d: {' j4 q3 w: s5 a   if (yDir == "down") {! n7 Z' x- J3 S) R
      yPos = yPos + BallSpeed;- \) v4 p0 `3 j" J; l
      }( A' i7 p! o  ~9 c) t. W' s
   else if (yDir == "up") {
2 ]) X/ \+ `& P      yPos = yPos - BallSpeed;
  A. X3 a, s) _      }' D/ o% X# G) t4 J/ o# Q
   else {- G$ j6 |- f9 r1 ~# k' Y
      yPos = yPos;
4 X" }* @% [1 P; a  |* N      }8 F' H+ ]5 w! U3 B& l1 \2 R
   }
% T- L  g/ W8 o) x* J
9 r$ [9 j3 @/ \8 k( e; ^) d' Ofunction hidetext(){7 V+ K+ d; h& a$ h" M6 j
if (document.all)! {' Q5 V& g4 F0 f8 x2 w) C
supertext.style.visibility="hidden"
7 {2 P  c5 W# f6 n! d: Y; C# Y$ qelse if (document.layers)
* ~! }) y# o, idocument.supertext.visibility="hide"
' T6 Z$ d  X# N3 Z8 B5 H! jclearTimeout(animatetext)0 b: `% \' L1 d  r) H. W
}6 r+ G5 w  r2 o! B6 C( v( O
+ a! x# l5 r8 V- F  C
if (document.all||document.layers){2 o, _% S2 G1 w/ U( P1 C9 k
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 y3 k' I. X8 J% n  k. p' j7 wwindow.onload = initializeBall;# _  }& Z( H# s" T) x' ~
window.onresize = new Function("window.location.reload()");
% [1 ]3 f- g! W0 l8 z6 Y! w}7 K7 e, w' b8 r2 G) C, g

  h: e: l, y: |/ B. w! s: c/ U</script>

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