返回列表 发帖

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

<style type="text/css">
/ R! z2 ]1 @& f* t: |#supertext {
- w- W/ ]0 m* J' jposition:absolute;
! I- t. I5 {- R% Rleft:0;
7 \7 {  e& Y3 B4 l  |top:0;3 y! F& |6 \( G4 ]
visibility:hide;6 m; G' o) Y; B- H
visibility:hidden;& j$ o+ f6 u4 E) P% s! v, k* O
}! A$ L: R( `7 A( S; Q2 T' F
</style>
0 r1 u/ E2 [& _2 [8 C<script language="JavaScript1.2">9 Q7 K" A9 l0 L* S0 r
<!-- 改变下的字体的大小。颜色-->* Q0 u- b! s- o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 O+ ~+ v# c! y" I0 |
var hidetimer='';
" e  S0 a! b$ O4 S; X+ p% \9 }<!-- 改变下的弹跳速度-->) `8 R7 B+ i7 _% M
var BallSpeed = 20;
' I% m6 y7 h0 @- z1 i3 f7 [var contentWidth;
" S& f3 ]. ?8 n! k% `" C, T6 q; ]var contentHeight;
) I5 n; b4 Z1 ^+ y" hvar maxBallSpeed = 50;- e' l0 z* {  f- x, b/ t

( Z, |$ o5 @3 e3 s& T7 F
1 Z% `- O7 o8 u0 Lvar xMax;
. ]( V' W0 c8 @. V1 \. Fvar yMax;
; T: X/ U  U, T/ @var xPos = 0;
! o0 p& }4 g) g3 m  Tvar yPos = 0;7 x" _3 M  O6 a, w2 F
var xDir = 'right';3 S+ M6 h( g' p& u$ j+ u
var yDir = 'down';' v9 s2 o( {& r( K7 g/ Z, v
var superballRunning = true;
7 p* y5 D3 Q8 \) I5 ?var tempBallSpeed;
9 B* S7 W7 o8 x2 |! r+ ^8 mvar currentBallSrc;
' \8 a& m. C/ t# e1 H& vvar newXDir;
3 ]- I' [- g- v6 i+ u9 R" \0 Mvar newYDir;! P5 r8 s3 ]3 `& d, e- H6 M* a

- A; n! u# Q. Y2 d$ g3 Sfunction initializeBall() {
+ r; _2 n: o  [- x( c. M' A3 G   if (document.all) {
  o. C7 N0 d1 Z% O; K" ~1 c# r      xMax = document.body.clientWidth2 U! b4 [9 C+ O
      yMax = document.body.clientHeight5 Z- N8 H/ A. ?
      document.all("supertext").style.visibility = "visible";
8 Q" h( M+ p: ^6 m2 E% G9 s      contentWidth=supertext.offsetWidth
9 R) V, h7 M* ^      contentHeight=supertext.offsetHeight5 W; V5 a6 ?6 h
      }
( r$ Z' S2 x, A9 B) ^   else if (document.layers) {+ }% K6 O8 D2 b
      xMax = window.innerWidth;- m. H) A1 x4 i0 u% E
      yMax = window.innerHeight;8 ?. l% p+ F6 S& B- H' E; b
      contentWidth=document.supertext.document.width
# i! ~4 f$ Q( \: L3 c3 o      contentHeight=document.supertext.document.height, y1 ^2 q* E% |/ H: Z$ `
      document.layers["supertext"].visibility = "show";
% o2 l# `8 m! @3 R4 v. ~      }
0 N' \! r* E5 N5 ~+ i& a* j& e   setTimeout('moveBall()',400);+ K  _2 \1 I0 C. ]
   if (hidetimer!='')
3 Q- U8 k' ~5 l$ Q. E' ~0 u& b8 s   setTimeout("hidetext()",hidetimer)
2 _7 i; v3 D- U% C0 Q   }3 @2 m% L9 K3 M& [+ {( A
) j. P0 ]0 s2 v+ f
function moveBall() {
3 z+ `) L! C4 ~! u3 |$ G/ E* }   if (superballRunning == true) {
$ U& B3 h6 F" |. `      calculatePosition();' |% f5 t* B% e3 l, b
      if (document.all) {
5 E! N& B5 a# @1 C; y" _         document.all("supertext").style.left = xPos + document.body.scrollLeft;( @! n7 m4 p% ~7 Y  q
         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 r* }5 j* T. r7 C         }
: j: Z' Y4 {% {1 D8 P- \      else if (document.layers) {
% _% U1 A; K: V4 t1 D6 \5 Z         document.layers["supertext"].left = xPos + pageXOffset;, P- z9 e' y) P: }' n2 Z
         document.layers["supertext"].top = yPos + pageYOffset;, l) B6 y  P, B9 ^/ e' m+ I  Y0 V
         }" D! I, d* c  f$ F
      animatetext=setTimeout('moveBall()',20);# T+ b- P) O, c4 }5 w6 T' J5 [
      }
