返回列表 发帖

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

<style type="text/css">
4 Q$ g* d+ o( g" _#supertext {
1 x# u- [( `* i" p7 Dposition:absolute;
5 t* v, ^9 f+ H( x) Cleft:0;
& r2 X  }: J3 m6 }3 ttop:0;
& U/ u/ u! [8 M1 Gvisibility:hide;1 G) N3 Q5 d: D* a2 y
visibility:hidden;
+ M- ^  i5 i0 A. t/ k) c' {}
$ O/ |. A: |$ E  z; ^$ _</style>
* I2 \& D4 X* |/ T8 \0 D' s<script language="JavaScript1.2">* U6 {. w- S' c* Q3 _: S" u3 I' a5 S
<!-- 改变下的字体的大小。颜色-->
% `& N" I" t9 fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" a* {0 V) I% rvar hidetimer='';
, d* _4 e- a8 `4 U+ r, q<!-- 改变下的弹跳速度-->
2 l. l) i( n' {2 lvar BallSpeed = 20;
. d4 d- U; V3 u) |1 nvar contentWidth;6 K! C1 G2 S6 Y9 ~) L8 l
var contentHeight;% d0 S# g0 r. y1 ?. A6 f
var maxBallSpeed = 50;
* ]+ ?! _9 M; E5 [3 b8 \8 }
" E6 ^  L( g5 b1 x! j6 {9 ~! n2 s+ ^. I6 y: o2 M
var xMax;
0 u& V. E; _1 q! I: V8 tvar yMax;
( E4 o0 h  i% Y6 p# W+ g+ M% Ivar xPos = 0;
, v5 `3 J; ?8 E% Xvar yPos = 0;% W7 v" M+ o* ]9 m9 D& K
var xDir = 'right';% Y8 W* [# p2 b% q$ S1 y% {7 P: B/ m; @
var yDir = 'down';* B. n  _$ e4 X1 G8 ?
var superballRunning = true;
$ p9 w+ h1 h9 H" e2 M: |" Fvar tempBallSpeed;+ _4 _7 T; t- W
var currentBallSrc;
+ U; v# o2 S, W( i" o& uvar newXDir;% O+ A$ Q4 R/ P9 a" J
var newYDir;( d% @. H( p8 K! n
; V1 M" `1 Q+ H7 `# {. L4 M
function initializeBall() {
8 t" H1 }4 d% k& e   if (document.all) {4 Z) s' d, w* E. B
      xMax = document.body.clientWidth# e8 F1 h8 H2 u! G% k) S' Z
      yMax = document.body.clientHeight, x# p3 J) g3 P$ f+ j; O
      document.all("supertext").style.visibility = "visible";8 k* q8 `/ w& d- s$ ^
      contentWidth=supertext.offsetWidth
9 J6 ]0 u% a: Y( A) L7 |      contentHeight=supertext.offsetHeight9 c& y4 J2 F5 ^7 \5 s$ Q
      }
