返回列表 发帖

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

<style type="text/css">5 L8 F$ n2 `, Y4 x, {8 h" j* C
#supertext {
; t* D: x: n2 o) j+ Tposition:absolute;$ p, v2 s( ~% O$ r- q0 m
left:0;
! Q6 h5 j: o& d5 G' mtop:0;) e% r9 e* f( o/ H8 s* k
visibility:hide;! I- w- [* v1 {- r6 ?
visibility:hidden;, B6 f3 E, o* {3 U' |# N  X
}  N3 L- [* _+ j# S7 O4 i
</style>
8 _7 x9 z1 _: v7 {<script language="JavaScript1.2">
4 u8 |! l3 l2 h<!-- 改变下的字体的大小。颜色-->
6 j( q8 r+ ^& G2 S6 E( h6 n; Avar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# J2 n. I: _8 M8 Q; S9 f
var hidetimer='';
% z- u, I6 S' q9 f  n<!-- 改变下的弹跳速度-->
& W0 H$ e) T. S6 r) V; o! P4 S; avar BallSpeed = 20;4 E$ {9 G+ a% \5 S; {- b5 b
var contentWidth;
* k' H1 }$ H( }var contentHeight;
2 I4 j- |* y3 h+ Q' n" C- _var maxBallSpeed = 50;' [, l/ l& E9 C2 n+ j

* Q0 G7 X5 \$ f( S* X7 g' P/ ?( H3 s1 R& P! r6 I  y
var xMax;, H$ b; t. p$ N; c- V+ B# w
var yMax;/ L3 u. S- I3 W9 ^4 l
var xPos = 0;
- s+ [# g$ P1 {var yPos = 0;' r( k5 _! g$ ]4 z3 o
var xDir = 'right';
+ v+ B) X8 H! `7 z+ Y6 D) F# _var yDir = 'down';2 s+ I! ^# |& `' V" }" A
var superballRunning = true;
  R4 s7 z4 ]5 f+ h& f9 Ivar tempBallSpeed;3 T- H+ U) G: o
var currentBallSrc;
1 t" T1 K. r' J/ q+ x$ \3 C- r6 cvar newXDir;
( J1 T$ z) ^5 _3 }var newYDir;* C5 a' h5 Q3 \3 U) K) q: ~

: K8 g  p* f* T* I- A3 Sfunction initializeBall() {
% b! i! S& y) T. |   if (document.all) {
0 Y- a. Q5 x- i; ~7 K) C2 z- I2 C+ W      xMax = document.body.clientWidth3 i9 O5 h. D+ M8 D* {" ~, A
      yMax = document.body.clientHeight
! I, a3 J' M: |      document.all("supertext").style.visibility = "visible";
  |: w/ F, V5 e7 D      contentWidth=supertext.offsetWidth1 M/ o! {4 ]# ]4 _& M+ @9 p
      contentHeight=supertext.offsetHeight$ n' J' B  i) E* H1 j
      }
) \$ l* _1 A( }0 t   else if (document.layers) {+ s6 {8 f5 S) J! X$ P
      xMax = window.innerWidth;
" W* G- y/ S9 B      yMax = window.innerHeight;% |$ i, E! u9 w' g4 J
      contentWidth=document.supertext.document.width' j8 S8 _+ w$ `) g$ ~3 U
      contentHeight=document.supertext.document.height% t1 L" ?! u* W
      document.layers["supertext"].visibility = "show";
6 `# u& J* q( E# ]      }6 o" @/ |: I$ P9 T4 ~+ T" M
   setTimeout('moveBall()',400);0 W8 `! R8 Q$ J$ u$ G3 T
   if (hidetimer!='')
& X3 a" B1 C& t( h+ n   setTimeout("hidetext()",hidetimer)0 k% ]7 l$ v# H' _# p
   }