% c# c# y  g! n$ u, ~% z   }9 M& q2 z; M& U
1 m! e2 W' o) w2 x" |; ~' d5 C/ h
function calculatePosition() {
; E+ ~  s6 a, c& W: ?9 n   if (xDir == "right") {8 P3 Z( R; s3 n. d, G7 W; f5 I
      if (xPos > (xMax - contentWidth - BallSpeed)) {5 A0 b+ ]* x) V* W2 K. g: ]. `" ^+ p
         xDir = "left";
2 I1 E9 N7 y# b# u         }
: h! {! Z1 v2 |      }
0 C- G7 i' f8 ?- c0 _! @   else if (xDir == "left") {
3 F! B3 {9 t: K5 k5 n      if (xPos < (0 + BallSpeed)) {1 k7 |. J8 r# u4 p0 U
         xDir = "right";2 P. \$ u1 f+ K( P% j
         }7 G& v( ~" T/ Q. n9 {9 _
      }
" N! u6 q% F$ ^' ^8 i" q   if (yDir == "down") {
# B& y! x7 N( ]' j0 C      if (yPos > (yMax - contentHeight - BallSpeed)) {3 W% @" h2 x) e; F, d
         yDir = "up";, ~2 }9 J# F, ?8 u1 X$ K. `: ^4 U& L
         }; o) T. Y/ |, q8 x1 C
      }
6 e# W7 S- E0 Q: ^4 w   else if (yDir == "up") {* k* e: }' }6 }  d' G9 J3 R0 ^
      if (yPos < (0 + BallSpeed)) {
; p7 Q# o& o# y$ A$ a$ h# T         yDir = "down";
* e: M4 y1 l) l* L. z9 d3 Z. S         }0 q$ n# n* ?) n0 i+ [, G! ~
      }0 ]: b& a% E+ z
   if (xDir == "right") {
) X* g% o3 \$ e0 ^5 c3 c0 ^      xPos = xPos + BallSpeed;$ i9 f% i/ f+ u1 R
      }
. p+ V) H# ~! l- `   else if (xDir == "left") {8 f  g/ K; M+ ]7 o5 l9 i1 o0 q) Y$ m
      xPos = xPos - BallSpeed;) w( U: A  ^5 g- I9 S( V
      }
0 Z2 ~3 M+ H1 Z# u   else {
$ _% O+ N4 \) w- K+ T  }      xPos = xPos;
) L4 F; B0 O, P: k; X# n      }8 A; Z6 P- U  g) J; K8 O$ D
   if (yDir == "down") {7 ~9 |' [- ~7 C7 d
      yPos = yPos + BallSpeed;
7 h( y9 ~2 H% c' k8 N" `      }
: h* E5 d4 W3 F' T+ k5 S   else if (yDir == "up") {& D5 G3 g. m( R* u  p( e
      yPos = yPos - BallSpeed;
3 S: b; J! ]! o7 A* B" G" d- M      }: J% E9 C0 ^0 u
   else {* M8 c$ p1 {, j8 F& o' o
      yPos = yPos;
: X  k! ]- T2 O7 x) L9 E; W0 y      }7 c/ P: |% A* o4 l, U
   }
7 z1 \1 z7 A: w/ ~9 {% n& P- F
* _2 \) F6 a# J$ i# Y* H' Q, y- bfunction hidetext(){" w* ^- t3 i+ M, e  w3 M& v
if (document.all)' {4 v4 [( S/ Z' ?6 Y0 y* S
supertext.style.visibility="hidden"5 a- {2 g. ?- A4 _( T% J
else if (document.layers), Y; |; r; ^6 d/ k+ ]* v
document.supertext.visibility="hide"
1 m( U' Y" [8 B2 x; ?. t' YclearTimeout(animatetext)6 N4 N# i& J6 H2 E+ O+ @
}* V6 J  E% ?, |" w- E

5 J5 I' ^% H3 N* U" P2 N% Rif (document.all||document.layers){+ e# c6 B4 a) O) ~3 B$ e
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ v7 a2 \/ S: F( F, R$ x4 W* @window.onload = initializeBall;: T2 G! o8 \9 D* s( b- p
window.onresize = new Function("window.location.reload()");$ r" N( J7 ]. ]6 S# e, w
}  q& [* y) d4 u0 M5 S- _0 F( }& _
0 @, x2 @) K7 ]# E7 W; o
</script>

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