返回列表 发帖

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

<style type="text/css"># E2 _. U1 L# I4 Z
#supertext {6 g/ {3 o9 x( {
position:absolute;
8 B5 Q1 a4 i" F& ^  B& [left:0;$ U" T( o; c! N& N! s( A# q( x
top:0;
* r2 Z& w4 z' w$ W  a2 b: Pvisibility:hide;
' S% W# w3 B2 o" Pvisibility:hidden;# _2 t5 }& I! Q% c# g6 s' f
}8 p  ~* r: N& q! p
</style>
! E2 g5 [! J; d, K; T<script language="JavaScript1.2">
0 V3 J6 J3 j# v<!-- 改变下的字体的大小。颜色-->& n1 }2 e% c# U, i
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% m4 {& u7 G) Q: K& [) A" ~' Fvar hidetimer='';
" }# E" a, v: M9 y& r<!-- 改变下的弹跳速度-->
8 z$ ^" s" o/ Qvar BallSpeed = 20;
- }1 A0 \/ a/ r) z1 n5 zvar contentWidth;, u/ P6 Y2 s/ c; O  c2 n8 W5 \7 y
var contentHeight;
* e: [' s" @1 I3 nvar maxBallSpeed = 50;' R2 ^) e8 @. Q/ \/ U
0 m5 q4 ?4 I4 {( O- v

4 G9 p8 P7 z- _+ n* C& Gvar xMax;0 G3 D+ l0 L6 P" r
var yMax;* F8 o% y6 i& e) w# @$ h
var xPos = 0;
  _3 O3 R3 |8 U. }& V; ?8 Uvar yPos = 0;
