返回列表 发帖

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

<style type="text/css">
  `; _& y; x: x" J2 K, u#supertext {
* ?4 ]1 C5 g1 t- v& I$ S& kposition:absolute;9 T5 r9 B" U* d3 Q+ v
left:0;9 Q. `8 j4 W9 [8 a+ J: q
top:0;
. p8 X4 n6 }% ?5 ovisibility:hide;0 Z) f1 y7 n' V) k
visibility:hidden;
( n6 C: ?. x5 A1 k3 j; m! P}/ D# ?' v4 Q/ y  p% e! Z
</style>$ c3 x' h2 v2 u! x# ]1 B/ X
<script language="JavaScript1.2">7 b9 X3 |3 f9 `% g6 j+ I
<!-- 改变下的字体的大小。颜色-->
2 u* n+ _+ |- B9 M4 v9 |1 p/ Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, B$ d! c& J* s, J3 Z, @4 F% f( ?var hidetimer='';# u" {& C; W! G" ^0 Y* H5 t; O
<!-- 改变下的弹跳速度-->, Q4 h* I! m* |) C  T! s2 n7 e
var BallSpeed = 20;
) O* [  @0 @7 E1 Gvar contentWidth;
3 z5 C" a& P* A. {7 W& g5 S) ]) R, zvar contentHeight;6 w% H" B* |, H# o& O% K) ]$ O- y8 x
var maxBallSpeed = 50;( O! b  k( j1 c9 r  H: u  s, G
3 G, j& m' T( [: S8 R
4 {  s# H' j$ |, W# X, E% C
var xMax;, ^3 B! k& I  T% H! c$ v
var yMax;
" C  M" A( c5 m/ n, y' s+ G" \var xPos = 0;
# n9 F+ F9 ?# Uvar yPos = 0;
4 @( E$ D, B$ L+ p6 b/ H% ?var xDir = 'right';$ d8 _8 o. E+ `! W# A
var yDir = 'down';
2 E) `" o1 Y/ Q% i. @var superballRunning = true;
; i& _8 J9 G  n2 `3 {7 I6 g. H* Q" mvar tempBallSpeed;' V% t/ F3 e5 H, o+ q
var currentBallSrc;
! U, q" Y7 m( W) l6 Uvar newXDir;
# }. ~& `& J. G' I" ^  fvar newYDir;! x$ @: S! a) `, N# ]3 I
& ^- U  R4 \0 j& c0 g% i9 O
function initializeBall() {
0 V# \) q: a( P' \  B* h   if (document.all) {
; _+ z1 |- k( ?! D1 ]; P7 n4 d      xMax = document.body.clientWidth) e, J. x% H4 q5 Q# Y3 x. }
      yMax = document.body.clientHeight! w- L" }; ]% k: r( ~
      document.all("supertext").style.visibility = "visible";3 `4 x8 v& t% R; x& _! _/ L
      contentWidth=supertext.offsetWidth
; r% R2 U0 X: v' e      contentHeight=supertext.offsetHeight
/ y* p* ^" k# Z% {      }* g# G+ y. {$ [1 n! a8 O. w8 N
   else if (document.layers) {
/ Y; T" a- ]- y& V      xMax = window.innerWidth;2 `$ d% Y8 J; x% Y  _& ^) @
      yMax = window.innerHeight;5 ~7 h4 I7 }1 ^6 a2 q* d5 W/ y
      contentWidth=document.supertext.document.width
# ?; }8 J+ P" L1 Z      contentHeight=document.supertext.document.height
* j) {) E% Y9 Z1 A% M2 k9 i$ Y      document.layers["supertext"].visibility = "show";" A- s$ W& d" j; B/ B7 y
      }
( x5 W  s$ y& |" w1 q  J0 w   setTimeout('moveBall()',400);
# Z) c5 c0 B" a6 P0 \3 J, Q$ ]; q   if (hidetimer!='')  T; V8 `, J% Z4 r4 B- W0 R
   setTimeout("hidetext()",hidetimer)+ d! N- I7 j, u- U' n' Z
   }
