返回列表 发帖

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

<style type="text/css">, s2 G9 D+ H: Z  H
#supertext {
/ S/ _# y- d0 ?" a1 Vposition:absolute;
9 q2 S4 F+ s  [left:0;
$ d) Q8 M/ o& p# ~- z+ vtop:0;$ k" R; _: Z& k5 Z* R: M0 e
visibility:hide;
2 t6 |3 U1 W3 s! p% [& Evisibility:hidden;
  y, |: q' v/ A' E; ~1 U4 F- M& o6 ]}, T$ Y" k4 G6 `, C+ F8 F2 x
</style>; p8 t) r3 a( l& F$ t" I- }
<script language="JavaScript1.2">
# j) R6 s2 E. @<!-- 改变下的字体的大小。颜色-->
6 w$ N+ k7 g/ D# V! [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
3 S, H* Y, a5 a$ Yvar hidetimer='';
# I. H' t( c+ _5 H<!-- 改变下的弹跳速度-->
; y: J4 C- b$ |! U" dvar BallSpeed = 20;4 k5 [8 Q5 `( w, J
var contentWidth;6 b6 B5 o, B! }" ]3 V3 t7 o1 X* X
var contentHeight;
! P& p# W9 P. @var maxBallSpeed = 50;( [) @0 x  R0 Z1 w) K6 x
) z; \" d) B# J' p6 C" Y& f6 n( K% l

- E* u2 R0 x' e% Uvar xMax;
( @$ g: S) x4 z% N2 gvar yMax;
! z/ s4 @$ b: x, ^4 \$ [+ F( q' ^var xPos = 0;
$ m5 D* e9 n$ n) N! i3 Svar yPos = 0;
6 l% }" ]6 P, h& d& y9 Dvar xDir = 'right';0 {( a* q, ^1 X& M( c5 P
var yDir = 'down';
: q3 ]* a: K5 Y) a' C8 g+ l' ovar superballRunning = true;
+ [# y0 i/ b1 n, |1 Evar tempBallSpeed;5 `: V( q, ]+ f+ H# y& q
var currentBallSrc;
4 f/ R  R+ [9 W( Qvar newXDir;& z1 S; i. w$ o& R8 b3 r
var newYDir;
+ Z) w% S" l3 C# i: d1 E
& j3 I9 n8 _/ W# O% N3 }+ F9 u( ffunction initializeBall() {
5 e7 [  u# w" [! E" ~' M   if (document.all) {+ `5 F( F. D. v  a
      xMax = document.body.clientWidth
% T% J4 O5 P1 T3 V! w# |      yMax = document.body.clientHeight
6 o/ H/ h& ^4 O4 ~/ s) _      document.all("supertext").style.visibility = "visible";: v% ^6 V- |. Z4 Z' x( {( D# b9 d% N% _
      contentWidth=supertext.offsetWidth3 Z. f  l0 {7 s" I4 A/ u! y% W
      contentHeight=supertext.offsetHeight& x+ \/ f, n' \! N% p5 X+ C
      }
$ t0 b$ f6 d7 s4 o8 @   else if (document.layers) {  L2 f6 v& }) H; _; D
      xMax = window.innerWidth;6 Z: ~% d  I$ _! K
      yMax = window.innerHeight;! F7 u6 E1 v% p: Q
      contentWidth=document.supertext.document.width8 z  K* k5 l- k( G- f& E
      contentHeight=document.supertext.document.height
7 }) H6 s; ~1 h% v6 V0 o      document.layers["supertext"].visibility = "show";
6 i2 i# T. X; R  `      }( x/ F. ~  K' n3 k' p7 y
   setTimeout('moveBall()',400);% H' `* |# I! ^9 L2 {. J
   if (hidetimer!='')