1 O* |/ F  \# O
$ n7 `# X3 ~  d+ r1 efunction moveBall() {* B+ ?# ^' Z' U/ @+ g
   if (superballRunning == true) {: ^& Q. Y- ~6 B' F) {2 O0 x9 Z
      calculatePosition();
. A/ F  m6 j0 `8 w( N      if (document.all) {
4 v$ z0 G$ p  A" v1 n/ R! n         document.all("supertext").style.left = xPos + document.body.scrollLeft;+ `. E. a2 ^7 |8 ?
         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 w$ F1 @  b7 [- b% |$ G         }
9 a- ^- d6 J$ `  o+ L      else if (document.layers) {9 a, G, D: F9 Y) k+ @6 O5 v7 w1 ]: }
         document.layers["supertext"].left = xPos + pageXOffset;
) ]$ Z, d9 J. d1 r         document.layers["supertext"].top = yPos + pageYOffset;5 D+ Q- Z& m5 w" \5 {: L
         }
: C: V& }3 k$ |: N      animatetext=setTimeout('moveBall()',20);
; ~4 W) f0 T2 v+ Y+ S  X$ X      }' J5 I! G5 _5 Y- Y3 r; h+ v
   }: n/ j) U2 `/ t3 O0 @, A

6 N) h8 W$ Z/ _) o- q0 e$ K  jfunction calculatePosition() {
( n" n/ q' B' g8 p   if (xDir == "right") {/ g% F- z- Q. n+ b0 b# E2 i% t
      if (xPos > (xMax - contentWidth - BallSpeed)) {) x! Q/ I( K- y  S1 u1 z
         xDir = "left";0 _2 D' I* _4 _$ P
         }
% D4 t9 n6 ?8 u- ]      }  E) A# n0 k5 v0 T! W
   else if (xDir == "left") {
( ]; v( ^- l9 s/ O      if (xPos < (0 + BallSpeed)) {* N' l& F2 O3 r/ @$ x3 y. ^4 v1 a
         xDir = "right";
  \$ N: B: Z" _         }
7 L- w6 b" |  W; w' v      }
9 U7 b9 S8 O2 [; }   if (yDir == "down") {
; _1 E$ e; d( B* d0 \      if (yPos > (yMax - contentHeight - BallSpeed)) {7 X! ?0 Q/ q% D8 e) Z- q$ Y
         yDir = "up";
, @& m; w8 @5 U  R6 Y! J$ q2 ^. z  J. _         }
  y9 R9 X* v; N& `: n      }- ]7 e2 }) H/ Y! S
   else if (yDir == "up") {8 ?9 s6 c: F9 A$ A1 o# @
      if (yPos < (0 + BallSpeed)) {( |' h( W$ w5 a8 }/ ]
         yDir = "down";6 T0 a' u# }$ ?, @' M9 [- c8 ]
         }. \! v) K8 P( \4 \. E7 b
      }  ^% y# k' ]1 w
   if (xDir == "right") {7 I, M1 D6 x: z: f9 V. R
      xPos = xPos + BallSpeed;  y$ v6 ^# ^. d- e
      }. q+ ?! K0 X# _$ B  e% N1 k: c
   else if (xDir == "left") {
/ T& U9 g- M* O- I      xPos = xPos - BallSpeed;
: F9 h+ Q, M7 C/ I% P: {      }7 ?# J1 y2 @' y1 o
   else {
  T" m5 Q8 s* t9 u9 x! I      xPos = xPos;
( F( a7 s4 a0 A" J2 v1 [      }
4 }4 o5 t! d) H9 k2 H7 f( d   if (yDir == "down") {
+ i' d! S; T6 m8 D: u1 A      yPos = yPos + BallSpeed;/ |; j; i- _2 o5 n) A  |
      }
  a, I/ ]" \% V   else if (yDir == "up") {
7 R7 \" L+ k& e% F& p      yPos = yPos - BallSpeed;! D  E$ q/ E9 k1 Q6 m) `
      }. W. C# E" j6 g
   else {! _: ]* O; s  V1 Z( |* U
      yPos = yPos;
- i4 @  z) ?! V$ Y2 D/ y      }* a! S; M' d- K' g5 `9 W
   }
0 ]3 ?% K, B' a; _* D
, l4 @4 H% S' u- p4 ?function hidetext(){
0 B2 j, M6 `" G1 k: hif (document.all)- x; X/ |" T6 q/ j7 f
supertext.style.visibility="hidden"
: V$ |% u8 a) R+ W1 Eelse if (document.layers)
% l' g1 B) S6 S3 X* \document.supertext.visibility="hide"
9 v/ ?- P' M4 E  _) A" oclearTimeout(animatetext)
: o6 y7 X; f4 I* g0 f}
3 X& ~. l1 v- F6 u; b4 ^; P6 \# F% b( Y. ]6 P2 }  s
if (document.all||document.layers){
# b2 i7 j/ C- F" k9 pdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 J7 o2 o! Z; t, P' f/ v( g
window.onload = initializeBall;
: q, s/ G0 h) Z1 f$ {8 xwindow.onresize = new Function("window.location.reload()");
& V/ ?& D5 Y( ?. b: M8 T, p}# H  Y6 ]/ b3 I
9 I- l! D* B8 u# G
</script>

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