返回列表 发帖

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

<style type="text/css">4 r- f. `# @8 J- `
#supertext {
- \1 q* s' E5 E1 Iposition:absolute;
* I; r( p9 e1 t* u! pleft:0;* I% \+ C7 l* A6 v
top:0;
1 ]% X# z  z6 P; `# o/ K7 tvisibility:hide;
, p- a$ V  M2 Q! Zvisibility:hidden;
3 \1 O) {. H/ Q. a3 `}+ a/ @' x2 m( x- y0 z
</style>/ ~8 G$ J3 V; V# C2 H- R& e+ `
<script language="JavaScript1.2">
6 X8 H1 T$ l7 j0 S0 W$ U: Y, N4 n<!-- 改变下的字体的大小。颜色-->7 z" n3 t; @8 e+ p  {4 a, w7 s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& A4 q1 [& g: v( W4 M$ Nvar hidetimer='';7 c0 i- K/ @  E0 P3 l6 P9 b3 W
<!-- 改变下的弹跳速度-->
8 u4 u" y, W* Z% |& \5 L) M0 l! [var BallSpeed = 20;
6 v# c5 j; W, L3 p- Vvar contentWidth;4 Y: H' j& x/ o1 u* T; C4 g
var contentHeight;- X( u) }6 x) b8 `
var maxBallSpeed = 50;
8 q) h+ m' t& M$ t) |- R; S2 W& A. U; m2 K" Z6 g5 N( K

" ?4 ]- M3 |) k! p  v4 S& F& Pvar xMax;5 V# Z! J, h1 R+ v$ `: T! B
var yMax;
9 {& P, [3 [% N6 S% ivar xPos = 0;) e+ |* i1 W% ~* e
var yPos = 0;, D+ k) r$ X5 c0 `' c) I
var xDir = 'right';
# B, ^* Y8 h& H7 t+ ovar yDir = 'down';
" j- ?$ b  g' V% evar superballRunning = true;, |+ D9 E% q. S% V* [5 w
var tempBallSpeed;% k* T: O; w" v# X! i, x  _
var currentBallSrc;* Q1 H% e, M& H& |% Y
var newXDir;: T$ y# i. [; X- Z7 D1 e
var newYDir;
% E9 W7 r' M, ?/ {* `$ C- [
; {$ z+ Z! x2 z. e: _; Z4 t$ wfunction initializeBall() {
3 l; T% [* m' @  w1 S! r2 f   if (document.all) {; N1 \: P0 h0 k/ w$ n3 s$ ~; e
      xMax = document.body.clientWidth
' N/ S1 w" `% O7 _  N      yMax = document.body.clientHeight
0 J  M/ P# U0 A" @6 P+ B( h/ U      document.all("supertext").style.visibility = "visible";6 v" a2 S0 z4 O0 T. B1 V
      contentWidth=supertext.offsetWidth) p. n1 ^% n7 ?8 d3 {' M
      contentHeight=supertext.offsetHeight- E( z8 M. H7 N) U
      }# D( C- V0 G6 o4 @5 ]+ y2 n" X' n
   else if (document.layers) {4 L9 m) V  I( w+ H# Q
      xMax = window.innerWidth;
- o" _+ j, i+ R  @) d* e4 Y7 |( f      yMax = window.innerHeight;/ r8 `- Q% r. T& C% |9 [. @
      contentWidth=document.supertext.document.width& m: P% o  f0 r' {+ l
      contentHeight=document.supertext.document.height
" S. \0 p6 L9 o% m2 l      document.layers["supertext"].visibility = "show";
' a/ c; z0 @2 i" U8 s5 L$ L/ e7 N      }
- _' d6 x+ S% w, w6 V% U& M: h   setTimeout('moveBall()',400);7 z/ g5 v0 Z3 ^6 s$ R# \$ Z% l
   if (hidetimer!='')/ N3 {( j/ r4 O) p1 q
   setTimeout("hidetext()",hidetimer)
1 P6 f0 f4 K; d! f; [   }
$ G# r) S. w& y: a5 c$ q/ l  r$ a1 `: S& e4 y/ l% q
function moveBall() {
4 |$ g& r$ X4 o1 l   if (superballRunning == true) {
3 f$ C% _9 g( V# \1 [6 f& w& Z, {      calculatePosition();" V! g* q! |1 N3 P5 }
      if (document.all) {; A& H: Z# r4 x0 i5 [) N: ^, [
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
8 I3 h" G$ p+ x; k         document.all("supertext").style.top = yPos + document.body.scrollTop;
% {- S% q) x+ Z4 ^/ `+ w- @( c         }, @, ?* n4 B' P/ H
      else if (document.layers) {
# {, L# Q+ I5 [7 B# T6 \         document.layers["supertext"].left = xPos + pageXOffset;0 h, y1 [- w- [# B
         document.layers["supertext"].top = yPos + pageYOffset;
1 [  t1 c( E# F/ E: Y( S1 ?         }1 T' U" a# K6 G3 H- o; Z0 ~
      animatetext=setTimeout('moveBall()',20);  ?2 F# `, y  x7 t9 y
      }
9 g' d1 z& A9 ^  X# q, l   }
4 y! u3 c' z- X8 J$ o: ^7 ]) s  E  y1 H4 a8 F
function calculatePosition() {
* v5 [/ m6 ?( |: a5 X4 j) U   if (xDir == "right") {
" ^  Y' o- d4 d9 X" b. K: Y. r      if (xPos > (xMax - contentWidth - BallSpeed)) {1 F$ D# O1 l% B% `% J3 K, {) s
         xDir = "left";
" ^& h, t& N! X3 [9 }4 Z; U         }
( U: G/ l- |' S) e9 b$ S      }& ~" r* ~& Y$ d) f' s; h" W
   else if (xDir == "left") {5 f% i$ f# H2 |5 v: ?
      if (xPos < (0 + BallSpeed)) {/ E7 a1 Z3 v! y+ M
         xDir = "right";/ J7 L" ~: H' m0 ~7 p
         }
, R- U$ Q1 a" g- J      }8 I/ I! D& a6 R  R  Q6 k
   if (yDir == "down") {
3 m& k- q: D3 K6 n( \( I3 a      if (yPos > (yMax - contentHeight - BallSpeed)) {: v+ K0 ]3 R& u* ^, X; S. z
         yDir = "up";
8 a# l' R4 Y- ^2 P         }
/ C% `# U' f+ S% p      }
6 @8 K' T) f; D. s$ k3 i   else if (yDir == "up") {1 ?7 U6 x9 a! U$ `) r4 W
      if (yPos < (0 + BallSpeed)) {
; {" R6 u& h: r' E         yDir = "down";5 p# l  p% |/ R4 y2 Q8 |
         }' Y# ~$ P* P, J1 h
      }
9 Z) q4 ^( ~5 s3 w1 R; Z7 z# C   if (xDir == "right") {7 N: l# E8 x& S5 \6 k5 Y. J' d$ \
      xPos = xPos + BallSpeed;
- h. ^6 t7 d1 V4 U2 C, ^      }
, b4 g* l: x$ c   else if (xDir == "left") {
' M  M5 ^: W2 f7 K7 `0 S      xPos = xPos - BallSpeed;
+ @6 h. m" L; Z9 Z$ I5 h% M* y# ?      }2 _! {5 ]' p2 o1 x0 w
   else {7 c8 }& i2 y5 W3 W  W0 [; {8 S
      xPos = xPos;
3 h4 l- p2 W+ R      }' Z# M( a. M  I: L4 h) w
   if (yDir == "down") {% `; I& l' H9 l
      yPos = yPos + BallSpeed;% t) [3 k. X0 ^! Y, ~
      }
) Y! e# Q8 F7 |+ R. ?: I! _   else if (yDir == "up") {, o* n9 e2 g0 |7 N% l
      yPos = yPos - BallSpeed;* K. d5 `& a  F) ]% w/ a) O
      }2 o# \9 P9 J5 p
   else {
& z) Z  @& w6 c9 |; c+ [( I      yPos = yPos;5 |' M3 b  G% @
      }# i4 c6 b" t/ ]* b  ~' p3 H
   }3 ?% T; L0 R( U+ t0 ?

5 s' m2 R# q* n( y9 s: {function hidetext(){
/ r, c4 r# ]/ S9 m* Pif (document.all)
% h$ O7 y: Z6 ]; `9 isupertext.style.visibility="hidden"9 A5 [! B& Z6 t
else if (document.layers)! `2 x2 y5 W. C! p! U' ?
document.supertext.visibility="hide"
* i* J9 h- f  E1 p& ?8 i& `0 ~- wclearTimeout(animatetext)
% `) y' J9 P+ K$ ?}
* X% b, b1 i! n; ?/ q0 I3 e
, D! `4 ^- D, x$ p4 p3 B5 a+ aif (document.all||document.layers){
7 T% A& ^! h7 W3 ?/ {# Gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" K6 M/ K+ ]) Twindow.onload = initializeBall;
$ K0 E5 c! a6 ~$ n2 Swindow.onresize = new Function("window.location.reload()");7 E, F0 ^4 _4 _( E% Z( N
}3 {( N$ P2 K4 h* G6 j5 V
5 Z6 A* Z% H, a8 N9 e
</script>

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