返回列表 发帖

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

<style type="text/css">. j% H$ \& R0 ~5 q" ], ]
#supertext {+ s6 V. {# r1 ?% u- `. d
position:absolute;6 I) g9 w0 B: r5 D( A* D0 f: {
left:0;; L$ R+ h2 F9 i
top:0;0 J" o" J# D" F: c" Z& E
visibility:hide;
8 Q9 x" A& n/ l! H+ K* A' hvisibility:hidden;
* w4 g" Y/ a1 I; p, g! H}
- D; n& m2 k2 ?; _: L3 Q7 G, j# X8 m</style>- Y: x2 R+ p: T: c- U; Y
<script language="JavaScript1.2">
. B* @* O$ R5 ?9 |6 \: S9 t<!-- 改变下的字体的大小。颜色-->! ?0 f! p# p( F7 _
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 h1 ]/ u. M3 T/ K0 ^# J. rvar hidetimer='';; m, V6 W8 r) ^) M: y
<!-- 改变下的弹跳速度--># W" j4 @# o+ ]; a* I3 f
var BallSpeed = 20;5 _& H( A( V' Q0 F3 |+ z& B
var contentWidth;# N2 Q+ B4 A; _% |$ _7 C
var contentHeight;; N- j! H  `1 g+ c
var maxBallSpeed = 50;
( {( z" p- Y& j  J- U4 W* K0 ~
! f1 t* |. T. W" ^
var xMax;
# a, k3 _0 E* d) H6 [' [var yMax;0 B1 f' m& s) Y2 c( g* M9 @+ ?8 u3 F
var xPos = 0;
5 V0 \( v1 r7 D9 kvar yPos = 0;4 Z. h7 }/ A" ?) F. C/ V$ A
var xDir = 'right';) l2 i+ G9 w& \- c. \& J
var yDir = 'down';2 k& T9 g$ e# n- W
var superballRunning = true;
7 U; K8 O4 y, _0 h. X; Qvar tempBallSpeed;* w# l& ]5 _7 l( j2 Y) v/ @3 x4 T
var currentBallSrc;
/ V% Q9 g# y% }( |var newXDir;+ M6 t1 _+ r3 h# x
var newYDir;& k" ~+ ~/ V& m

# T5 y, c- b" F' M! z0 @function initializeBall() {
* ^; Z2 ?9 z9 L   if (document.all) {
9 `- ~0 L" V# T; A8 ^  e  G      xMax = document.body.clientWidth, w9 p$ M9 ^) x8 w( e8 l, ~, I
      yMax = document.body.clientHeight% r8 z4 d' m; ?8 A9 o4 t
      document.all("supertext").style.visibility = "visible";
6 `- b  B( X: M8 |" H% g+ G      contentWidth=supertext.offsetWidth' v6 Q8 v7 I! e8 @
      contentHeight=supertext.offsetHeight, J* D' d  _1 P( s- M) F) q& T
      }: j; }1 c6 V" o! d% i: R" m8 J; H
   else if (document.layers) {
0 m6 L4 s0 X- [! E      xMax = window.innerWidth;% |" l# J! B6 H5 F1 q3 ^
      yMax = window.innerHeight;$ w( h/ @7 @& ~+ {7 c% N* v& f: @
      contentWidth=document.supertext.document.width
# g3 i5 ~' F9 H& s  U- A+ g- s      contentHeight=document.supertext.document.height# q! x9 A# b( R! ^, s4 x
      document.layers["supertext"].visibility = "show";4 Q. ~! W& t+ c8 L9 m2 N
      }
5 r  X$ H. Y3 @1 g   setTimeout('moveBall()',400);3 G2 b% V! N4 A, n2 C$ x
   if (hidetimer!='')0 K/ R# ^' ]4 ~: q; ]: B
   setTimeout("hidetext()",hidetimer)4 R: R4 d& U# g8 u( T8 Y. \
   }
7 I$ _2 E1 D+ a. B" v& P+ ^
' t/ t& y8 X) D0 }1 jfunction moveBall() {
9 g: `' K+ A: r; C2 ?" u   if (superballRunning == true) {8 q- u' a3 c6 w8 j
      calculatePosition();
7 R6 g% X; d* s; Z      if (document.all) {3 l) D) v# C+ b4 p
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; m8 u" q6 Q$ y' w# U& {; C         document.all("supertext").style.top = yPos + document.body.scrollTop;2 A; G3 d6 G# Y% V+ y5 S
         }8 \. R) o: c1 I) ?* P& ?# {7 R
      else if (document.layers) {
" u. l; ^7 u/ d5 y# [         document.layers["supertext"].left = xPos + pageXOffset;- v2 _) {7 d" }
         document.layers["supertext"].top = yPos + pageYOffset;0 \; m3 K: b% h& z$ I& j% M
         }