" U& T; b* x" ]) S3 a   setTimeout("hidetext()",hidetimer)
) g+ n+ s! q, e$ H2 s   }
6 n1 M7 @2 z# ^; C; \0 d! k7 M2 s) O( l, Z! H7 b& d) ^
function moveBall() {
# y7 I0 E3 x- d. E5 L* E2 B   if (superballRunning == true) {
: F* L- K3 R- D, ~: b4 v      calculatePosition();
7 B. u: b! ^: s5 `/ v% k# V      if (document.all) {
* t. v# y6 I) M         document.all("supertext").style.left = xPos + document.body.scrollLeft;/ t5 c5 E: a" V: l; s  ?9 ?
         document.all("supertext").style.top = yPos + document.body.scrollTop;
. `, g( W8 l3 u/ }         }9 x2 ^: ]/ @5 [9 N
      else if (document.layers) {/ k9 D: O7 W, G
         document.layers["supertext"].left = xPos + pageXOffset;1 c9 t4 Q: L* \! E
         document.layers["supertext"].top = yPos + pageYOffset;4 P4 M' a# B5 k
         }# b- }+ i2 H' c0 u
      animatetext=setTimeout('moveBall()',20);
6 F' p# v& E; H      }  z. A: _  z# J3 v  O
   }! e: J4 X0 S1 q8 y& {0 A
8 {$ F" T/ o+ V( P7 Z
function calculatePosition() {
* `% g6 p& q  V7 ]   if (xDir == "right") {
' r/ W8 A9 e* }. I      if (xPos > (xMax - contentWidth - BallSpeed)) {
) B% S# g  p8 E         xDir = "left";
% @$ T  g. w  I% }" l         }
! t( D/ \1 B% `* ?      }
8 E! v( G3 Z9 H8 F% i9 Y$ o4 ^& q   else if (xDir == "left") {$ M- Z( w3 s- O, y" d
      if (xPos < (0 + BallSpeed)) {/ e  F5 B* s/ c: t+ M
         xDir = "right";% {( f( Z; R& h( z( p
         }
# b( c0 F6 E1 h' w( r/ f      }
3 v* h- k* ]) `  K2 X, {   if (yDir == "down") {
; ^* u  e3 b1 P" p  d      if (yPos > (yMax - contentHeight - BallSpeed)) {, T7 ?- q* \' ~- T/ o0 y, r
         yDir = "up";
: p7 [: S4 K" {" n  {         }" V! w; F( {1 [* Q$ {# E% T+ t' q  i
      }
. Z% u4 Z* {3 n0 _6 Y/ n   else if (yDir == "up") {& h* h4 H* \& T$ D
      if (yPos < (0 + BallSpeed)) {
6 y* a% l, k3 R, p3 Z         yDir = "down";
3 C! a# E9 n5 D' @9 c: O         }& E" l9 b& A4 h7 a6 t' O/ j6 x; ~
      }0 S% v. _4 }  I
   if (xDir == "right") {
! i9 F! ?7 `3 }, q) f      xPos = xPos + BallSpeed;
: a- A$ D$ d, x8 A4 @' h, ]3 O2 i      }
9 C8 l3 o' j" l$ q6 g5 N   else if (xDir == "left") {
! r: o. U) J) J      xPos = xPos - BallSpeed;! O. d4 l/ o: x$ [& m) u: n: H
      }
$ c$ `7 }+ R  p6 r  N& B1 }   else {% x) e8 c# N* D1 w0 |  {0 P
      xPos = xPos;7 O- [; W. D" V
      }
( w$ C( w6 l4 ?& [# _   if (yDir == "down") {- H. M  j2 V! t
      yPos = yPos + BallSpeed;1 ~  ~( ?9 U5 v: e
      }5 c0 A5 z* [( J( r
   else if (yDir == "up") {- _+ v! [/ L! G7 ~
      yPos = yPos - BallSpeed;3 r9 S- P6 k5 L6 c. h
      }
. A' f4 Y" E5 C3 |   else {# o% G1 ]' P) x* q' I- c
      yPos = yPos;( |; e- K7 s+ Q* |. r5 u/ q
      }( q' w1 ^7 v1 Z# k
   }/ I/ a; F7 G" A& V( {
+ F* A) l4 z0 R! Z$ Q* @
function hidetext(){: I, F/ {1 y9 i& O
if (document.all)2 Z# g; @) W  |$ ~
supertext.style.visibility="hidden"
8 |# s, _, w" Belse if (document.layers)% L" z% Q7 ^  d5 H5 t
document.supertext.visibility="hide"
% t) A+ l, Z. a* `clearTimeout(animatetext)
. n2 m  c4 r2 ^4 e9 a/ p) q  i* Q- @}" W. L" g$ g  ]4 b1 y! T4 r

1 ~0 d; z: i% n) ?9 {9 n! L+ ?if (document.all||document.layers){
5 y+ u' C( E$ i; `( idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 v, [  ^$ N2 Y, m- y, i
window.onload = initializeBall;7 z) x4 \" U/ s9 k) W' z' i8 a! B  D' G
window.onresize = new Function("window.location.reload()");
4 V3 F) G. l/ n" p5 E  K# n) ]0 L: v}
; X, O9 `* K# N( p! @; O
- V7 d7 M3 O, W* a; x</script>

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