返回列表 发帖

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

<style type="text/css">
) X$ h5 c* G) ]#supertext {+ }& h0 G# ]2 z% T7 a
position:absolute;
' z% s. Q0 R$ w2 Uleft:0;; N* N6 n1 I' _' k
top:0;
$ o9 u! Q" C7 Y9 q- }" z/ T7 Svisibility:hide;
- a6 t( ^! J9 e+ R" q2 d. S7 {visibility:hidden;5 ^1 a/ r3 G4 o4 r* F) s
}- i7 {- j. d' \0 j" y& i) Q2 J- F
</style>
# z( |' J: _& b' u# c( l9 }8 \, A<script language="JavaScript1.2">
8 x! A: I! e. b, _* U% G/ ~<!-- 改变下的字体的大小。颜色-->: f; M, s( s$ P0 u
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. t% l0 Q- b4 j, E+ T
var hidetimer='';
# @; m! s/ K! C) L3 E* Z, m' j1 c<!-- 改变下的弹跳速度-->
9 ~! {6 ^' [, }6 t+ `! V+ avar BallSpeed = 20;
9 j. R+ [8 Y: f& y4 ^var contentWidth;3 T7 }. I* d8 m/ g. N2 h
var contentHeight;* ~# @: L' j' H5 V  o
var maxBallSpeed = 50;. h+ Z) Y% B4 s% l; J

6 X7 ]5 M. S( H' O/ Q: Z$ t, \, M& X8 _2 I
var xMax;
, P  o  J" b" U; R% u: lvar yMax;
$ [4 E' T1 h% y- [; w; M. Qvar xPos = 0;
5 c+ P5 G+ U* {% m& bvar yPos = 0;
9 u& L4 p8 I3 g* C' G% b2 ovar xDir = 'right';
8 `! e) Q( ?- C1 nvar yDir = 'down';# k. O, {( ]) S/ s0 T
var superballRunning = true;
7 Z: N" C& n. Gvar tempBallSpeed;$ ]5 ~; `1 f& Y  F* c
var currentBallSrc;
+ x- \8 n1 M, H2 w: hvar newXDir;
% K& k" V! @& ~0 A9 I. Pvar newYDir;! I' J0 P  c9 }0 Q  P. T
$ Y  h0 H/ T3 `! z( O
function initializeBall() {
2 r* m; v2 A5 ~# R) V   if (document.all) {
& r) d: |. u( f7 n; X5 U      xMax = document.body.clientWidth& m1 l  P' s+ m+ Y0 G% N
      yMax = document.body.clientHeight; d( J: N; }2 w
      document.all("supertext").style.visibility = "visible";& J# R0 k6 }7 D! S& S* K
      contentWidth=supertext.offsetWidth: q" [+ a7 P0 B. Y! t, ]6 Y
      contentHeight=supertext.offsetHeight2 _0 P& L& ]$ d; W/ k
      }
' e9 y- ?+ X& k7 b  f6 n& o   else if (document.layers) {  @# F/ {( b, P0 c
      xMax = window.innerWidth;  H% T6 J4 `  A2 i4 K8 e
      yMax = window.innerHeight;
) P8 B9 Z: A% A# [8 C8 ~      contentWidth=document.supertext.document.width/ s/ u8 W9 L) J; v- ~# |
      contentHeight=document.supertext.document.height# Z' H. R  ?$ Q5 D; h1 j) x, _6 s. g
      document.layers["supertext"].visibility = "show";
  k) z& B) ^. t: E6 U      }
4 p$ G; E1 N, K, X  w) t; U" m   setTimeout('moveBall()',400);) H% N1 E/ I2 W; T$ W6 I( v* D
   if (hidetimer!='')! y  }+ `3 R' k& x
   setTimeout("hidetext()",hidetimer)5 a7 O: D4 F( T* e. w/ p! Q
   }2 Y$ m/ [! @# ?2 q0 P2 z/ Q
* ?% S* {, e0 D) z1 T
function moveBall() {
  n/ j- S# u4 Z+ K5 x   if (superballRunning == true) {6 D: m# e8 T: p+ x( p: C# D
      calculatePosition();
, H" n7 X# S, N8 c( T      if (document.all) {
! j+ f' ]0 r: }! t) |# _1 i! O- {         document.all("supertext").style.left = xPos + document.body.scrollLeft;1 V# x1 m& R) Z
         document.all("supertext").style.top = yPos + document.body.scrollTop;# P# X5 v0 l( N
         }& _5 Q% y5 \. d3 |
      else if (document.layers) {/ S1 h) v$ T+ Y% l4 @% t1 u
         document.layers["supertext"].left = xPos + pageXOffset;
% c4 B6 i$ k7 n- }         document.layers["supertext"].top = yPos + pageYOffset;
/ a' K0 z! V% D2 q. N! y4 q! `' h         }  W1 k1 V4 u+ p# {: f
      animatetext=setTimeout('moveBall()',20);
