返回列表 发帖

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

<style type="text/css">( R" Z8 s9 L# a( A/ Z
#supertext {
3 L5 B9 ?- @( E: [0 ?position:absolute;
6 ~1 i* B" w9 cleft:0;0 U/ Y$ \+ Y. P: ?1 K3 {6 m. K
top:0;) v" b$ X4 p# P5 C' {, e7 X+ M
visibility:hide;$ y, ^0 T& o. M7 ], a4 @* z: z1 j
visibility:hidden;
4 J7 V# ~1 Q2 a3 M1 Z7 a: k8 f}
9 o) q0 p5 \7 X$ ]& D</style>
6 m2 i; g" D1 U6 k" n<script language="JavaScript1.2">
# V+ H2 A; r" [, {1 s( c<!-- 改变下的字体的大小。颜色-->
, b( ], W! I/ L* U8 Svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" ?/ p1 W! {$ _2 A( Lvar hidetimer='';$ r& S) e  b4 Z9 t% I* F# r
<!-- 改变下的弹跳速度-->9 t  C. f+ A, C/ o; b/ q# O
var BallSpeed = 20;/ r7 g# w  H# N  M' J
var contentWidth;
9 X. ^5 p+ v4 o$ o3 W- ^var contentHeight;
: S, c& [. \. [" Rvar maxBallSpeed = 50;
& B  |3 c2 m& j" a5 p
2 i3 R# V3 {1 z4 T. _3 X% O
) H5 W  G0 c6 ovar xMax;
! S' B, [( u% B1 ^' q6 dvar yMax;" M, L' C- _( r1 e
var xPos = 0;
& r0 V4 E. W! D, C# Cvar yPos = 0;
; |. x$ Z/ k1 C7 Pvar xDir = 'right';; E! I8 A1 X+ P  g' @
var yDir = 'down';- h$ d0 b* B1 {4 j
var superballRunning = true;; n) b# a# C% q. S: M* m6 f$ Z
var tempBallSpeed;
2 e5 J. z) ^! Z2 d6 `; ^var currentBallSrc;
0 ]# g2 t2 k) N& s5 f: vvar newXDir;
  V, Y2 ^3 w3 O8 C" A  ^8 vvar newYDir;$ A; Z+ S! r2 O( K. h: R* u
% i, H! g/ _: C8 V4 D* O0 \
function initializeBall() {+ |$ P+ V/ u- }5 f* R$ b2 j3 E3 U# G
   if (document.all) {
( Z* I8 B% l+ ?6 o; X      xMax = document.body.clientWidth
4 X* G! ?' t1 }  [9 |' i/ h8 R      yMax = document.body.clientHeight: f# C2 I, \+ K' N# w1 G( O" {
      document.all("supertext").style.visibility = "visible";$ J. @1 q7 ~6 A9 V3 G. H, R4 G
      contentWidth=supertext.offsetWidth
( C% t! N" ^: A. c7 {" p% _4 _% p      contentHeight=supertext.offsetHeight3 Q* \$ ]# S8 w7 H: J0 Z2 a3 l5 t
      }
( }/ E0 r$ O6 y1 H! [& b; ], X  W   else if (document.layers) {
, P! |. |9 L6 H) Z: E5 i$ k) z      xMax = window.innerWidth;
/ D; I) Z: }7 J5 x- I+ U/ z$ J7 f      yMax = window.innerHeight;
6 s& @. ?, h6 b2 n0 [% {      contentWidth=document.supertext.document.width
3 I' Y. |$ i: K& L6 F, M      contentHeight=document.supertext.document.height) G2 n) }' L2 f
      document.layers["supertext"].visibility = "show";
$ K; H' v! D7 B+ L$ e7 E3 c6 s      }$ s* Z& f$ o# A+ c  U7 J3 o
   setTimeout('moveBall()',400);8 `6 F3 a7 {  L8 C  Q1 l
   if (hidetimer!='')+ b& C3 a) |3 K( H& t+ d* z' l
   setTimeout("hidetext()",hidetimer)- I# l6 d- i+ @+ l5 b6 L3 V" {3 Z% g
   }: o, x8 d2 |9 _8 H* Q! X
! E2 D3 B" L0 ]
function moveBall() {/ y1 i6 T  u# j6 i* d# j4 T  L
   if (superballRunning == true) {5 y. n+ _) l  }' p9 ?
      calculatePosition();1 _# |4 t3 Q7 v  [' h4 J
      if (document.all) {
1 [5 _7 o- c: r' J" B  ]         document.all("supertext").style.left = xPos + document.body.scrollLeft;, z9 k5 e# a; }% a' ^; z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 Z- h5 F! q% z9 S3 t1 n         }) Z7 k" J. {  Q; [& E4 o3 [
      else if (document.layers) {
, t% s8 d) q: f# C" |* e( [0 {         document.layers["supertext"].left = xPos + pageXOffset;
! d8 H7 f, @" I% D6 f         document.layers["supertext"].top = yPos + pageYOffset;
2 {7 ~1 y+ [, F1 U# Q9 e         }
# d& C4 h* w4 A  X; v3 \      animatetext=setTimeout('moveBall()',20);
- G5 b. n) _2 H2 Q      }
- _" U* V+ Y6 Q) c. T- l6 w   }, O+ j' w% q! w+ l9 n$ P+ h3 l

