返回列表 发帖

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

<style type="text/css">5 k+ U$ i5 w6 Y
#supertext {
0 c7 X" S9 O. K1 L1 gposition:absolute;
% n1 s* ~6 `+ x- N1 S( yleft:0;
: h: c, I+ |0 `# m/ e4 |0 Itop:0;( z0 F: F7 l- P9 G; j
visibility:hide;, d0 M$ Z  a2 u4 w' D
visibility:hidden;
& J  W$ K6 l/ F}
6 |/ w; v1 e2 m+ O! J</style>) j* h7 b7 G/ p: Y
<script language="JavaScript1.2">
' C# H( a. J: f: o& {, ~<!-- 改变下的字体的大小。颜色-->
& a4 R, |; m7 M9 Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% X7 Q, ?; J- h! w
var hidetimer='';; j$ D6 N# o1 c) Q, c; N
<!-- 改变下的弹跳速度-->
- Q0 a  I, d3 Q8 u) jvar BallSpeed = 20;. j2 C1 Y5 L. X  I
var contentWidth;  m1 s6 g, p5 Z8 K
var contentHeight;
& X1 A/ b3 x3 q+ r+ zvar maxBallSpeed = 50;
( E7 V6 z  P8 U2 ?/ Q2 f1 V9 y: n8 F; M4 E; F( v/ \! b2 w

: e$ R. u- y8 Q/ l2 c. a, mvar xMax;
% t! l  K- U3 p- L, Tvar yMax;4 t8 Q0 @) X2 U) d2 c6 C
var xPos = 0;
5 M7 F5 H0 V# W1 A6 X9 vvar yPos = 0;0 Y) H# e. q7 V- V7 b
var xDir = 'right';+ d( r; O0 ^# M, A
var yDir = 'down';
- I  h' H' K. m# P3 g  o  J5 H" j6 cvar superballRunning = true;) d1 V9 a- j) P7 B) `* ^
var tempBallSpeed;4 v" U4 B% a- e9 I
var currentBallSrc;) L6 E* a+ Y4 a* R1 l: i; @
var newXDir;! I* J3 a" r9 Q- q7 s
var newYDir;
, ^: h: _1 |% D
2 S9 E2 ?2 F3 w( _function initializeBall() {9 j( o! O: h2 p
   if (document.all) {
0 ~# A; I2 f, |- A# t/ Q      xMax = document.body.clientWidth  k2 h$ l/ e( _5 v0 d* o4 R/ F
      yMax = document.body.clientHeight( [1 N, K( T8 E3 w* Y8 N
      document.all("supertext").style.visibility = "visible";0 ]* |7 s' o" w1 _
      contentWidth=supertext.offsetWidth8 B* U( f# k8 K
      contentHeight=supertext.offsetHeight+ V7 z- a. f  q* n! _4 S: D
      }. y4 U0 k  m: A$ w3 @/ R& m7 d
   else if (document.layers) {& e7 L1 m8 O' ?" A
      xMax = window.innerWidth;
- q9 p: K  @) e8 q# w      yMax = window.innerHeight;
. |, m4 [6 m2 ?% |. m: H! o      contentWidth=document.supertext.document.width
6 I& P9 i& v2 J! Y$ Q8 _3 L5 y      contentHeight=document.supertext.document.height2 R8 v/ L1 P8 s' _* T" ^( h
      document.layers["supertext"].visibility = "show";
6 ^5 v& g# h7 t; e- r" _$ {      }& L8 |1 X$ `2 T2 {' W6 f
   setTimeout('moveBall()',400);
1 B: B$ w! u6 u- J( x   if (hidetimer!='')
+ \: N! I8 C/ F' j2 p6 }( b; J$ H   setTimeout("hidetext()",hidetimer)
2 J* y0 S6 t) V   }
+ c# e7 o8 a  ~9 k
' {* B; N% ~7 Zfunction moveBall() {
8 i; i8 y  F$ d3 W0 e   if (superballRunning == true) {/ d8 ~7 }; ]5 Y6 d( N3 r9 `0 K
      calculatePosition();7 t& t9 d0 M) Q* ~4 W+ K1 [
      if (document.all) {- N; M( z. g2 y% {# d9 q4 q4 O
         document.all("supertext").style.left = xPos + document.body.scrollLeft;' M8 P( B8 @5 X0 x3 V. Y
         document.all("supertext").style.top = yPos + document.body.scrollTop;
  G- _: d. K$ l5 i( @' W         }
4 I7 H7 l& x3 E9 @$ n% d/ t      else if (document.layers) {
- k- L# s  Y) J. q9 p         document.layers["supertext"].left = xPos + pageXOffset;0 P- d' T( x2 B5 y9 A
         document.layers["supertext"].top = yPos + pageYOffset;! X% N; L5 E9 B- F& b0 n& l
         }$ y* y% b( U! t" z6 [" a0 M* A; M
      animatetext=setTimeout('moveBall()',20);
, ?; D; s3 L  T. _  m      }
8 \3 o- v, U* M4 M   }
; o2 c9 g! m) P9 Q0 @4 m. Q
& Z2 E0 K# p# @* ^% H% H  Kfunction calculatePosition() {
# n* u4 T" U/ b, n: w) J- z+ s   if (xDir == "right") {
7 u% p1 [# Y1 Y" W      if (xPos > (xMax - contentWidth - BallSpeed)) {
3 n  k( i* U5 C+ w9 y9 {         xDir = "left";# Y. T: U9 P5 X9 k2 G
         }
1 G9 }& Q6 b0 C6 r# y      }8 X; N$ f- Z$ r" f& I  k& P
   else if (xDir == "left") {
$ |! ]( \9 b2 [$ c+ w4 z* ?" J- Y      if (xPos < (0 + BallSpeed)) {* H& H' f) j! `7 X9 p. _
         xDir = "right";) L! y0 R2 C/ ]. t/ r  @
         }
! `/ ~; Z7 a% |! q; \      }
0 u- Y7 S" u9 r* ~: i   if (yDir == "down") {! v' _( N4 i8 ^8 A( N2 Y! D" `( v3 B
      if (yPos > (yMax - contentHeight - BallSpeed)) {9 }) [2 _  J) E" _4 z# b, x
         yDir = "up";
1 m, `2 \; H' }3 x8 J4 T6 o         }! E- d6 D3 \2 I, |$ C  O9 g
      }
# Y' ]+ x) t+ V8 b' h% E8 b   else if (yDir == "up") {
$ [. S( L: I, K0 y      if (yPos < (0 + BallSpeed)) {
7 ]- N' K! C9 J1 t         yDir = "down";
8 r6 s' o$ b; t. C         }* ^8 _$ p$ k2 S$ s0 R
      }) m' p, `( M$ L4 s) }; @; X5 l  t3 z
   if (xDir == "right") {* N: ?! |% A% Z! |
      xPos = xPos + BallSpeed;
& L4 _  o/ C4 i; N( B5 Q      }* h% {0 ?3 f3 H9 H0 ?
   else if (xDir == "left") {6 l" ~, `2 \/ u7 N
      xPos = xPos - BallSpeed;* _" d' m4 A) h9 _% K0 A) Y2 H
      }. V( B- \# i* i6 ?, z8 u2 s# @, h) q
   else {
) s1 G# k- F# L# w& y      xPos = xPos;8 M; @. d' e2 Y: N0 W5 f2 Q) {
      }, `; Q8 M5 Y( `* e$ a8 u# n' Q
   if (yDir == "down") {
3 ^3 Q# v3 D/ ?0 m% K& F9 d5 O      yPos = yPos + BallSpeed;  s: R$ i; \) j2 W
      }
8 g7 e! r! x" h   else if (yDir == "up") {
. c2 p9 ], B9 q. b' b4 M# O      yPos = yPos - BallSpeed;% p1 d  n, Q- Z7 x3 R
      }
. x$ ?. H8 y0 a& x7 y* A7 U$ c   else {; ^7 [# ]# M% |8 P
      yPos = yPos;
/ y) G: z# g' P6 F9 S      }
$ S" @3 {6 ^% i. s- N1 ~& u" P   }
0 `3 v3 {8 ^0 v) G9 Q
2 @4 {8 n# x7 }, r5 Ufunction hidetext(){) ~# c3 K1 l( V& Y4 Z. g! l4 t
if (document.all)# T2 [7 M+ x( [) x
supertext.style.visibility="hidden"( [! R- {# h( `; a7 j2 H4 {+ G: l! V
else if (document.layers)# y0 Z2 ?# x2 E
document.supertext.visibility="hide"
, }6 x" ~, G, b1 PclearTimeout(animatetext)
" [6 ^- g! F. i9 R}
4 ]/ L# K: ^6 ?, V) A9 l) M' |+ U; B* ^' m% g( D! M# Y) m
if (document.all||document.layers){
! r! `& M3 Q7 a) o5 vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); w" c4 q' C7 A4 x! C1 }; ?
window.onload = initializeBall;' R9 g' E% m9 m) A2 N4 d" s+ u
window.onresize = new Function("window.location.reload()");% r, B% R" i$ ~+ }* r
}
1 T- l, s0 \7 Z1 T" W3 U; ~- t  _7 M" O* z
</script>

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