返回列表 发帖

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

<style type="text/css">
  g& u+ N9 \/ \# J% Z7 G#supertext {0 o9 H" T& x% u* q: }8 h
position:absolute;3 \4 I) I/ O8 U
left:0;
' R8 n. D; D( L2 V1 k2 u- Otop:0;
( a5 I" ^, S' Z7 w6 Hvisibility:hide;
% P# ^0 a9 c* R2 @$ E) Wvisibility:hidden;
% m, z3 Z3 k& k}
% R$ e8 D. R5 `; q1 E0 @  x</style>
; V) T5 P7 W& _( E) n' Y. _( [1 S<script language="JavaScript1.2">
) U: ]* ?8 V3 t* w+ e<!-- 改变下的字体的大小。颜色-->4 G# k4 X$ ?! B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* |* ~; G& _) v, Z, W: L" F3 t* k% fvar hidetimer='';- Q9 f$ J% P" G% H
<!-- 改变下的弹跳速度-->
: G! |: O$ o! r. Q3 s' Evar BallSpeed = 20;
( X, q+ c6 P& J/ y- Evar contentWidth;; n8 T2 A, Y- X$ x* I  ~+ g/ z
var contentHeight;8 `: }4 f7 f3 F) @" Q4 z
var maxBallSpeed = 50;
1 Q: L% T; d6 {" W/ @8 ?! S, Y/ L
, Z: Y6 I# G9 I
6 q7 F9 T+ q" v' cvar xMax;
, w6 U& X% R  ~1 o; ovar yMax;
6 s& C% g) b7 X2 x$ uvar xPos = 0;
1 R. C4 U1 q; Ivar yPos = 0;: y9 T2 A9 j: l; L; U3 M& t# p
var xDir = 'right';- Q/ _- Y& a& Z
var yDir = 'down';7 [! `9 g5 @1 l0 O' i
var superballRunning = true;& ~$ d8 R  u( f/ U* f: U
var tempBallSpeed;
$ v8 R. R3 x0 ~8 k/ mvar currentBallSrc;$ ~) h# h3 }, e  W
var newXDir;
3 n7 C: R' j9 w, ~/ F6 g/ lvar newYDir;6 j' x5 n+ d; e# x* p# C

- {) j; g  R9 C) z" Efunction initializeBall() {
- h, k5 G0 I3 G% m+ A   if (document.all) {
1 c) F, z) d- w4 ?- \      xMax = document.body.clientWidth* m# U5 y* s0 i. [9 }
      yMax = document.body.clientHeight
1 T5 [; D+ X( v' `0 w# ?      document.all("supertext").style.visibility = "visible";/ `  M! E  W" L+ `, {
      contentWidth=supertext.offsetWidth
' _2 `5 Z8 W& l0 u* B      contentHeight=supertext.offsetHeight, Q3 I. _2 W) d. ]/ ^+ o1 @
      }