! l1 A( j7 U* q* C' Sfunction calculatePosition() {
/ [0 @1 |9 Y+ k/ _' |   if (xDir == "right") {
) y+ I; S: Y7 b" @# r1 o6 G      if (xPos > (xMax - contentWidth - BallSpeed)) {
- ^2 [( p. B) B( T4 w         xDir = "left";% A- ^& J. A: n" Z! x: p
         }' ]# a1 A1 p5 b1 b
      }; g$ h5 n+ z$ l! V4 ]
   else if (xDir == "left") {' A0 d1 {: B/ Z$ i: S
      if (xPos < (0 + BallSpeed)) {
3 c: E- T  c; {. A& j2 C$ O1 g+ }$ U         xDir = "right";
7 T& q4 H6 r" g+ Q4 s         }
$ `' y. S. @0 F8 ?5 Z6 \* {8 C+ U      }- O3 x" v" A; q! ^6 G
   if (yDir == "down") {
5 s1 W* X" L. x8 n! x      if (yPos > (yMax - contentHeight - BallSpeed)) {
! g6 y, _. s7 t! s2 h; ^9 M; j         yDir = "up";
! K% ]$ Q* {3 U9 z4 {6 @( i7 Z5 ~         }% m0 G/ I; \6 n" i. e* x- u! ~; I
      }: R+ i+ P5 M" o. B; w& Y5 M9 p
   else if (yDir == "up") {/ O5 p( l: j6 l0 z+ C+ f
      if (yPos < (0 + BallSpeed)) {, A6 B' U+ ?1 Y; S7 d0 T8 o
         yDir = "down";
" l. n7 B0 {! N' o         }, H6 G# t' R. r( C
      }
" G# C/ Y! P7 n  [5 l+ V   if (xDir == "right") {& z/ s, o7 {; T* m; o# K( }8 e5 H6 U/ ?
      xPos = xPos + BallSpeed;0 y6 t) J- V: ^, j6 F
      }9 Z1 d# |5 K7 l0 O  ^
   else if (xDir == "left") {
' R% b2 F/ E9 w$ d      xPos = xPos - BallSpeed;6 \3 e, x9 u! [8 b  J8 o
      }
( `3 Y% K/ D( Z7 V7 J   else {
+ ^" e: C5 w2 T; ^2 |      xPos = xPos;% R; m1 U5 C* g+ V4 S0 S; ?
      }
0 H! B( O  E( E7 E" Q; W   if (yDir == "down") {
3 d5 M0 ^! j0 ]* E, m% U, B      yPos = yPos + BallSpeed;
1 z  w7 s/ F2 J! V" A; \8 m      }
# H% O0 H3 C3 y" y   else if (yDir == "up") {/ G# K9 B$ C% e. q. m2 Z, R8 ~' [
      yPos = yPos - BallSpeed;7 s. k) e6 r# |4 t
      }
$ Q2 }1 v4 C! r* x5 }   else {$ x+ ]& \& O6 R8 ~) [7 b/ J9 d
      yPos = yPos;7 Z2 x' l: X( d" o; u' A4 w- R' R
      }- H+ ^6 T- [) G0 d9 W3 X. L$ T) ~5 U1 e
   }. j% F) E. r1 Q3 A# G

. L8 P) W% N+ w6 qfunction hidetext(){  I% x8 L7 U! ~* T  r  f- h$ w
if (document.all)
9 I- M9 V+ Q: l0 Ksupertext.style.visibility="hidden"
4 q2 l# q$ E6 A! U+ b$ N# jelse if (document.layers). r' t# O( O/ H9 _/ z; k0 g7 i
document.supertext.visibility="hide"
  T' V& D1 F9 Y0 P, D: v) D) K% D( fclearTimeout(animatetext)
6 T! n6 V9 h: u# o}# w9 Q" m" |6 X( l

0 y5 x! Z2 z6 p$ k* Fif (document.all||document.layers){% U, ^# f5 r( \7 n9 i
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 |4 ?6 V- ^" G( A5 S5 z' _8 hwindow.onload = initializeBall;
( s+ L1 w) {3 R8 O: i& ^4 B& qwindow.onresize = new Function("window.location.reload()");; B9 O# a9 O0 ~/ q) I1 d* \- z
}
2 i9 p# \& g- f) k/ Z6 U5 O
$ X; \9 q) ]! j9 s</script>

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