返回列表 发帖

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

<style type="text/css">
" g, t. Q/ I2 S* W2 j' S2 X#supertext {4 p  [& s* A3 b6 R
position:absolute;2 F, G% {- Y. O" `: l
left:0;) h& H% T" H% h$ Q- e0 k
top:0;7 I& D: H% y! T
visibility:hide;
! J+ b6 w+ X% n% `' t. o0 [  evisibility:hidden;
/ T1 J# @3 d1 E4 o$ F5 ~- C* R, Q}
, `# o, S+ R% S6 e. C: r! L( O</style>1 N1 r( z8 G& v7 _
<script language="JavaScript1.2">8 @) r4 P( ]; x7 \7 I
<!-- 改变下的字体的大小。颜色-->
0 N- b. ~5 H2 }& s% e) dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 \" e% N7 Y" Q5 g, t+ B* @
var hidetimer='';
" z. k9 H7 M5 q0 o; L, X<!-- 改变下的弹跳速度-->
" @6 H( @+ f) E6 \/ y9 Ovar BallSpeed = 20;
7 f& y- c; |& D2 fvar contentWidth;2 _+ W7 w7 `& o# D
var contentHeight;; \" O7 R5 }' s7 Z
var maxBallSpeed = 50;7 a+ d/ O7 C2 j. E
9 B- \) d! Y+ u$ \% F0 n' c- `

