返回列表 发帖

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

<style type="text/css">: R! T0 Y) b2 S
#supertext {: W; G) o% W2 a, R! d& p
position:absolute;6 B9 w% F  p4 t* V! A  N
left:0;
, l+ m/ x( z9 E  T3 _top:0;2 k# L# B$ v; B1 y9 v1 V
visibility:hide;
, k- c9 V3 e3 I7 fvisibility:hidden;3 E/ N$ x: K  Z0 `  Y
}# v' _% {; X; {- N3 T
</style>
, t8 e0 [: {9 U# @  L; W, ]6 n<script language="JavaScript1.2">
. H$ Y0 t& f$ t: u( F<!-- 改变下的字体的大小。颜色-->
6 {- A9 G" ?9 ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( h: Q8 w2 u: j) [7 g- `var hidetimer='';! s1 }* }. j  F1 Z) \/ P$ F8 L
<!-- 改变下的弹跳速度-->
% H" d& j' A. d7 q4 J8 f; Y( Xvar BallSpeed = 20;- _2 I9 ?7 l! M4 r$ U& s/ H
var contentWidth;
2 i% e" o2 I. R, Mvar contentHeight;% Z9 U4 X: i$ Z; O, c6 Q
var maxBallSpeed = 50;! {* O7 G* m' F

: y5 u. Q: Y; M, F. T7 V& `1 H
+ i' J$ p* x6 g$ x: h: vvar xMax;  V8 s' h  z& `! G$ x' X2 N. L+ {
var yMax;- `3 N" C8 m- [1 K9 y: V
var xPos = 0;
' a* G; X( N% D' l# r9 w9 hvar yPos = 0;5 M5 k3 j* g8 P+ T/ L9 F2 h  F
var xDir = 'right';
+ s, C/ x1 O, L; e/ ?; U" evar yDir = 'down';
6 H$ T, h& }/ m' I# h0 B6 x0 X; Hvar superballRunning = true;( z, A/ X6 n) O. Y' D4 N7 ~
var tempBallSpeed;
7 j2 b4 Z- I% s' Nvar currentBallSrc;4 H$ X7 Q# O( H% [
var newXDir;& y( R1 ^0 f- {
var newYDir;
9 M7 p! Q- J5 k; h* B) Q% y1 u& t5 o$ V( Q* N
function initializeBall() {' C; g+ o$ x( u7 Q7 N/ Y1 W
   if (document.all) {# t% O: g* ~+ F# J
      xMax = document.body.clientWidth8 @& ]* c: l9 f$ \, P  [
      yMax = document.body.clientHeight
5 G: v/ P3 s3 R      document.all("supertext").style.visibility = "visible";
# s7 A; b; U! Y# t0 h" R- x% ^# |      contentWidth=supertext.offsetWidth+ X5 P7 }  d' a/ U- S* v
      contentHeight=supertext.offsetHeight
1 @* l2 p$ c( `/ v' T4 |) ]      }+ T$ F9 c& }$ O2 N  T0 Y
   else if (document.layers) {
. X( P/ r; n3 i! [. Z; Y7 Q: J      xMax = window.innerWidth;
$ P. a0 U" v5 R" ~/ T      yMax = window.innerHeight;
8 Z" T( \5 J/ s, u4 e      contentWidth=document.supertext.document.width  _' R+ a6 L8 P/ U! p& Q
      contentHeight=document.supertext.document.height
, I& q% Q! z8 E      document.layers["supertext"].visibility = "show";6 g1 \  K2 J3 L* s9 Z8 n
      }
: T- [7 m* H7 s5 g/ a   setTimeout('moveBall()',400);
, u7 \  u0 W3 o" b   if (hidetimer!='')
1 [3 ~& J7 z8 R) Z6 [   setTimeout("hidetext()",hidetimer)2 Y9 \1 Z) \* P
   }7 S  v; c* V4 s: @

7 ]) t( V2 f3 h+ a* [5 w. Qfunction moveBall() {
; _% z- }; y0 G' Q2 q! ]: i   if (superballRunning == true) {
. v3 o  m, m1 i. J" ^5 c      calculatePosition();
; x9 C" u+ u, n5 u' h. F      if (document.all) {
7 q1 N0 K6 n8 Y6 y. z. T$ z: \         document.all("supertext").style.left = xPos + document.body.scrollLeft;' y8 j) D  m% |1 F
         document.all("supertext").style.top = yPos + document.body.scrollTop;; F3 ^; A( P+ X* k
         }
4 y+ ]$ R5 f$ N5 G! H      else if (document.layers) {
# J, v* h; q" x- k% E2 C+ d         document.layers["supertext"].left = xPos + pageXOffset;) U7 }* y8 B, i8 Y
         document.layers["supertext"].top = yPos + pageYOffset;5 z0 o6 N7 z5 F( l4 @
         }0 [) n: x8 d# U: @* U% ?$ b
      animatetext=setTimeout('moveBall()',20);4 k+ f9 p2 B' r: c0 f
      }
5 s* y. q3 S( o& f3 A   }6 d  v. i( D* u9 g3 M! W

7 Z- I+ H/ B3 m% ^, v/ c' d: hfunction calculatePosition() {
6 C9 d) |" b0 G, `2 }6 {* {0 J   if (xDir == "right") {
/ R; f/ z- k  r" R  V/ t      if (xPos > (xMax - contentWidth - BallSpeed)) {
' s9 {$ d6 v  \8 d+ c; Z         xDir = "left";7 C( h( D  y* x4 y  M
         }* u9 J6 `/ W5 n$ j: ?) h8 ?
      }
- U8 v' g& L8 R, e   else if (xDir == "left") {/ w# g' |3 a: S7 i
      if (xPos < (0 + BallSpeed)) {
. X% W1 A8 L+ Z8 e1 l" G3 [         xDir = "right";
# v) ]3 N9 v* L" {0 V1 w         }
+ h! a: W9 @$ V4 t) z- [      }
* X4 l8 P2 k) Z" i   if (yDir == "down") {& s0 ?; K* m$ X2 U& q8 X! n
      if (yPos > (yMax - contentHeight - BallSpeed)) {
  l% Z8 A5 |2 X. {% K0 H: H2 q1 L         yDir = "up";
. o* H0 c$ p" ~- t# O         }* ]# {9 F0 {  f3 v( C/ d
      }
# M3 ?& I" d2 T% j7 {/ c5 K& S   else if (yDir == "up") {
7 {! o, d8 l8 g8 E4 ?, Z      if (yPos < (0 + BallSpeed)) {
. d8 l  H" g+ S" I         yDir = "down";
) ^: c2 I1 s  N( j: b# G         }8 j% k$ C! ~& u& I0 Y: J2 x$ N6 e
      }; \5 j& B, m1 i8 o
   if (xDir == "right") {
$ K$ |' j4 U' a: q* ?7 K( u) A      xPos = xPos + BallSpeed;6 F, Q0 ^$ P5 ~
      }$ V: d- Q/ D0 E
   else if (xDir == "left") {+ [. B. ?  v# ^
      xPos = xPos - BallSpeed;
3 q5 ^. x6 p0 ]4 A! o) `      }
2 r1 p& |1 f3 \" |   else {
4 O* i5 S* L5 N# L      xPos = xPos;
' a. G: g: U8 R9 Q# t- t6 z      }
) }% l$ S* i' d( q* j$ a% p   if (yDir == "down") {
9 u4 C; S- m7 u- v      yPos = yPos + BallSpeed;
+ k( F) ?  F1 h7 ~      }$ v( B. n5 z( E( r
   else if (yDir == "up") {
1 O0 z" W( _# @) l) x' V" l, ]) h      yPos = yPos - BallSpeed;' S! M1 {& b, z' o4 \8 ]
      }* d9 ~9 l& n" S; [
   else {8 L( D: Y/ L+ O. a& S6 X  ~
      yPos = yPos;: m& U7 J( {8 ?) X! w
      }+ p( h8 Q5 P/ x( ^
   }
' _1 A" b- Q, R& y) [9 ^9 ]$ N
6 ]5 h, Y/ `+ U; n( M6 y/ K; r$ Afunction hidetext(){+ G" O4 d4 W6 E
if (document.all)
7 T$ b% o% p, K" Usupertext.style.visibility="hidden"; C+ |  O. ~: V* Y. R
else if (document.layers)) T5 Y% T  k5 a9 V$ ?7 C& R
document.supertext.visibility="hide"7 H' v' m6 K- n9 k1 a" q
clearTimeout(animatetext)
) T/ r6 [" S1 N9 a  F}
# ^" L/ i0 \( I6 Y# T, w* O2 `% k7 U7 \) F  |  C
if (document.all||document.layers){" F* {0 ]! v* P+ R. `) x, {( E
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 Z2 v& g- U+ D) ?- c- l% {
window.onload = initializeBall;
6 ^2 E  s7 y" y: \; J* M. Z( ?, M7 ^  @window.onresize = new Function("window.location.reload()");( M0 w- W6 }0 l6 M4 Q
}
7 [: l  i% @% o/ _
% {+ i0 e/ C( B; R+ `" W</script>

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