返回列表 发帖

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

<style type="text/css">
9 l) S7 E- H) C% {#supertext {
+ \- {6 e& W; ?9 gposition:absolute;
6 j  P0 L# ]0 K; g) b3 Y' Zleft:0;
) r( L. v1 Q( Q8 S1 Y# T8 ntop:0;
9 v5 g+ T0 v- z. D) G- l. C' d% Avisibility:hide;4 @0 A/ _3 a5 x9 l1 {- n
visibility:hidden;* D/ B  r5 N4 Y* b- K( Y+ L
}1 q8 G; b3 x0 ~0 y" G3 {
</style>* p; z' ^" P9 E5 I* D" v$ u. L! q
<script language="JavaScript1.2">
2 O4 U) M# B) W3 |8 }* M2 Q3 o<!-- 改变下的字体的大小。颜色-->; y$ K# T  g5 a; |
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% K- w7 z6 j! o8 K# c  e8 Hvar hidetimer='';
; O* k) R3 J& z/ n# j# b<!-- 改变下的弹跳速度-->, Q$ {7 l& U# H6 U  @: A
var BallSpeed = 20;
; Q( L* x; F( u' C/ Z& ovar contentWidth;4 K8 i4 r2 g) \+ F* C9 g
var contentHeight;2 Y. v' D% \( g) E( s% E; J0 f8 J7 v' \
var maxBallSpeed = 50;
8 s$ e3 |) x  g3 T( G
' b- W! C4 I4 L; E6 F' @4 R. A7 M. K
var xMax;; i; b# p, U( G' O2 X7 i9 m% }0 @
var yMax;
  x4 F5 o' T2 l: S3 H" Vvar xPos = 0;' o1 Z- B5 h3 l: y- T' A' O$ s3 i. e
var yPos = 0;% o& f9 a) C; X. P& a
var xDir = 'right';
/ O* Z! C! T5 T9 J# s6 [var yDir = 'down';
% J6 T+ c+ Z. W! W7 \var superballRunning = true;$ N) n( q) |9 T0 b% e' K- G" l
var tempBallSpeed;
4 y3 M- F- S  r5 h( T! b3 avar currentBallSrc;& Z$ [  E" q+ R9 \( n2 E
var newXDir;" F) D8 Q! n. o" l5 K% p
var newYDir;
) _# K+ S  X% J" |% b
+ T: D, }( k% I- L" m/ i( B4 Hfunction initializeBall() {
6 |* t6 M: [+ l) n7 P3 B7 W   if (document.all) {; e( y$ b2 |3 {
      xMax = document.body.clientWidth
* h7 o: O; s/ ~# V8 `) i! a      yMax = document.body.clientHeight
6 [# B3 e' k1 l. M4 }; t) S% B      document.all("supertext").style.visibility = "visible";& J6 a5 O, V1 q  Q; r
      contentWidth=supertext.offsetWidth
& g' o' M4 [) _/ W/ k6 J      contentHeight=supertext.offsetHeight' {# i9 w2 Y9 q! D) i: k
      }8 e8 r' {  b! v7 L+ P- d! e' q$ d
   else if (document.layers) {
. F% N- c! t! \" W  D      xMax = window.innerWidth;+ F( [4 c- E2 ?- B3 m  `( S, s
      yMax = window.innerHeight;! Z5 R5 ~# u, ]+ I! r
      contentWidth=document.supertext.document.width: {9 V) q/ [! ?
      contentHeight=document.supertext.document.height! q3 X" U- V3 w% X. @* y
      document.layers["supertext"].visibility = "show";' A, Q- g% H" M* U3 ~! F& D
      }
! _1 L2 X+ d" t1 `- w! `6 _8 d" I   setTimeout('moveBall()',400);
8 F" U! _; b/ p7 u4 T$ l   if (hidetimer!='')
* h0 s7 G$ S: t9 a2 a   setTimeout("hidetext()",hidetimer)
& J. ?! \. b! l8 ]( y+ a   }
; e! x6 a" v- W' P  ?0 h. h& Y+ D+ s, l4 c
function moveBall() {
" S& O$ I+ E1 S   if (superballRunning == true) {: a/ t+ ~) R' D0 u$ y
      calculatePosition();4 \/ Q( c4 N( }3 j/ {
      if (document.all) {
+ A( {# d6 T$ v4 k         document.all("supertext").style.left = xPos + document.body.scrollLeft;3 R% h' V1 f& G; D. r! |, a, L
         document.all("supertext").style.top = yPos + document.body.scrollTop;/ Q8 ~  W( u' u; i8 a2 m: k
         }6 y1 [- E& E' U1 ]0 D7 A
      else if (document.layers) {; [. S4 ^, M" ^2 h
         document.layers["supertext"].left = xPos + pageXOffset;
4 C0 }( d8 O1 W0 y3 o/ C         document.layers["supertext"].top = yPos + pageYOffset;
" R' E6 _! `% Z- G& M& H+ J         }& Y; T0 N3 u* u: b& e- C4 B+ O* r, Q
      animatetext=setTimeout('moveBall()',20);
! q9 E7 T. C# D% w      }
3 E! L) x5 m) N: L   }2 y6 k; H/ P. A, E% _6 n5 y
. O- M8 J' i+ E5 Z! C: J/ B
function calculatePosition() {+ i8 Y. b! D! e
   if (xDir == "right") {
. C: e8 B+ H7 l      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ b) J" Y! c: Q         xDir = "left";
6 C& v8 N6 d9 C6 a) L/ q: N         }
" N  Q, M9 f2 K! B" _2 d" V: j      }& E8 R, O+ i# t( r/ y, T
   else if (xDir == "left") {) v& q. O# M: T. c) h2 C$ R: E
      if (xPos < (0 + BallSpeed)) {7 ]' M: w. g3 F# a- y/ b% F
         xDir = "right";
) g- D2 H6 }' s0 \* y6 n3 Q( \* u         }
4 ?6 _6 k7 g% B! `4 u. e      }
% r7 D+ c" G6 Y7 a# z# Q9 k   if (yDir == "down") {5 D3 Q) d5 B1 b! h5 i3 s
      if (yPos > (yMax - contentHeight - BallSpeed)) {! D% W2 {8 v3 z7 n+ |5 R) l$ p
         yDir = "up";
. e/ q0 Z) v* K- O         }6 w. R; j& v3 ~3 M6 x6 K
      }
+ {) ~% B( Q: {, a8 K   else if (yDir == "up") {
& N5 H# n1 V* l% n" X      if (yPos < (0 + BallSpeed)) {3 q( b; Q! ^4 i4 ]- _* l1 u1 t
         yDir = "down";& S* u" \- b* P3 v( a# F
         }3 {! ^5 _* Y! N1 d7 L
      }/ L" c! {* c! |7 P. r
   if (xDir == "right") {
- j9 r% f6 y* `# d      xPos = xPos + BallSpeed;6 _. ^  L: B; z: F
      }5 K! x1 w! b$ b5 P. U+ v: R
   else if (xDir == "left") {0 }* F( h! |8 ?9 o6 [
      xPos = xPos - BallSpeed;
6 @2 D. z3 W' V2 J* Y      }
- w- d+ }0 Q4 [; _# J& i   else {2 r, l" k3 E3 e' m3 Y, q1 H
      xPos = xPos;% T) y+ R8 Q& }5 Z
      }
$ b; O+ u8 I0 f% ]$ L   if (yDir == "down") {
$ N- b/ h( l+ v, d" f: r      yPos = yPos + BallSpeed;
4 Q% Z5 l% p4 W. p& l& [      }
* @, h2 b! V5 ?, h; A   else if (yDir == "up") {* b/ f# {6 i1 }; U+ _
      yPos = yPos - BallSpeed;" r7 i8 P/ {. |
      }
" V9 u+ L8 y, G& a0 I  G   else {
% v, F7 i6 q- x3 t& M      yPos = yPos;& k- |/ R& X2 v5 J9 o2 y4 S
      }
4 g$ ^/ E( A# F1 [   }
3 T' X! r( e+ V" r
2 n) M  l# ^& s% efunction hidetext(){
( a7 g! d$ j! K" gif (document.all)/ V# i1 ?! f7 d3 [
supertext.style.visibility="hidden"
( G2 s" b$ |+ i& J- W( L+ a  qelse if (document.layers); C6 |5 k, [+ R( M
document.supertext.visibility="hide"
7 d( l; O* T; K8 oclearTimeout(animatetext)
; o8 R3 @2 s( B! u% j1 Y7 h/ x! z! s}
0 W& F5 |4 Y" l, m5 V0 f) C) h
/ n3 j* H! }/ x& k/ e! |' {if (document.all||document.layers){
4 e$ x) h$ T7 n+ K: ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. p4 h& h8 Y8 s0 R2 B4 D8 G; ~window.onload = initializeBall;, X5 s2 \2 ~( u3 x
window.onresize = new Function("window.location.reload()");
( Z+ V- v. I1 L. n) G7 h3 U; E}4 l; x7 B5 [0 Q! x
; ?; S" p, d( U
</script>

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