, K! T# O, ~' J! `1 F$ f% |var xMax;
% k/ d, m$ y1 w* M  b' r4 H; X/ `8 A* uvar yMax;
: E" W1 o" U1 Gvar xPos = 0;
+ \; h5 N- R8 e2 a+ pvar yPos = 0;
2 ]' n6 y1 ~* C' `6 j9 g2 X: _- Uvar xDir = 'right';6 N  ?& g5 [  R3 [$ K% u" ^
var yDir = 'down';
( b3 N& Z+ S+ i. e) Avar superballRunning = true;& E! e) ^5 K9 v# I
var tempBallSpeed;5 h' y; O; ]" Q$ p2 H
var currentBallSrc;/ L9 x3 G9 |4 H# W  o
var newXDir;
" {' o5 I% O$ A, Q3 Yvar newYDir;
  a* H# n+ D% [& T8 n9 Y
9 u+ ~: v! V( ]: ofunction initializeBall() {) w3 `) V2 I. ]2 A1 c  ?7 s6 e' V
   if (document.all) {
; k% k3 R* o: y! P: W% _      xMax = document.body.clientWidth
& x# ]  P7 p- C  Y      yMax = document.body.clientHeight
8 w3 A# N" K# K      document.all("supertext").style.visibility = "visible";
4 [  G+ C; h6 @2 s! D" p7 h      contentWidth=supertext.offsetWidth4 x( O, o5 z/ Z) p$ F0 a
      contentHeight=supertext.offsetHeight
+ w. M' T, r. {      }
! q6 g, e3 J' W/ _! o0 f   else if (document.layers) {) ~6 `$ {% _: X2 p) ?1 [! Y  \
      xMax = window.innerWidth;
6 m6 Q0 l, L6 s1 a) x      yMax = window.innerHeight;1 m, G. T3 d+ s4 F  g6 i
      contentWidth=document.supertext.document.width4 r# c3 s' [% @% J# l
      contentHeight=document.supertext.document.height
( H6 k% y$ ~( B  e, Y/ @      document.layers["supertext"].visibility = "show";
5 g; l( f1 h2 q+ J; \      }
* v8 n. V# g2 n8 ]( }, C0 G" J5 O   setTimeout('moveBall()',400);
. {- ]7 [8 ]" k# m+ q+ y: e   if (hidetimer!='')
. |/ s0 `" _- k   setTimeout("hidetext()",hidetimer)2 P8 e! h( w* T
   }
( [/ V4 m0 G; v9 }$ D! l  B5 q9 \- R0 J+ N
function moveBall() {
% C* h  U$ W) B7 z! a, u   if (superballRunning == true) {. F* ]" r  |, r; N
      calculatePosition();
! s4 N) o  D* K8 t      if (document.all) {  X% X' s/ b' |# j' s* _
         document.all("supertext").style.left = xPos + document.body.scrollLeft;! n4 c& o) S/ g0 b# I) Q
         document.all("supertext").style.top = yPos + document.body.scrollTop;
+ l6 e2 m6 O' H7 w         }4 Q7 @$ Y% S1 M6 e
      else if (document.layers) {) y0 J, n: ~& ^" h
         document.layers["supertext"].left = xPos + pageXOffset;  Q& v# u4 n5 V% B
         document.layers["supertext"].top = yPos + pageYOffset;: w4 \  v8 P" d' [1 X3 q0 ~8 w
         }$ p& z$ e7 _0 n: X5 O7 ?0 ?+ t
      animatetext=setTimeout('moveBall()',20);
, }3 |( \: B& e1 a+ G6 m      }3 x9 J/ i5 ?9 P3 L: {- [
   }
4 |  g. }* U& X# Q. r' y: z; c3 K5 T% e9 r% g! B# d8 x% L& N
function calculatePosition() {* d! f& c/ K3 w
   if (xDir == "right") {) v$ K' F9 \: E1 u. {
      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ Q& Q$ D5 \3 M9 ?9 |2 o- g         xDir = "left";) S# f% ]1 e' {
         }1 t% l3 [, V7 X2 o
      }' j% e7 Z; E' O; M- h
   else if (xDir == "left") {
. @! D- D3 B. n  _, n7 W      if (xPos < (0 + BallSpeed)) {! D) n7 i- q+ C% ?$ Z' W
         xDir = "right";  @4 A6 R* b! Y  w. P/ Z
         }' j6 i; `; s5 A" H1 `
      }
% S- @( l- R$ M" E2 b9 I8 E   if (yDir == "down") {
' d! s1 p' C" T: Q& Y      if (yPos > (yMax - contentHeight - BallSpeed)) {4 m7 _5 z7 @. d# p5 B. [
         yDir = "up";
, w$ }( y1 N4 q! Z: `         }/ ]( J# W' q* D
      }. C! R( h- A! z/ E
   else if (yDir == "up") {! |8 T+ g; v/ N! o
      if (yPos < (0 + BallSpeed)) {+ R' f. Y& b% {9 ?- y
         yDir = "down";) e0 U1 G* S# O1 S0 i- i
         }1 L# g5 M/ b0 V! Z* Q
      }
. H  O6 d3 q+ u   if (xDir == "right") {$ c3 M" ~, v- D& ]8 G% E) }+ |8 \
      xPos = xPos + BallSpeed;
$ O$ P8 p' I7 f0 u' [0 u( K1 W0 b% k      }5 x/ Q2 {5 M' j- [
   else if (xDir == "left") {
3 W6 n/ m* a1 `- m8 H' f% Q* _2 @      xPos = xPos - BallSpeed;6 Y% i' P- V+ U6 E" n
      }
4 }! P7 N$ Y* i2 W   else {" ]. A- k# s4 ~8 i8 ?0 a% @
      xPos = xPos;
, N- ?* I2 U! g  H$ n2 @- W! a      }
" ]: d: o( t1 O8 V/ J9 U   if (yDir == "down") {
' f3 ]8 z4 E2 j9 t9 w      yPos = yPos + BallSpeed;
- U  m& }2 P& k& A# a      }( u( [+ E' K5 k( \4 F
   else if (yDir == "up") {0 z0 c) B) e; E( a/ M
      yPos = yPos - BallSpeed;# L5 e  B/ y9 Y$ E: @
      }; M5 r+ w9 s5 g$ D
   else {
  ]+ ^1 |0 }8 |5 L" ?  c      yPos = yPos;
% B) w5 e4 A! a- Q5 Z" ~      }
: h. w. |$ e: K# ]% i9 ^. a   }3 R! p3 C' t; ~, B( P4 I

, S4 w- u. Y6 k5 a# |! jfunction hidetext(){
/ M# e, L: A( Z: @% D* Y1 S# Yif (document.all)( H" C  M+ ^1 r+ M! O4 e3 d  m
supertext.style.visibility="hidden"* B, x6 m9 b8 s- s/ g
else if (document.layers)% E1 i! H  C, r1 S& p+ }. ?% R
document.supertext.visibility="hide"% {7 k9 M& e+ W. B& o
clearTimeout(animatetext)
- `' F/ b2 m2 L) r. D) w}# V4 C" Q4 s2 Y
# J5 ]' l% _) B
if (document.all||document.layers){
2 ?  m! k" r' mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 ]) W; b3 K! ]window.onload = initializeBall;
9 m# Y- ^, K. ~9 f3 uwindow.onresize = new Function("window.location.reload()");0 u# j5 o4 ^& |8 h, x# x* H2 V
}! x: D, _4 X: Y* r6 b+ T5 {( a

( V+ Y7 F9 K/ |& O: j" n) O</script>

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