, A( S/ |2 Z: a7 ?4 X0 q& F! L( I
function moveBall() {" x5 |3 W0 j; _" P; t
   if (superballRunning == true) {9 E( N" h  u; l8 b% R. M
      calculatePosition();1 U" e: R6 Z0 j9 J4 l
      if (document.all) {& |. |- |$ S; q9 e2 G5 r* H
         document.all("supertext").style.left = xPos + document.body.scrollLeft;& q' T3 h; g) k3 r6 z0 M
         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ Z9 S! S0 ~9 x# O) X" Z; P) G         }
- _" e  g9 @+ l      else if (document.layers) {
3 e; I  N$ h* g% }! |4 Y         document.layers["supertext"].left = xPos + pageXOffset;- Y; u6 {( i8 ^' L2 e, D: m1 j% _
         document.layers["supertext"].top = yPos + pageYOffset;
8 J) s" n1 t9 |2 ^: N: B         }' Y" w5 O& V2 L
      animatetext=setTimeout('moveBall()',20);
3 C  ]1 y3 P9 ?4 J      }
* h# s5 s- S! r  Q5 `   }+ \7 i: ~8 z* w- m

5 b. _$ Y4 M+ Q$ O7 Kfunction calculatePosition() {1 w" D9 r8 O4 i
   if (xDir == "right") {
$ j7 A' @$ Q9 [, _7 c- ^6 `      if (xPos > (xMax - contentWidth - BallSpeed)) {' ~6 G7 m$ j5 F; W; Y( y8 [
         xDir = "left";
2 I5 A9 s/ s( S- h& ~6 V/ j* Y" H3 h         }
1 ~& V( j0 d4 n3 j; W* U& `! B      }
* h% x" a2 B$ `   else if (xDir == "left") {: J- L1 ?- e+ O) ~+ V
      if (xPos < (0 + BallSpeed)) {$ {: G1 X' ]+ u  k1 D
         xDir = "right";* T5 B" \% R7 l5 K3 z, b
         }
$ y4 @4 i& ]2 _) {      }
+ y7 A7 m4 H) [   if (yDir == "down") {; d: i# }2 W0 z6 K. B. e. \# k
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 }) k2 X2 z9 ?$ a" [
         yDir = "up";, s' ~* |$ Q8 E: c; z" ]
         }2 U& U* P$ T' i9 M8 h0 p
      }: ]+ D! Q1 G0 H. h$ e0 c& K
   else if (yDir == "up") {" \5 x1 O) O7 g! [, F, f
      if (yPos < (0 + BallSpeed)) {
; D+ \% m, `6 M$ ^; F         yDir = "down";
4 s% X, T, i( e* d$ _0 g% I# u         }
6 P8 s$ a4 ]9 L      }
- X8 ?/ _. K& P1 |4 z# _   if (xDir == "right") {
7 |6 A+ j9 q$ z+ p$ w0 p+ A      xPos = xPos + BallSpeed;$ A6 r& e% G3 D% _
      }/ j: d) _$ Y  p/ C, u7 M
   else if (xDir == "left") {
* Q- \, x/ U1 P" H! _5 X      xPos = xPos - BallSpeed;
0 |# |" w$ X; [$ n0 R      }
6 H+ S9 X. j# V! J   else {
; N: f+ l: ~4 W      xPos = xPos;
5 y+ Z# y6 @! U. T3 ~; E% f      }4 T% q5 P, P$ v/ O6 z5 p
   if (yDir == "down") {* e& `1 m% d. d4 Q6 \8 C" {
      yPos = yPos + BallSpeed;
) N3 Y  S$ r, e, ^: W      }
+ q- I6 |; @" Z7 B8 Y) Y/ C' V) [   else if (yDir == "up") {
& s! H( B" |+ c9 r      yPos = yPos - BallSpeed;& Q2 B# U* l* S* Y0 _* c4 `0 a
      }
* H: _9 L  h2 B0 T; ?+ s* t7 s   else {
" v7 H: _1 n" N      yPos = yPos;' {% ^5 ]" ?2 ]$ r& O
      }
; V# K# O$ M: b   }
6 I/ R7 G9 e+ K9 m2 X! o  l" Z$ h/ V. X6 c
function hidetext(){* u: e* t: y& M. E
if (document.all)
5 Q1 \1 U6 s4 X  m7 J- U( Asupertext.style.visibility="hidden"
% s' h( {/ J  h' h  \# E( g1 Yelse if (document.layers)
, K" N: p' x! w' k( ydocument.supertext.visibility="hide". L% A% D+ x$ Z: w" q+ \! W2 G
clearTimeout(animatetext)
/ \2 m, |, o# w}
1 B: r/ r" W2 T3 Q1 O; }: L% D+ v
9 E) C! p9 U' Nif (document.all||document.layers){
" A/ }- u# U8 Edocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  s# o5 g5 h: ~4 r9 Hwindow.onload = initializeBall;* ?0 a" {5 o6 I1 l
window.onresize = new Function("window.location.reload()");
- G, a8 I% @/ u/ L/ c$ |}
. z; x) M" O  r1 k
- ]( Z  u- r( u8 \3 X! G1 I</script>

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