返回列表 发帖

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

<style type="text/css">
% R: M+ |$ N/ M# S#supertext {
- ?0 r8 \3 c) A5 s2 fposition:absolute;
+ p1 G/ V# J- _( }1 P9 dleft:0;
' W& }/ s( @# [3 f: Htop:0;2 K( W+ {$ i7 _6 ^: J
visibility:hide;
# T# I1 f" `- U7 L+ ~' \' B, uvisibility:hidden;( q- Y, q* s/ u9 r. I1 I! t$ K
}
5 y- r$ P9 u, Q; ~- R& u</style>4 A0 [, v( b$ M5 o3 E
<script language="JavaScript1.2">
( y5 G- f8 U6 w: i5 y<!-- 改变下的字体的大小。颜色-->4 V2 \3 R* ^4 Q. A; Y- f0 W" b  L  h
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# G! \. Y2 p% c1 x3 e7 j/ `; P
var hidetimer='';7 I; X# [7 [, l# y' G. s5 a4 P
<!-- 改变下的弹跳速度-->
# j# \: o' V0 @' s5 J- Qvar BallSpeed = 20;& y! e& x. W- J8 J& _* N. x
var contentWidth;
) E# w( E( a9 M1 c6 A6 `- Uvar contentHeight;; H* g% U* ]" V& |
var maxBallSpeed = 50;1 c0 l6 t8 B- q% B. B

# n7 k' A# l* U7 [  s( l$ J- n* g
var xMax;6 N5 T. X/ s+ C# k* R, L
var yMax;9 b3 p& c' c+ J: \9 p6 L; G
var xPos = 0;
8 W& i2 i9 J& R3 S' bvar yPos = 0;
- Q- }; Z$ H( q" H( R. Nvar xDir = 'right';
3 }+ l9 r/ k9 E+ N+ h: {' {. x8 Ovar yDir = 'down';+ g. j8 L' t$ A( ~* M5 b9 N# \
var superballRunning = true;
7 y9 k& Z1 K# h% E5 {4 jvar tempBallSpeed;
! [1 d/ @! Z5 [% }: mvar currentBallSrc;
) L# @# g4 c- ?/ q* x0 q$ Evar newXDir;
0 P; j4 p7 s( S+ Pvar newYDir;" F5 ^8 G9 I$ n& l7 w, F$ r

9 I* c/ c& I% {# I9 _. Jfunction initializeBall() {4 f8 U. L, Y1 S  r3 ~* x+ U
   if (document.all) {# q2 M0 I  Y7 ]+ k0 _5 T2 e
      xMax = document.body.clientWidth
; w: F, e* ^: {" Q" F  H8 z      yMax = document.body.clientHeight
$ y( Z: J" U% h      document.all("supertext").style.visibility = "visible";- N; @. V' C: p! w
      contentWidth=supertext.offsetWidth
4 |' f, Y: _/ j, F+ X6 X      contentHeight=supertext.offsetHeight) l- N1 j. b' l* n1 ?8 K- `
      }
" U- b- W' S$ y1 |   else if (document.layers) {
! n! L$ r" P/ D  H! \$ ?. c      xMax = window.innerWidth;& a; `0 w" y% y% _
      yMax = window.innerHeight;
; l% a6 l3 a; z8 P      contentWidth=document.supertext.document.width) _" @1 @$ L  F* s
      contentHeight=document.supertext.document.height
4 v6 e: E; S) f4 P      document.layers["supertext"].visibility = "show";- }! Q$ ?# d. S* B8 b
      }
* a3 X& z4 m7 J, r. o   setTimeout('moveBall()',400);- S9 m0 \- g5 B4 A
   if (hidetimer!='')2 f/ z# _" q2 u- [! n4 A, f/ u
   setTimeout("hidetext()",hidetimer)3 M0 D! l: ~. P' n
   }2 K5 w% K. x, `1 @" z

4 z1 i: Z2 z" y" ]+ L$ `& ffunction moveBall() {& I' O7 V4 _$ o1 m
   if (superballRunning == true) {
' c/ c+ g( w  \4 \: G+ M: a$ q: ]      calculatePosition();
2 `6 u3 `3 y1 H* z0 G3 R( r      if (document.all) {
5 ^( `+ T" c/ W$ a; Z! {- E4 j% a         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 ?0 w3 r! F. ?" _4 K6 G' d         document.all("supertext").style.top = yPos + document.body.scrollTop;9 A. e( k; ~$ B( `) C+ \# J5 N, X
         }, j! H" D, `: R% O2 Z
      else if (document.layers) {
2 }0 ?; _$ l7 e1 _/ h9 Y. o         document.layers["supertext"].left = xPos + pageXOffset;
, ^9 o& [' i" m         document.layers["supertext"].top = yPos + pageYOffset;; Q  o! g% M4 M0 x
         }3 _9 j* E% X% C4 R6 p+ R
      animatetext=setTimeout('moveBall()',20);! x  x4 V% {  l/ C
      }( |/ }0 U% l; A& X& n4 d
   }5 ]; q/ s( M9 h' f  s
9 ?$ F: G8 C# ~- t$ T9 y
function calculatePosition() {1 b% |' S/ c4 `1 p, O9 T
   if (xDir == "right") {5 m* Q3 T  P) {  r; e
      if (xPos > (xMax - contentWidth - BallSpeed)) {
8 k1 t0 M& k- Y4 M! Z         xDir = "left";% @9 e6 b& L/ g4 M  h
         }% t, ]( ^2 e6 _3 D" z  ^
      }' V0 E; v& s8 J6 M3 Q8 l
   else if (xDir == "left") {
1 j' T6 \2 Z9 D! L! k7 D( Z& C      if (xPos < (0 + BallSpeed)) {7 w' I: `% f, Y. [2 }7 m
         xDir = "right";
1 K, x! ?' N4 h1 x: m- j' O         }
4 M7 u) R0 y6 B; V  |. K! i      }
* v" ^% t" s4 ?, n   if (yDir == "down") {
1 o: S4 d. v  N* ~; M9 `# W      if (yPos > (yMax - contentHeight - BallSpeed)) {
, z% p- `% W( S9 F         yDir = "up";' L0 N$ I, j3 o4 t) ^
         }
9 x2 s2 {+ T  T; t0 e8 i- q2 q      }# |1 h0 x3 g, U# m' E
   else if (yDir == "up") {
8 p1 c% \2 x, w2 E' A2 n7 o      if (yPos < (0 + BallSpeed)) {- r: s% p, t8 l6 W+ Z) Y1 d; b
         yDir = "down";
4 h" I% [+ m6 s6 ]         }, T$ D; W9 y& W/ J5 X0 M
      }
* }4 Q3 ~* l6 N   if (xDir == "right") {
+ m( p8 E. A+ N. x# c' W+ z0 _      xPos = xPos + BallSpeed;
1 E: b" e( g9 O2 r$ q+ Z      }
, E5 ?7 v* j# {+ ^. v4 m7 r0 D/ g   else if (xDir == "left") {- k: ]! ?. n1 j7 X% G$ {. E# B
      xPos = xPos - BallSpeed;
7 W* a( F7 @+ p! R% L      }
) l, {2 s: o; J' g1 q   else {
% s) u2 i( p6 ~* j4 A# j$ z      xPos = xPos;) I7 u1 b1 a5 _. n, W" m; X, G. A7 ]
      }* h4 S# f* K  w  j) W8 p6 e) n/ T
   if (yDir == "down") {
# m4 U/ D1 f( l- Y% D      yPos = yPos + BallSpeed;4 v! g. d9 p% {. v
      }  K0 s  X; R' |1 s1 a- N- s
   else if (yDir == "up") {
# U( q8 x( `( @7 r( s3 U      yPos = yPos - BallSpeed;1 x0 G* `8 \" Q+ P
      }# Y: }, }5 W, q$ W6 g9 L4 y# U2 ?" Z
   else {
% a, P9 }  @+ q( K      yPos = yPos;, S5 B* f# \3 j# t) g
      }
0 e1 Y& X. K2 |+ K# M   }" n( X! ^! \* h- s

4 W% g0 T  Y# u6 M, g; Bfunction hidetext(){
7 y+ W0 ^8 R# Fif (document.all)
, x/ `: K2 j( r5 @supertext.style.visibility="hidden"
' Q, H8 J& s- oelse if (document.layers)$ }2 U: g' R  c2 Z5 D
document.supertext.visibility="hide"( `" z+ t: `, ]
clearTimeout(animatetext)0 k( z/ n# `4 ]- Y* {/ o) a
}
" {. f2 c% J: |0 P
) m7 B  U5 \: B* N* L' U# hif (document.all||document.layers){
* {# i9 C. }5 I- m3 l" Mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ m0 z$ t0 S3 ], W6 X( C+ j
window.onload = initializeBall;4 x  h' R$ }6 U6 K8 v, \
window.onresize = new Function("window.location.reload()");
8 G' h2 u6 W% g: O9 U) e& p7 ]}  P/ E& g, J- \/ e  X. r$ @) a' H8 p
( r+ Q% _% z5 Z+ A3 z' h
</script>

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