返回列表 发帖

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

<style type="text/css">. t+ P6 Q5 H9 w, N
#supertext {
& `% j) G. n$ \, c: f. u; Oposition:absolute;1 X& U. r8 g3 ~: X
left:0;
! X- Q6 U5 r; j+ u  E4 U( I- C9 Ytop:0;3 s+ L4 V' r# C7 t+ {$ Y, O
visibility:hide;7 _' t5 {/ l! [/ a8 Q8 ?7 q
visibility:hidden;7 Z7 q" v& D, v$ u1 c: t7 v2 F
}
9 R# k0 n! F. M2 X' n% [% D</style>
5 o  i& u! g1 O) C<script language="JavaScript1.2">
3 b: \8 p, j$ n+ P8 m6 \( @<!-- 改变下的字体的大小。颜色-->1 @( t% F! q8 _4 U& |* h7 P+ z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
+ A, t  X$ V8 t, ], I# h, c! [var hidetimer='';
+ ~1 U1 t. k' n. z: J<!-- 改变下的弹跳速度-->, `0 \9 s3 n3 v5 N
var BallSpeed = 20;% s* `1 \0 A0 `1 P
var contentWidth;
$ b5 ~6 \& W7 A4 I! ^- Avar contentHeight;
. f+ F2 a) j1 \+ P3 b# {var maxBallSpeed = 50;
# u& V6 p9 w. U. Y* w1 F4 d, H
: y2 o' ~0 Y6 R2 A3 p" B6 L) V2 ^9 Z2 v$ b4 E9 w5 q; ^, X
var xMax;* O0 x2 D( H+ q: R5 Z/ U+ H( J5 v$ d
var yMax;: R: C; D, F  Y& A0 R$ V7 P4 L
var xPos = 0;9 h2 u& L8 ?0 m- |
var yPos = 0;& j7 t7 x1 y: y7 B  C
var xDir = 'right';
% u+ a' D! x) p, k) u+ x6 `var yDir = 'down';5 l# W; y0 h3 O# B6 g; d
var superballRunning = true;
) D( f1 Z+ M, T$ cvar tempBallSpeed;
( c9 D) a5 X; d4 U; l8 {% [1 b. ?4 e. Fvar currentBallSrc;
4 R" J' J" e+ `" kvar newXDir;
2 @* \( u& ?1 k, @4 _# R8 ^var newYDir;
+ Y# M' G. O& T3 A5 r% q
* Z4 O' }" D) Z  a( Xfunction initializeBall() {
" W9 V& d6 i$ |- ~: a% {- [- T. W   if (document.all) {5 H5 h6 H( D* ~$ {
      xMax = document.body.clientWidth8 a& [/ {) A' }- U. j
      yMax = document.body.clientHeight
6 e# O7 a) }$ O) L. y; I* x      document.all("supertext").style.visibility = "visible";
6 \4 {5 a/ p) c# b      contentWidth=supertext.offsetWidth
+ B; k: [$ j; n8 Q      contentHeight=supertext.offsetHeight2 r# B2 O! |8 u" z+ G4 u& V
      }9 Q* I& j1 Z2 O7 J- Q7 i6 K2 o
   else if (document.layers) {4 `: w0 s  p. z" B
      xMax = window.innerWidth;2 _8 j7 z8 ]/ e- m! m8 ?
      yMax = window.innerHeight;
' C$ V0 v7 N4 P  p& m0 O& l& L* K      contentWidth=document.supertext.document.width7 d3 f  h+ W" N
      contentHeight=document.supertext.document.height5 c7 w1 b1 ?  m( v
      document.layers["supertext"].visibility = "show";
! ?" V( H, F  I/ v7 _7 f      }1 E# C0 ~" |, N. i9 x) e
   setTimeout('moveBall()',400);, P. P+ N. `" e- Y5 V( V
   if (hidetimer!='')& i& |7 X6 y; m5 G0 A: f# c: a  o
   setTimeout("hidetext()",hidetimer)
# l: E$ ~! d; Z   }
+ k9 K3 _$ e2 J3 {
- ]7 a# z" K) e( q# Vfunction moveBall() {
$ N) H  Y6 P" E" _   if (superballRunning == true) {
# f' v, x9 n: e  z      calculatePosition();
0 G' R5 K9 {: N8 {3 }      if (document.all) {
$ ?5 V" X1 O0 X# D% [' A         document.all("supertext").style.left = xPos + document.body.scrollLeft;
' }4 @  E3 V) t( X         document.all("supertext").style.top = yPos + document.body.scrollTop;, S' K! Y* k9 J1 T7 b, G
         }
- q9 g6 `# |" F0 c& A      else if (document.layers) {
. ?* `) m  h4 ]6 \         document.layers["supertext"].left = xPos + pageXOffset;# y' U. r4 z/ N9 {3 T/ g
         document.layers["supertext"].top = yPos + pageYOffset;) c, o. c5 K& C: B0 g1 J
         }6 G5 Z) F$ {( M( Q
      animatetext=setTimeout('moveBall()',20);' o" R  v2 w, ^, A2 X% p
      }7 O$ G; {* Y0 |+ b! S2 X
   }
5 L0 ~. l" M% i# O$ C4 |, X' o* K3 V
function calculatePosition() {
8 h& w& a; r+ [% [" ~5 o0 L   if (xDir == "right") {
+ r  \( D$ R1 u' o0 i# Z6 A% v      if (xPos > (xMax - contentWidth - BallSpeed)) {9 ~* e" }: G0 ~3 }
         xDir = "left";9 p& O$ m. H1 d3 Z% G1 _- a% E
         }# j6 e, @6 v/ j4 s' d$ F& S# s+ i/ a
      }( G  A0 R  ~: i9 k6 h- n
   else if (xDir == "left") {4 [- _) Q- v, G: v
      if (xPos < (0 + BallSpeed)) {2 a7 W9 V- ]' O* R' e
         xDir = "right";
; ]! y' U5 x2 S- G9 T2 }         }% A7 d. \! X4 |, q9 s) p# P# @
      }7 o! G, i& \9 x, o" a3 m
   if (yDir == "down") {2 W) ~9 J: Y1 [  s- t' s
      if (yPos > (yMax - contentHeight - BallSpeed)) {+ S0 }! C0 G4 e; v8 N4 Y, S1 k
         yDir = "up";' s, i( e2 \+ E+ |
         }
% C% O  [% w! U7 y! G      }
8 \+ j# h; S) I# a6 i" n% q1 [7 w   else if (yDir == "up") {$ E2 X$ ?+ R* \* k
      if (yPos < (0 + BallSpeed)) {8 L' m/ d; q; ^5 P- V
         yDir = "down";
$ w' \3 ]/ `% d# ], j' }         }
8 J4 l- \# I# ]& _      }
1 Y5 z" h* d9 H) z% _  v0 @5 Y" D   if (xDir == "right") {
: n, ?/ u  K" Q+ q6 o( p$ T) W      xPos = xPos + BallSpeed;! p) _# Z. x4 U. `+ v# f5 L% u
      }
, ?- ]2 A8 v! S! h* F' d   else if (xDir == "left") {7 X6 E4 ?; ^( c1 w  d; g' Y
      xPos = xPos - BallSpeed;
0 y3 g5 j8 W" ^3 `      }% k5 W7 S! A) C6 l5 T: [, B
   else {& T$ |1 l2 g# S6 F5 o
      xPos = xPos;5 _# m  ?* m% F% u- f6 t& R
      }  m$ W. ^8 ]; V" E" _# c5 V. e% F
   if (yDir == "down") {1 E; p1 t8 y7 P( W2 L
      yPos = yPos + BallSpeed;
" b1 s9 c; r( s, O  u. n      }
6 E) G0 r' a5 J# K4 |& A- h   else if (yDir == "up") {  V" W& K1 |& p1 T
      yPos = yPos - BallSpeed;
& s3 n. K7 ]$ C# j. K0 p, e# D' A      }
3 z# n5 o( h1 B; `   else {
; E5 A) m* r3 M4 w$ t3 c0 S! p% @* W5 W      yPos = yPos;
- r/ A& g1 u5 n$ [2 d5 G      }9 b1 ~5 K. l" A  y! u. S
   }7 M( A6 a# K, V/ s8 {) [) I% f
( F7 {7 v! J+ R6 F/ A
function hidetext(){5 [& |- a6 N) W' R
if (document.all)/ ^6 x. @) C$ p9 a
supertext.style.visibility="hidden"6 T. K. _- |+ q0 ?$ j6 y
else if (document.layers); ~& R8 d6 M$ {9 `! L4 W
document.supertext.visibility="hide"
- y. Z  }8 O% g, Q. PclearTimeout(animatetext)7 \# L$ \- f) |% g. P) \4 s
}4 i7 q1 l* S; P5 Y8 N/ d! X
" o! o9 n3 \6 Q" {# H' v3 \" C
if (document.all||document.layers){
( \7 U" p& x& G* v! ]document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 O3 s1 a: x' {7 C( ?
window.onload = initializeBall;
/ a7 m+ o, X/ ^9 W3 t" Mwindow.onresize = new Function("window.location.reload()");
, ?+ p4 V0 x& {}
/ H5 }2 p( ^# T- g
! W9 M9 B/ W( B- [</script>

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