5 ^0 x& n9 W" d+ q" e      }4 S. U/ R: Y: C; }4 N( Y
   }
4 e/ J- @. H& B% C( |$ i/ C# n, r% `/ e9 y
function calculatePosition() {& t' `. r# B9 w4 Z  \3 p
   if (xDir == "right") {1 K0 \0 b2 N. a& J: P" K$ C
      if (xPos > (xMax - contentWidth - BallSpeed)) {
/ c1 g) D/ K8 z0 a) ], j( w         xDir = "left";
' t. a( d0 {& i" [. A) E# I, c         }
, ^9 k5 n- U. M2 A$ d      }
3 G) p% _/ P7 }/ V6 m0 Z, _   else if (xDir == "left") {
! i  @7 q+ W& n6 b      if (xPos < (0 + BallSpeed)) {: j5 M( _: a% r2 b
         xDir = "right";! M( t+ {  ^: M: _0 ^+ a* g9 K
         }! o$ P; g+ @' N, \2 [2 c  G2 g! g
      }
& z) x- J5 i; S5 l( n6 ^   if (yDir == "down") {
1 z; F# ]) c4 p' j% u- o* k      if (yPos > (yMax - contentHeight - BallSpeed)) {
5 G) ~) q  T( y* s1 s+ E  o2 I2 x         yDir = "up";
# J. E" c! \( L+ H. J8 e) }7 G) l         }2 o/ P. }8 T0 p
      }7 j9 P5 F, a1 u" ^& e" i
   else if (yDir == "up") {
# T7 H1 [+ F; q4 V* H, [      if (yPos < (0 + BallSpeed)) {
# l* }9 c' v8 _' T) v1 c: u* g         yDir = "down";
4 P% q5 P+ T' g  l- v! |' Z" |. H2 h         }
' v. ?% {( k; f3 k      }
) ?: Z. E+ N0 @: V; ?. K   if (xDir == "right") {8 |# b! }. o% o) s; Q# [* K4 h
      xPos = xPos + BallSpeed;
8 I* Q; f6 J( Y) K: v/ w7 v, e      }
# J* |% u% H4 z2 [   else if (xDir == "left") {
( N# j! v% K2 q( O      xPos = xPos - BallSpeed;' e2 K" I9 G& m4 w: @9 b* T
      }
& B' H3 t$ c2 k: K   else {
% t# x; F$ t8 t) K, }9 G7 p& c      xPos = xPos;/ J: }% q8 b: W& s
      }% }% Q4 ~$ N' D4 D3 K) e
   if (yDir == "down") {  O5 i7 m) @6 h' z+ O
      yPos = yPos + BallSpeed;. g% x+ B. y( [' ]3 q% M
      }
* }% d* U* |2 d4 H6 P8 x& o   else if (yDir == "up") {2 d" u$ Q( s/ z# d% _! L- F1 r& G
      yPos = yPos - BallSpeed;* b3 a- \% l# {
      }$ a9 K5 I9 q. o: a+ {* ^* W5 q
   else {
0 T# J4 x$ i- ^# t. u; W      yPos = yPos;+ e5 V* L/ j, r4 M6 G- @2 _
      }' D! X# F: E. A5 D8 w, X8 f3 o) G* ?8 N. s
   }3 J: I4 O) H( T& y/ @

/ k# z7 t$ B8 R1 i3 f3 yfunction hidetext(){* B* M8 y5 G; W/ W- }' L
if (document.all)
: w6 |3 }1 _8 A5 g4 \7 M3 c* J! dsupertext.style.visibility="hidden"* j9 w8 J0 V; ?, E8 f& P
else if (document.layers)! p. \6 N6 g2 W
document.supertext.visibility="hide"
2 E1 j" o" S" q. t2 uclearTimeout(animatetext)
3 e% v( A& T9 Z, D1 M9 d}
* @& p$ ~- U) F& G% }8 h$ J1 T9 ^+ `+ H9 b
if (document.all||document.layers){
" T9 P" J4 N0 J( |, ~$ K% Jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
: D) `# r7 Z. y, P5 X6 `# l3 H2 ywindow.onload = initializeBall;
  l5 O# y" D, l6 o+ uwindow.onresize = new Function("window.location.reload()");
8 B) P3 U& w: g4 r/ w7 U}
% F+ f; E4 ~) v4 l/ O
. `% ]- }1 r7 }+ R* @9 d</script>

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