返回列表 发帖

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

<style type="text/css">
5 q3 H+ [* U, N( L2 c6 T#supertext {  j, \/ f; J$ f7 a
position:absolute;
7 D. f3 ?. l% L& aleft:0;
# x  X* F) Z9 z% {2 Htop:0;" E* ~; r' E! G4 n3 a
visibility:hide;
0 Y% A" l' R8 Z0 X; Cvisibility:hidden;
5 h' ]+ i1 h. h: |. s}
4 T- ?" _* J% ?4 ]+ _; v</style>
: e  {( f9 u" i0 D+ G3 L! ~<script language="JavaScript1.2">
9 C$ I, p3 r/ O<!-- 改变下的字体的大小。颜色-->* u8 _3 M+ l+ V& T- G7 P
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>', M$ K" B, a; t
var hidetimer='';
0 U' P' p7 `) r0 G<!-- 改变下的弹跳速度-->
, `2 K- |4 J1 F, @4 Evar BallSpeed = 20;
4 I3 X$ f" c0 Z3 v3 f) u9 h" E- Q3 vvar contentWidth;
( M" L" h3 s6 j# U( e  avar contentHeight;% }8 ?1 L: O/ b  B
var maxBallSpeed = 50;
% O& U0 {  H* C2 ~1 w% m% W* \% S6 z0 V' Z9 f5 R

+ ?! ?8 N! P( r, `! q* B- ovar xMax;
/ b7 E. w% F4 M/ u: Y1 R8 D9 h1 D6 {var yMax;2 f# e! x7 d. E9 W0 S. |0 x
var xPos = 0;
5 V' t2 S5 @! t9 m/ cvar yPos = 0;0 K  W+ w) Z  V; d6 z; J
var xDir = 'right';; [' r3 E' i/ Z) n
var yDir = 'down';
" H. G2 @% Q! t2 h+ l- Nvar superballRunning = true;
* T; Y1 _# `) ~, x5 `var tempBallSpeed;# m" P1 R( Q7 ?3 m, J* N
var currentBallSrc;
5 |! M& y& Y# s% O" `var newXDir;6 I9 s: q  \% L4 g9 C+ |- ?* x
var newYDir;0 y$ k% J% C$ o4 p5 J- z

" P4 }: M; [) c8 Q0 C# o& pfunction initializeBall() {' k( R( D" j3 y7 X  c9 ^1 [5 R+ Q
   if (document.all) {/ C* h' b: q3 K/ @
      xMax = document.body.clientWidth
) j) |# S7 d/ U& s      yMax = document.body.clientHeight6 `# Z5 t6 N# O. n0 B, M
      document.all("supertext").style.visibility = "visible";# c' i/ |0 `- _, b$ |; \: ]
      contentWidth=supertext.offsetWidth, J/ B4 Q+ q, L2 y! c; {
      contentHeight=supertext.offsetHeight
0 L: v' n3 f, u" A  q; C. h3 y% T      }
1 v$ Y( B, E% g8 C   else if (document.layers) {5 M3 f2 j% k" Q" X. |& F9 Y; F! l
      xMax = window.innerWidth;
+ W6 ]4 C- q2 C; k3 b9 l7 ?' m      yMax = window.innerHeight;8 E+ ^1 W) o0 X, Y
      contentWidth=document.supertext.document.width
8 c) {9 Y( \# i0 p: j      contentHeight=document.supertext.document.height: u( W$ R4 e! ~2 j* H1 k. }
      document.layers["supertext"].visibility = "show";( s0 ~2 f; P4 d! l* k5 t5 }  a
      }
0 E; A5 i- {; k0 A8 b/ P& J8 H( V* ?   setTimeout('moveBall()',400);
. {1 ]% ^0 D- K& u   if (hidetimer!=''); S* R& b- d$ b" ~7 |* r
   setTimeout("hidetext()",hidetimer)
9 X' z* a: O$ W5 `0 B/ a, X! K   }
' I* U% i' ?- z+ n& _
' _7 \- ^5 T1 U$ I1 Q0 Q, P% d' efunction moveBall() {
( d( c" i/ K8 B2 ~8 {   if (superballRunning == true) {
. Y. D7 [7 O+ a' C      calculatePosition();' O3 ?* g7 \$ `2 t- p7 e
      if (document.all) {
& \) i# s+ t0 y9 k         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" }! M8 W% K' ~3 o         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 E9 U0 e" Y& k         }
7 i9 T! l  C3 M9 a' r5 T; o2 E- z+ X      else if (document.layers) {
* o2 |& u- p3 y/ o7 `5 o9 g         document.layers["supertext"].left = xPos + pageXOffset;- P+ g! d4 ?# |3 u& k
         document.layers["supertext"].top = yPos + pageYOffset;- C; S; S1 c0 X& C
         }
9 y9 P2 ]+ \# @& E  x# F3 g. P      animatetext=setTimeout('moveBall()',20);4 f: d  v; a) G; d5 c
      }
$ u. Z- k. ]+ o5 A/ C8 z# q   }
+ o8 N, N9 t/ T) L; l9 `/ _. V7 F' w3 f. ]# m
function calculatePosition() {
" ~7 w) [8 m1 x   if (xDir == "right") {4 L) `1 H/ P  m
      if (xPos > (xMax - contentWidth - BallSpeed)) {
3 S" f7 t* k- @+ T2 e         xDir = "left";# s9 c( i6 t& u" s! J' ^" L
         }
! G$ ^4 x. p! k5 h+ u      }
$ _( J) w$ s  q0 R$ ]8 e# X   else if (xDir == "left") {
5 e6 T) ^0 V7 ^4 g* U3 k' E      if (xPos < (0 + BallSpeed)) {! X, u- a# _: D; D' M% I
         xDir = "right";! \4 z& m; g1 d; y2 ~
         }0 t/ h: C" b& d2 |
      }
; N' u* y4 F# N5 c- K* u4 N- S. u/ q   if (yDir == "down") {
# v( D0 m: R2 v4 @% l" N      if (yPos > (yMax - contentHeight - BallSpeed)) {( P9 s5 X( x6 D; y' t+ `
         yDir = "up";
+ |0 G" l( O8 y0 d9 d         }2 x7 W8 j4 m% `( @8 C# {
      }4 V3 ]5 Z0 u; g2 Q& L8 N
   else if (yDir == "up") {3 z& O7 L- w% k7 J* e9 g2 u
      if (yPos < (0 + BallSpeed)) {7 W5 f% Q3 k/ q' ?1 S1 \9 \
         yDir = "down";$ i0 n+ H- x4 O3 l2 _
         }
) K" C  x. M, D# u4 i& l0 A      }# j+ P3 Z: @6 c( N$ W3 Q
   if (xDir == "right") {
  I: m6 s! y- C+ a# F& p      xPos = xPos + BallSpeed;
& }0 l2 e( Q) N( O+ K3 g2 R      }: G0 |, e3 {( H7 S
   else if (xDir == "left") {
3 n2 Z" u! D& h. v8 @1 J6 a# ~      xPos = xPos - BallSpeed;
  F5 J. f/ B* X      }
. S: W; T# U; L8 z9 b& d# U   else {% L: R1 ]* m9 _* _; f" k0 d2 L
      xPos = xPos;# G9 X9 Q( `' N: Q
      }
, y2 ^" {! N6 H6 l% l   if (yDir == "down") {
% m8 h5 B7 X, Z0 t9 S( x      yPos = yPos + BallSpeed;
4 P9 ^5 Z9 Z& r2 \& U6 F0 s$ t      }7 v7 O  U% a; |& k, l
   else if (yDir == "up") {% a( t3 L( t* _9 P1 a7 ~
      yPos = yPos - BallSpeed;
6 T- h# w6 k+ B3 N      }  \, }1 A2 D( a8 y, @
   else {
. S( ]4 {' {3 G) @6 o      yPos = yPos;
$ D2 j. p3 X- p9 R" ^      }. t$ B0 F8 M4 |
   }
6 |+ j6 U- a. K  _$ P0 R9 t4 E1 B6 d
function hidetext(){& s, |; ]! N2 D' `/ u0 V( V
if (document.all)
( X- W: ^3 T/ p( N" W  lsupertext.style.visibility="hidden"6 U7 I8 B  s' U( F$ j
else if (document.layers)
0 r" }4 e& e) r7 S4 Udocument.supertext.visibility="hide"
9 Z% Q7 C" N% _/ sclearTimeout(animatetext)
5 V. J0 O) g4 K( Y! Y8 f  ~3 Q}
0 P+ x6 D9 @, k! M2 i
. @2 ~! z9 ~3 `# o2 P% Z! F' J! U& jif (document.all||document.layers){
5 W8 A9 {0 R5 a. b0 k0 U! w6 gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) U" R; B3 X1 o, J  F4 [$ wwindow.onload = initializeBall;
: ^) m) y, G" P6 Z) x2 Ywindow.onresize = new Function("window.location.reload()");
+ U* T/ ~/ h9 m; R6 i- Q}% [: n% z+ I0 U

, k- }3 Z6 N  @' R& Z1 R</script>

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