* S0 t* l5 P4 I2 ~( Y. v2 ^4 b      animatetext=setTimeout('moveBall()',20);) T: c* ]. K0 T( C3 W* r% N
      }
7 V' ~1 G: |" \) n5 }& |; ?$ O   }
8 ?( n7 ~. c) @! f6 ?1 w! R7 c
0 C& ~; [1 D; D* Q2 @function calculatePosition() {
% [$ f* `4 ~3 I4 A3 G; U& O- r   if (xDir == "right") {
; b2 Y' J- x" l  c4 `      if (xPos > (xMax - contentWidth - BallSpeed)) {
: K  R: V' h6 p& \' i         xDir = "left";
1 @& L9 K- m' G         }
( o/ A  B. \1 v( M* k      }
/ w$ ^2 t5 o/ B5 ^   else if (xDir == "left") {
0 R! U6 I# f% B5 S" Z* f      if (xPos < (0 + BallSpeed)) {
: G7 v+ ]3 {0 u7 j3 |( n         xDir = "right";# w- p: O0 J* O, L5 }5 S8 M
         }! f+ f5 J9 R9 t5 K! a/ g- Z; _5 g* I
      }+ s! [2 W/ ~, h1 Q' Q! z$ z
   if (yDir == "down") {* X8 b- ~0 }' Y2 L8 J) I4 Y  |. y
      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ A! g3 G3 Q: P6 f7 g8 |4 E8 t         yDir = "up";
, m( p3 A) z, A4 x/ {  h         }( H  X5 Q+ M, N: g0 Y& R
      }
* Z" e* [( g! h) L   else if (yDir == "up") {
7 v/ v8 x  e7 a0 Z# ^: F7 `      if (yPos < (0 + BallSpeed)) {# J& d  _$ P+ d0 j* z1 E7 n
         yDir = "down";
' |, j" b% m3 q- ^         }
' n/ I6 V! |& D$ b- l7 c      }
) z2 ]$ J* l; ~# y$ H) M# A) [6 i   if (xDir == "right") {
5 i% L! E$ k6 z) w      xPos = xPos + BallSpeed;3 ^* ^' r7 ?: Y0 X/ h; h
      }
: K* F0 Z3 k9 b/ L4 k+ o8 c( s/ g5 L   else if (xDir == "left") {  _5 i$ L$ O3 [  N3 b$ ]& H
      xPos = xPos - BallSpeed;
8 f( s  B, B- ~& y1 E3 h- `      }: ]+ j2 T7 g$ @" Y2 j& {
   else {& C0 o& I2 D9 e- ~, i" b
      xPos = xPos;1 Y$ }* b  s  Y" X) k: I- R
      }2 }1 G2 |; e7 M' r; _; H
   if (yDir == "down") {: b" M' x3 U5 B. |) @
      yPos = yPos + BallSpeed;# ~$ j) q2 }: D" A5 d; T
      }
& i- L6 p' D5 ^+ G# X9 ^+ S   else if (yDir == "up") {  i/ R% D' d8 q& Z- N7 Z, |
      yPos = yPos - BallSpeed;1 F0 g  I) v) F6 a8 f8 a
      }
3 l- |8 K5 v% t  Z- A+ l2 p4 ?7 Q2 H   else {) z: v( O$ \; c9 f. K9 v
      yPos = yPos;% y$ K1 |+ ]% ~7 `5 u* d
      }
/ ~! |; x4 [; g% f2 a   }% v: w# w# j4 O
5 m- j$ n' }$ F# H- n- z
function hidetext(){
% x  a; F! R% o* W6 Q4 aif (document.all). W3 B2 `/ W5 k6 ]+ ]* {2 g
supertext.style.visibility="hidden"
2 E7 b: ?# Q& D/ G& C  Welse if (document.layers)+ _% E4 X9 s8 q5 _
document.supertext.visibility="hide". a1 P1 T  X* _' u1 L* p/ I
clearTimeout(animatetext)
0 T! T* u1 f( z# d9 U* d* ^}5 b  K8 R) Y% M, X# G$ Y) b  J

' ~( F+ Q8 i" Y' V$ H& [% P0 jif (document.all||document.layers){
$ {; p4 G, c8 s- M+ ~2 ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 ~2 y; b. B$ hwindow.onload = initializeBall;! }+ w% H- \; C2 }( |
window.onresize = new Function("window.location.reload()");
1 s& ?! z7 n; Z$ i* p}
( [8 R( H  J. u" H
8 R' L/ b0 M5 I</script>

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