' Y2 c0 I* [. Z/ m) n( H* dvar xDir = 'right';
4 X! ]% Y  u. k2 q6 kvar yDir = 'down';1 @! a4 m: j$ [. K5 [: k
var superballRunning = true;- u5 i5 C* x, y5 L( W$ Y
var tempBallSpeed;7 g7 x7 K6 ~1 L' {! d
var currentBallSrc;
. `! M8 N+ b6 Ovar newXDir;0 x- a9 E/ J3 W/ x" w$ z
var newYDir;
% R6 J& d) q& s- j3 J# N( i. \/ _7 ^
( f: r6 i4 V( M* C9 L, V# B4 dfunction initializeBall() {
$ a8 n: L; b1 H" T. E4 t4 ~% N% C+ i   if (document.all) {: N9 u6 ?* ^. D# V
      xMax = document.body.clientWidth  f$ r9 t4 r- W
      yMax = document.body.clientHeight
  \" O+ R" G0 E; n3 {      document.all("supertext").style.visibility = "visible";
4 J& h3 o8 w$ R( _; M: m( {1 m2 z      contentWidth=supertext.offsetWidth& [9 w" g! H/ q/ N
      contentHeight=supertext.offsetHeight
( k* E% H. D) b0 l      }
# v! e  ~9 V; Q6 G: [) O. O& x# D9 L   else if (document.layers) {3 Q) w+ e( a& `# p2 q  q' X
      xMax = window.innerWidth;! D% Y7 \4 S+ O8 ~& T; n
      yMax = window.innerHeight;
* m3 h- \) w- \8 \2 h      contentWidth=document.supertext.document.width' i- `0 y5 C+ c" Q
      contentHeight=document.supertext.document.height
- a' O7 ~/ ?" F/ h      document.layers["supertext"].visibility = "show";( \7 m; ?1 [* A; {5 A: H6 D- w7 ^
      }
- M$ {( `' D8 [& Z   setTimeout('moveBall()',400);
! j$ @$ d1 y* {! B3 j   if (hidetimer!='')
* d4 f6 |2 y& `) u   setTimeout("hidetext()",hidetimer)  r: S3 l* W4 p( H8 M+ s
   }
9 P5 h, R( s, l5 o; _3 V8 I  n  x. G' E6 r0 E: z7 \
function moveBall() {
0 F) f7 v/ l9 {) R   if (superballRunning == true) {7 c) W  R- @1 k; r- e: c
      calculatePosition();* r% L/ a0 d0 E
      if (document.all) {
- u& C! H0 y+ B  s' P, v' D         document.all("supertext").style.left = xPos + document.body.scrollLeft;% _+ `% q( I! a& M
         document.all("supertext").style.top = yPos + document.body.scrollTop;5 X, Q0 Y: `; U4 W5 ~
         }
7 b" ~8 H6 P) q+ N      else if (document.layers) {& B" X/ E, z: p$ V
         document.layers["supertext"].left = xPos + pageXOffset;
8 o# @& Z$ v+ c( Q, F/ |+ _) U- v/ S         document.layers["supertext"].top = yPos + pageYOffset;5 D* T9 K+ u# h2 x
         }
1 Z/ D7 Z8 s4 M$ E- {( z5 t0 F      animatetext=setTimeout('moveBall()',20);
2 V4 ?7 J) K% U7 e+ ]3 i9 M      }
2 s% R2 @1 @9 K3 p" a   }4 C- M; ^; j+ V  U7 G! X1 Y' U
& L* y' _# T8 z/ C1 @. `9 H9 j
function calculatePosition() {7 ?+ k" r3 S* R4 H4 O' ]2 ^, |" h
   if (xDir == "right") {1 X2 }; ^# N- g1 M2 Y* n4 `
      if (xPos > (xMax - contentWidth - BallSpeed)) {+ k, v+ C7 I! @9 r  a: ^- [" i
         xDir = "left";
* k7 z- Y1 J7 a: p5 d- ]# d; x5 u         }, v6 s$ n- ]6 r, i5 @7 a  l/ H
      }
, d  n: r% D9 i# z# p: S- q( p/ h2 }   else if (xDir == "left") {
( O6 b; K& K& r& x* h# u      if (xPos < (0 + BallSpeed)) {. E: H1 U" [0 |" j3 @+ M
         xDir = "right";" k& R6 ?; u7 E0 R# ~1 [# W3 K
         }
( v& }. T9 v, m; M4 z      }
+ h/ n  h7 {2 b, s   if (yDir == "down") {
8 `* Q2 a/ F7 ^      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ f. A" a. C+ P$ ^4 U8 r         yDir = "up";
0 f9 t( C! ?* D% C- e         }
- `' M5 u; h, L8 W: L9 \      }
: P( `2 r: ^* V2 h& U   else if (yDir == "up") {
) u# @+ _" b( K      if (yPos < (0 + BallSpeed)) {# i; t5 R8 w6 P1 L! j" ]
         yDir = "down";( p: X& z. L1 P3 S
         }
+ e( r. N4 m+ i. `: X! o( ~      }: |9 k* [: X1 ~5 `: D1 P& ]; _
   if (xDir == "right") {
) ~1 ?7 c) M5 G; B+ f* ?      xPos = xPos + BallSpeed;* i, T+ q! J- H0 S4 W
      }
" J7 U0 j4 `. [   else if (xDir == "left") {
% H: \- ^' D4 M& n2 w      xPos = xPos - BallSpeed;: S" t) B. D  c* K3 d9 g& m7 Y8 u! k
      }
: f2 z. I$ p  V* Q: h* f. G   else {6 @' {6 j0 Y4 d7 y3 ~
      xPos = xPos;5 X* s3 a6 V5 k1 O7 \6 D+ T. y5 R$ ~
      }4 K- E+ M; Q2 W0 h; ?& ~
   if (yDir == "down") {+ o: X* ^& g( j( C$ ~6 C
      yPos = yPos + BallSpeed;9 k& \: o1 k2 ^" c
      }/ n7 {4 t: `7 I, u6 D) q& {
   else if (yDir == "up") {: S9 _7 q- _5 w, E4 \! r$ y, s
      yPos = yPos - BallSpeed;
2 r& q; B0 U* s3 A      }% @9 z9 T7 K6 |! y' Q
   else {' L! |" Z. V- K
      yPos = yPos;
" Z3 }' r- L2 R/ K1 d      }
* N" k7 b2 f* \3 s; o2 g  R   }8 g$ w/ i: `2 l

" t4 e2 g* ^8 o5 gfunction hidetext(){; P1 W% j- ~# R& @% |+ P
if (document.all)
/ F7 ^3 P, {. v) V" J" c3 ~: |supertext.style.visibility="hidden"
) ^6 O: p# n% a! _6 Q7 L1 H7 {else if (document.layers)
0 G% n- W7 R+ F7 a, @2 \: F8 b' |document.supertext.visibility="hide"
4 ]- z- `' ^' F8 B/ M* ?clearTimeout(animatetext)6 b% s- ?; f, S- ^& J
}
+ |7 S* |+ H1 G
5 v7 h2 Q4 t8 tif (document.all||document.layers){
& T  s, `0 i/ G; Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( e, S2 i6 k& N1 Y5 J' a6 o
window.onload = initializeBall;
9 H* t% y3 d! H: a5 C! Bwindow.onresize = new Function("window.location.reload()");
" P3 y7 y* y0 t6 `. I7 J}) p  W2 _2 y" q

" K2 e( _- i" ~</script>

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