; \7 e$ A( t/ v! `9 B: u   else if (document.layers) {& G6 R4 u  A& z# p" z2 z
      xMax = window.innerWidth;
- |& _: E! o1 m1 r0 b$ J: v      yMax = window.innerHeight;
8 P; M5 ]' v, J& ^0 G0 ^      contentWidth=document.supertext.document.width
* G8 M9 A" O1 z! u; l6 g4 Z. z      contentHeight=document.supertext.document.height# G+ `& n4 g, K. m' c
      document.layers["supertext"].visibility = "show";4 [0 E" w, [! c2 _, w7 ^
      }- @+ M6 E2 h! X& e
   setTimeout('moveBall()',400);1 h" a9 c: G& B! h! u
   if (hidetimer!='')0 q8 N. P& w: J( ]( T5 t; V7 R# [* e
   setTimeout("hidetext()",hidetimer)
* x) k) z( V4 r# V   }
9 f1 \- A# i/ Z$ B' e2 S7 x
! i  W5 o" r' Pfunction moveBall() {- o* v( m: v% A7 S! R. _
   if (superballRunning == true) {  o% f& \7 \) [3 L7 H
      calculatePosition();
5 R5 R1 f, _: ]$ m9 {7 s      if (document.all) {1 W% W9 ~! f+ B8 [; ~: S
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; l# @7 \" g4 ^( T$ T- i, z         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 t0 Y9 w7 d  T         }/ [6 l1 n: b  v
      else if (document.layers) {1 m! S) g) C3 R4 e9 U% V
         document.layers["supertext"].left = xPos + pageXOffset;
" U# Z9 Y. r% U. L         document.layers["supertext"].top = yPos + pageYOffset;( h2 W# P+ D$ k; t! z/ x
         }* x3 ?) W9 ^* h4 ~8 P4 r
      animatetext=setTimeout('moveBall()',20);* t% x% i  |  i, Q0 p0 I. t5 Q+ |+ A
      }4 F' `+ u* m9 x6 P; ^0 Z* O( X, {2 p
   }; a  y) S4 A" ]( R* }

) E' }/ z- A. B4 ~function calculatePosition() {
/ ]* ?5 P. A. i6 z  y" Y; s6 r   if (xDir == "right") {! N" A; W- {, ^9 d0 d$ t9 }
      if (xPos > (xMax - contentWidth - BallSpeed)) {
; v$ ?! J  ?( @         xDir = "left";
. L" m6 D3 V! g6 H# p- W         }  K! l$ e/ j& n) q7 W, `
      }
& b& l+ R) g+ m& f# Y- r/ U3 s. y   else if (xDir == "left") {
  \' [* ~& V7 @7 ?6 z      if (xPos < (0 + BallSpeed)) {0 h& j0 }1 ~3 m3 i' a6 h
         xDir = "right";5 r6 d6 P+ G2 X! U, `
         }8 Y* e% f3 {2 |
      }
7 {& g- p  i" y3 @5 W! ~   if (yDir == "down") {6 }! Q2 H* y; A* j% g* c% ^2 p% H
      if (yPos > (yMax - contentHeight - BallSpeed)) {& Q8 D# F, w8 R$ V7 }: B) u& f
         yDir = "up";
, h2 C* A; s' G% Z. Y5 j         }& F  X& y' X- J" q# I! o. o
      }' i' Q5 e. T4 U5 m; N& D
   else if (yDir == "up") {: W- ]8 G& P" H' I2 O
      if (yPos < (0 + BallSpeed)) {8 _, a* Z& G0 D2 I" C$ D
         yDir = "down";
, z; W7 w$ t. y$ U$ X3 q$ G$ O         }
% g, N* i" m3 H  i      }
$ N' [5 Q2 u: U. ]9 `   if (xDir == "right") {4 m% i) b* ~) W) ^1 u! u
      xPos = xPos + BallSpeed;, C0 G  D3 O" J* w$ H3 S1 I9 d/ n% x
      }
. t* y" K0 s3 ?: c  \% G7 e/ [+ ^   else if (xDir == "left") {3 K3 i7 Y, k* x/ s9 o# Q
      xPos = xPos - BallSpeed;
1 G0 H* v) ?/ d: z0 w8 r      }
- @7 d5 y* g1 s+ T   else {
9 m4 x5 ?7 r- N* X; ^. @" c      xPos = xPos;8 E4 e8 B3 z8 y  [4 k! S. r
      }
  y/ H1 i9 A* S. N   if (yDir == "down") {
4 y8 G' T4 ?7 v* |/ d8 r# w1 M/ t      yPos = yPos + BallSpeed;
: D' X, [1 ~; B' ?      }! H8 A* E& n/ i5 }! |1 j+ ~
   else if (yDir == "up") {( N1 K9 k4 F; v" f$ J9 i/ A/ O  K
      yPos = yPos - BallSpeed;  c& `* t' R+ G2 o
      }( a% ^8 l, H% y( M1 z4 @3 P
   else {
2 @" w# |: d2 D# _0 J- D7 S      yPos = yPos;7 }6 S9 h$ ?% x/ f5 S  X# Q
      }
' w$ f) I7 t. P$ u   }
# _0 y9 E; B7 c' M% e5 a/ U. S* {2 t. {. J4 ]3 P
function hidetext(){
$ O& I& [1 @( m# `6 R9 T0 Dif (document.all). {' D3 Y% ^$ W! M, h7 W9 I$ F2 {. ^
supertext.style.visibility="hidden"2 a, M9 R% ~% P. t
else if (document.layers)
5 }: f% K7 b0 ?4 R. {0 m. Tdocument.supertext.visibility="hide"
! ]  a, A7 {! W& S1 dclearTimeout(animatetext)
! S7 R1 p  Q3 u1 f}$ E, @* t% Y9 ~/ ]$ w

$ E) g* z# l1 h1 t: a7 J$ Dif (document.all||document.layers){
# [% t, h/ F7 h# R# w: W1 ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): M% m( c4 R1 W2 B5 z, P
window.onload = initializeBall;
1 C# Y( P$ G7 O" ^7 |# mwindow.onresize = new Function("window.location.reload()");
9 q+ ?9 p; j5 V: a: z}. V1 t( j; v2 {6 {
: K5 k& q) O% z$ p) k
</script>

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