返回列表 发帖

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

<style type="text/css">
$ L7 I3 ?3 N5 Z$ k3 b# J2 _#supertext {+ u# b+ R5 W9 u( ?0 }9 j
position:absolute;
6 f9 v% v6 ]& Oleft:0;
& m2 L5 i8 c, K0 i6 ltop:0;
6 l: Z9 R3 `3 x2 T7 V+ D- ^6 D5 t. Ovisibility:hide;; M+ h/ s% n# c0 `9 _2 x7 s
visibility:hidden;; }6 b  {$ M* f, k
}/ Y+ j# ]" Z4 v, }+ n. f7 A# A
</style>
; Y5 G. x$ Y% i# M# G<script language="JavaScript1.2">
' r3 q. P6 ]8 }3 q; v0 s<!-- 改变下的字体的大小。颜色-->% K" i* d2 P) ^9 E8 a
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 d" u' @0 K: H: k. Q
var hidetimer='';& {8 E  L! R+ o+ K* o9 x: i
<!-- 改变下的弹跳速度-->
9 f8 p9 z0 m( x4 D* T5 r4 T( Pvar BallSpeed = 20;
' _0 q' L. @- d2 uvar contentWidth;9 M+ i8 S! n8 P2 @) ~9 K/ Q4 g
var contentHeight;+ ~- F1 I% z( K* T2 J  C
var maxBallSpeed = 50;' I6 _4 z8 J( X4 R. P) D; K! S( L
: x" T' Y; W6 J5 g% u; D' H. w$ {
+ Z# L, M/ |; D# W
var xMax;7 V. t. ~7 g: ~) u: n9 _7 g" P
var yMax;& ~- V. G. Z" I$ K, H# ]
var xPos = 0;
$ V: t8 P3 o3 gvar yPos = 0;
2 o3 g0 h& p% W6 C, _var xDir = 'right';1 K" D) y  B/ x$ V( a. {
var yDir = 'down';& @) A0 Z2 w) c# e. [
var superballRunning = true;
4 E: M! N. Y5 `  F* V; e9 tvar tempBallSpeed;
/ p" ^* m4 ^3 G  ~0 l7 V% z& Gvar currentBallSrc;
: U, t. g" T+ C- L2 }2 ]: s0 rvar newXDir;4 E& _% }" c! e
var newYDir;
/ j; Q$ ^& D3 H, H3 u7 N! L& f% _  }8 R; @* v
function initializeBall() {
+ l8 h/ C0 `2 z! l( n; e7 O, ~6 B   if (document.all) {6 R3 E4 |# M6 q: T
      xMax = document.body.clientWidth
$ k" i' @; c8 T' r  U1 w      yMax = document.body.clientHeight
! p9 B1 [3 Q- i3 k$ D      document.all("supertext").style.visibility = "visible";
; u+ k! V# c1 M/ ~% b' E      contentWidth=supertext.offsetWidth9 ]1 d; U% D4 W$ z( N. U0 A
      contentHeight=supertext.offsetHeight
5 M3 O  R( t9 P      }
2 R6 k& N9 o" G   else if (document.layers) {
/ {& w9 m, m0 H" R4 F# E3 `1 `4 @      xMax = window.innerWidth;
$ h( j' F; s" r& f0 e      yMax = window.innerHeight;; R3 i( a% h5 ~' \: g
      contentWidth=document.supertext.document.width
& `1 V' |- y0 D- d: b6 p      contentHeight=document.supertext.document.height
& I. }4 e& P' e  t3 ?& k      document.layers["supertext"].visibility = "show";
7 W& e; M: L- R/ _2 O( L* O+ z      }2 v5 @& i% E. \6 g  c
   setTimeout('moveBall()',400);3 R7 ]' O/ x8 c' L2 j: |1 |4 w6 p6 T
   if (hidetimer!='')
! i4 c2 C/ N6 `& z2 _   setTimeout("hidetext()",hidetimer)0 Y. i5 W% D9 A2 ?0 z
   }7 t% q( {- A! E& y# X$ m
. d: a. k% E( v$ T5 @
function moveBall() {
( a. ?* a6 K, l1 n. X, }   if (superballRunning == true) {. W# R8 z5 |" R' _3 L9 p1 l
      calculatePosition();
* E1 C+ j& p+ z" y3 a2 X: }) Y      if (document.all) {
% T3 ?% |6 h1 U/ f6 \4 V* C         document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 |2 K3 @; {+ E2 p         document.all("supertext").style.top = yPos + document.body.scrollTop;& T! s  H; t2 c9 \; Q/ p) I: z
         }
; A! z% s. j) O# v8 X: |3 N& B      else if (document.layers) {
% l( J" X0 H! _: I  L; l" I         document.layers["supertext"].left = xPos + pageXOffset;/ X: P) z% Q4 ^7 B8 r
         document.layers["supertext"].top = yPos + pageYOffset;
+ x( y2 L0 T0 }8 o6 T, U         }
6 ]2 ^2 @$ f) Y5 G      animatetext=setTimeout('moveBall()',20);" K4 n9 a8 y+ e* m7 O
      }% g" M# l) L- S
   }
, h' s& N# Q2 ^) d
( ?/ r" H8 a8 bfunction calculatePosition() {- k; O5 n5 S4 [- ]3 z. S
   if (xDir == "right") {
2 r6 `, m% _$ T1 F5 e9 d+ M      if (xPos > (xMax - contentWidth - BallSpeed)) {
/ [9 V2 o2 ^9 R' n2 U4 A; t. ?         xDir = "left";1 _3 S3 a+ ^4 t9 ^
         }4 H5 z4 g  F7 s& e: A) o! o$ V
      }1 k# H( B& T" R: f- m
   else if (xDir == "left") {
% g7 J0 M5 y+ M9 s. g      if (xPos < (0 + BallSpeed)) {
: ]* Y# {8 c# T7 V$ B: B         xDir = "right";
0 E( ^, i0 |6 K         }- T6 Y% J8 S( u
      }
3 N3 p6 ?: @! Q8 k   if (yDir == "down") {- @8 c& P  r4 T, X% m9 K
      if (yPos > (yMax - contentHeight - BallSpeed)) {& }8 V  {0 K- W& L' O4 A$ @/ M
         yDir = "up";
7 m$ ?- ^* n. f3 ?8 x3 s         }7 ]$ T! l8 I  e  F9 Q6 }( K8 \3 u
      }
% `8 j6 ~1 i; D& t0 i   else if (yDir == "up") {
1 d9 _- P5 \' u, i      if (yPos < (0 + BallSpeed)) {
  ^) j6 W. @5 x! f' m  m         yDir = "down";; \" B6 e' O+ _
         }
9 w8 {7 o7 P* z3 o      }+ y. b) b! J  z9 g/ e" d
   if (xDir == "right") {
& L8 z% H" t" e2 V6 E  n8 j      xPos = xPos + BallSpeed;
& S( w8 _; K4 B2 w" F      }& W0 `! f: x8 ^$ Q6 W) c
   else if (xDir == "left") {, L0 _7 n1 ]7 k3 v* C8 h6 N
      xPos = xPos - BallSpeed;
9 R  f' `5 d9 s+ R! z5 C/ ^2 `      }2 f, p! x) ?- q5 c8 `' G5 {, U
   else {
( B! u9 N2 h0 R, Z1 y6 [      xPos = xPos;. Y6 s: R( T- Y+ y
      }# W, S% c! g% N; s* u) d' b2 }
   if (yDir == "down") {
: Q+ s& g& p$ f% }) l      yPos = yPos + BallSpeed;
+ Q) M9 j1 o$ x' C9 _: F      }
. t9 Q" W0 h" F* w   else if (yDir == "up") {- Y- q+ I) k! e5 V6 O
      yPos = yPos - BallSpeed;
2 ^/ j  n7 v% O. x8 n' f% f+ }      }* x9 O9 o8 a% _8 W& `- n: P& j  S
   else {
: d2 Q6 Y5 z3 ^; D      yPos = yPos;0 x+ {* X! S' W% q: f, t+ Z
      }
) i, Y3 A7 x& A( b   }
0 N6 H4 f% a- Z- A3 U" P( W  m& F( s& @
function hidetext(){7 l5 X3 x! H# W* @' W( x
if (document.all)2 k$ S# p  f7 U4 ?0 S* G
supertext.style.visibility="hidden"9 b" L# L; {/ g, _# u0 p
else if (document.layers)
* i0 J4 N; g: `; h0 S& ?document.supertext.visibility="hide"& X- t% ~4 }! s
clearTimeout(animatetext)% X' C( @6 U1 j
}
+ }& P" i6 v! V* |& w4 o! w; y# n! e* P/ b$ ^; w% N3 n7 o
if (document.all||document.layers){( D# U! c$ c" ]1 ~3 F
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'); @- `* J, ]* v& N
window.onload = initializeBall;4 t. M7 o  I4 o
window.onresize = new Function("window.location.reload()");! V" ]7 E0 k2 _: K+ m
}) G) y& w: P( I6 p' g

9 Z2 x! q2 `7 c6 Q0 [0 ?$ F  V</script>

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