$ c' d, }5 s  d- M( x   else if (document.layers) {
5 U* B6 T  B/ [      xMax = window.innerWidth;6 y  g& `  m7 c8 b# h
      yMax = window.innerHeight;
) |4 D1 ]9 H4 Y$ n8 s      contentWidth=document.supertext.document.width9 {5 n& K+ ?* c
      contentHeight=document.supertext.document.height  K) }  Q. w1 K, x4 S$ G% Y
      document.layers["supertext"].visibility = "show";/ I- g3 p8 v0 {. l4 k8 S
      }
3 j( O% y+ W' x: p8 Q) H4 v! n( f   setTimeout('moveBall()',400);
( O# L2 s1 z5 `$ t2 C( L   if (hidetimer!='')
  ~! t% O8 h8 Z- @7 d& I$ ^   setTimeout("hidetext()",hidetimer)8 c/ i& a- W7 U& A% c* B
   }
7 X3 p% |+ Y+ u" {3 c* w; H' N
7 n* X7 V- y/ xfunction moveBall() {! Z! a4 Z$ ?5 }& v: d: K
   if (superballRunning == true) {: C9 K  J3 n, k- {. ~! \. v
      calculatePosition();
$ D" t* D. @) R* O& E. p      if (document.all) {
% G$ T, E. U# r: y1 k8 `6 V2 {         document.all("supertext").style.left = xPos + document.body.scrollLeft;7 Y" |( g5 r" ^- a5 z/ ]
         document.all("supertext").style.top = yPos + document.body.scrollTop;
' c0 j5 u, E8 O6 J0 w         }8 A* _$ z; e4 E5 M) t$ t- X3 z
      else if (document.layers) {
8 e; G9 @$ a" w5 }( I7 K         document.layers["supertext"].left = xPos + pageXOffset;+ E% L9 A2 h9 y5 R8 u8 v
         document.layers["supertext"].top = yPos + pageYOffset;
$ v$ L0 V7 ]1 u2 V0 O5 x         }
4 z! `0 ]4 r6 k, h/ M      animatetext=setTimeout('moveBall()',20);! B/ p$ g/ M4 O. B% D7 a  u
      }
6 Q0 m2 l6 I) D   }2 [0 b# \& Y7 {$ X0 U, e

6 A8 {3 s+ u# J  Gfunction calculatePosition() {& [! S  l% S3 s+ N$ O$ e# \5 O9 l
   if (xDir == "right") {! v: g1 q* i+ J7 m2 }: |7 E! p$ n
      if (xPos > (xMax - contentWidth - BallSpeed)) {- W* m# M/ Y' Q" L
         xDir = "left";
* _0 q: a  x. B; I/ L. b; k         }
0 r0 a3 v: Q& i& [      }+ R* v4 n/ V8 ?8 J$ }" ~
   else if (xDir == "left") {; e0 L# [/ v. ?' l
      if (xPos < (0 + BallSpeed)) {( `% H6 _+ ^( D, m+ z. P
         xDir = "right";2 O( J; y) B* X8 H' h$ w
         }
. [5 v- u9 Y% ^- p      }
# X7 Q* f( ^) h( M! @   if (yDir == "down") {& X2 r+ n1 x1 z
      if (yPos > (yMax - contentHeight - BallSpeed)) {
5 r9 m3 k6 U+ p+ m  a+ ^         yDir = "up";
3 O8 s# \5 K1 K: U" a         }1 B) t- N5 b1 D
      }! Q1 H7 l" D% j3 u; u
   else if (yDir == "up") {
1 f4 I6 Y) Y+ w2 r: I' U; T* A      if (yPos < (0 + BallSpeed)) {( Q6 s+ v8 ^% h. c; |/ G; S
         yDir = "down";
4 X4 x# U* R! L+ z! x         }8 Y, O  g1 Y8 K: C6 c
      }5 D0 b, N- J, U% e6 a, L! F
   if (xDir == "right") {8 t, _9 w7 O& @/ j
      xPos = xPos + BallSpeed;4 n/ g& x- J5 i0 }
      }9 C" j! O% `4 p3 a8 @
   else if (xDir == "left") {
. w! I# `* r7 {* }+ l* z- \      xPos = xPos - BallSpeed;" ]9 H  d- t6 [( m
      }5 W' k3 l7 D3 w
   else {
3 _6 a1 J  ^0 C& y7 L# g      xPos = xPos;
1 f$ N. ?3 `- f' K- R      }9 c3 i# e: o& y
   if (yDir == "down") {
7 g# d0 u* H' b7 x      yPos = yPos + BallSpeed;2 ?* T/ A2 z) ]- A0 \
      }9 G* M, [8 r7 Y$ a) l
   else if (yDir == "up") {
) s( Y1 \& k/ l+ F, L      yPos = yPos - BallSpeed;
# c8 M, m  s% v9 o/ @5 f0 b      }) ?% X* {1 ]6 w5 L& C1 Z
   else {
+ @. K+ F" L$ f6 o2 A) @      yPos = yPos;. N# @" p% T5 @) y& G( A- I
      }2 C/ e% V7 D6 m& `6 U! U& I$ R
   }
' ]) [3 `3 C/ w, V7 |, E3 h4 H( _. A' L  g( W4 t7 ~
function hidetext(){( n4 {5 Q1 R* v+ T. H
if (document.all)
) }# O9 h' V5 Z$ C9 dsupertext.style.visibility="hidden"
. Y4 e# [" ?9 ?. n6 q. Xelse if (document.layers)/ {! d" r6 P5 n7 I& A/ I1 ~3 m/ N& L
document.supertext.visibility="hide"
$ |3 n2 q$ ]: L0 K* K6 VclearTimeout(animatetext)
4 S6 H4 D! Y9 d+ |+ x9 B# u}3 _0 f' i+ `9 q( x! f3 c4 I/ T
8 S5 s# M& s/ s5 s, s8 B1 ?! h
if (document.all||document.layers){
4 I" r9 X8 l5 K. F; idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
1 `+ O6 T8 S! P' D" K' z8 }window.onload = initializeBall;
# w+ r8 Q% O% b/ G+ `4 ^window.onresize = new Function("window.location.reload()");" d& n( K) J' m  z! m! G: n
}
; c4 U# D0 K* s) ~: `. N% w% s
4 c* `; S3 o, h; [2 u6 \/ @6 W</script>

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