获得本站免费赞助空间请点这里
返回列表 发帖

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

<style type="text/css">
# Z7 C* {9 L5 _2 r#supertext {
3 f% v# S; I! X, j3 v1 u0 t9 Gposition:absolute;+ p  `3 z' s) _+ @: I1 z6 R" r; I
left:0;" V# w' I1 u$ O* K0 x
top:0;/ U& L; a; h$ X2 S* o
visibility:hide;
% U4 l* c7 ~  D9 u$ k8 F+ ovisibility:hidden;# b7 p/ Y. v7 j9 I  A0 l
}
# v- R( j; g' z</style>
% y/ l4 G/ I" R<script language="JavaScript1.2">
+ n# c* c& Q. ?, n0 @<!-- 改变下的字体的大小。颜色-->
9 _7 v7 D" b/ O( S+ ~var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 [8 @( H( A# K$ zvar hidetimer='';5 n9 n7 F/ F/ i& i
<!-- 改变下的弹跳速度-->* d" F* d" j& ]' A% M8 T5 [: q/ I
var BallSpeed = 20;) \  e' r* ?  S9 |2 Q3 Y
var contentWidth;
  a! T1 X( M+ N' t1 c0 Z6 W' evar contentHeight;
1 X; `# K! [7 A/ H4 U+ g# G2 Kvar maxBallSpeed = 50;7 x* [  _: X/ n7 J7 d
7 [2 [. D$ k2 L0 N. O& J

* M& O4 d' Z& N# k9 f' j+ Fvar xMax;" r. l1 U' z5 ^8 n( c2 U8 C: Y
var yMax;' w, M4 ]2 P6 b
var xPos = 0;+ B/ N( k4 c& l; g: \7 V$ E
var yPos = 0;
$ \8 Z; K: z4 ^: [4 Cvar xDir = 'right';
  ?1 D  J2 j/ l, }4 wvar yDir = 'down';, r. b$ o, ^. b8 U
var superballRunning = true;9 P6 L# I! |' Z9 ~
var tempBallSpeed;
4 @# F! u4 O  `$ i1 Y" Rvar currentBallSrc;
* |$ Y/ I5 w. K. ]var newXDir;$ V, @. @/ I6 X8 J6 C$ Y" r
var newYDir;# V3 `% E' W& W8 t6 C. p# ?0 Z
+ V* S/ \1 g+ y2 [
function initializeBall() {
& i. H+ g! [' p) Y   if (document.all) {8 y+ I& d" e1 t1 X" H9 C
      xMax = document.body.clientWidth
/ a. |1 p  b1 {" D/ H/ Q/ p5 r) G# N      yMax = document.body.clientHeight) G2 V8 N' M2 p$ L& U. l; g7 ^
      document.all("supertext").style.visibility = "visible";
) e& G5 x% O0 {$ u, x/ _      contentWidth=supertext.offsetWidth
4 D# V( V* E) t1 G% s1 Q! l      contentHeight=supertext.offsetHeight
7 I# |0 Q+ B: u      }, L$ ~! _2 b. H1 l
   else if (document.layers) {$ v& b: W% `' l! G- y8 D9 H" c3 z
      xMax = window.innerWidth;
  f2 x8 t9 Y" y; j) b) x9 R& L: a! E      yMax = window.innerHeight;
$ ^" q9 @  @+ R7 e      contentWidth=document.supertext.document.width
) ?# u, O& T6 y      contentHeight=document.supertext.document.height
! ]# {6 B% p0 \" W) [+ `7 K      document.layers["supertext"].visibility = "show";
4 V9 X1 {# h( x, X  c) W      }
% Q9 m) _1 x6 Q: E& \( P   setTimeout('moveBall()',400);$ y/ R( X7 x" Y' n% y( X' E3 S
   if (hidetimer!='')% T& M' v9 x8 ?- x) o, a
   setTimeout("hidetext()",hidetimer)
. I. m" y7 U) Z3 |8 E3 t7 v   }
9 Q. B' _4 L6 g" `
9 l  z  _% N* V. \! p& e3 F/ v1 @function moveBall() {
  K& W6 r1 ~- b) m# W4 v   if (superballRunning == true) {
4 @  r2 q& {! A" z      calculatePosition();
% _# t; O4 _: V% I" d      if (document.all) {
. b5 W# B+ o! M- ^. i3 I         document.all("supertext").style.left = xPos + document.body.scrollLeft;
# M9 [8 H4 ?* V) P' _7 D- t4 M         document.all("supertext").style.top = yPos + document.body.scrollTop;
6 A: K* W0 o  z2 J4 m& Z         }
* f$ F* X% c8 z      else if (document.layers) {
  r0 `% X( Q, M3 u- n' [         document.layers["supertext"].left = xPos + pageXOffset;; o: _. c& j3 _) x+ ?
         document.layers["supertext"].top = yPos + pageYOffset;
- G- q  `1 x4 G/ C         }
4 F  g4 U6 [  M  v7 t# k! D+ f      animatetext=setTimeout('moveBall()',20);
' v6 ^/ c) f6 t      }$ ?4 [5 H7 L2 Y5 }% X: t
   }$ ?2 n. a1 s3 y5 x+ a
- Q  X. i- j, x6 d; {8 x+ L
function calculatePosition() {
7 O" h- C- c" k# @. s   if (xDir == "right") {& y3 b) ~( D( s0 y1 {
      if (xPos > (xMax - contentWidth - BallSpeed)) {; x' H$ [6 \# u5 T3 |
         xDir = "left";
  Y* {1 ]  @1 Q/ i  B6 D. ~         }
; |# H( ~9 g* [3 z( S4 X$ r      }
+ T5 o$ ~( n  W* C/ ?3 z5 z' F1 \   else if (xDir == "left") {, R( u) U  F7 o2 J
      if (xPos < (0 + BallSpeed)) {$ e. o2 s/ ^0 _- Y# `- e! _9 t3 P
         xDir = "right";
, t9 s1 L$ f: `         }
: Z0 J- o% r& e      }5 P% ~+ r# l- \* \) T$ _/ k/ z/ o9 ^
   if (yDir == "down") {9 q7 \+ w% V/ h8 G& o) \
      if (yPos > (yMax - contentHeight - BallSpeed)) {
% g8 x- F2 k) v7 j         yDir = "up";8 S  R1 b& T" c- i4 L7 j/ \
         }
1 _6 i4 u; q. a5 |* e6 H0 ]      }0 g4 h% @% X, L+ r8 `5 h+ Y
   else if (yDir == "up") {# d; z' [& l: l! w
      if (yPos < (0 + BallSpeed)) {, Z8 [; B$ h0 D6 K& q) Y$ r
         yDir = "down";7 S/ R/ g9 G# O7 C  N& D0 d+ `3 V2 X$ A
         }; E0 \( r6 f7 ^( L" [5 ?& t  X
      }; |6 u* X' d& m6 x. }7 o
   if (xDir == "right") {
/ c1 u( Y3 n( D      xPos = xPos + BallSpeed;' [' t) u8 I0 l$ x0 n8 o* }5 o
      }
: F! {% c5 j6 G1 }7 Z   else if (xDir == "left") {! k5 h7 g3 A4 n+ H' s
      xPos = xPos - BallSpeed;
% k% s7 K2 }: p- \      }+ x& |; C. D6 A* b
   else {5 r' a2 @2 F9 ?/ c6 [( p: I
      xPos = xPos;
' L7 a2 }  b$ b! `) t      }
7 w; H2 ?8 d# }7 z   if (yDir == "down") {, P! F" s$ _5 ?. i
      yPos = yPos + BallSpeed;9 G3 _5 }* ?+ J: b. \! E
      }
% d. b9 [9 N% b  k7 N* d# B. |   else if (yDir == "up") {  l: d  }, D% e  a8 z) a
      yPos = yPos - BallSpeed;, q3 _! H  {. {" {& D
      }  w) t& @6 r' u- u- |) |. T9 y
   else {. W0 v2 q7 P! k! x1 m
      yPos = yPos;  {+ k- S  S  t5 }8 J9 Y
      }0 ~" P& Z: H/ \# Y  X% X1 z
   }/ F* V/ V* a1 ~$ h4 ?
9 s# L' j  ?& L. S, U# F
function hidetext(){" l# y, l% [( s% Z
if (document.all). ]7 K; p$ ^3 A7 r
supertext.style.visibility="hidden"
0 I" h' k  v( M9 l+ G: r! qelse if (document.layers)( ?7 s4 T. _! I& P- G8 {/ t! |
document.supertext.visibility="hide"
" @& n/ j. @7 H/ U1 t5 d! ^0 O7 rclearTimeout(animatetext)
# N2 D8 m9 m2 f) Q  I# Q8 t}- ^" x; G9 S* r$ f) l  ~

- J& I$ j7 h# |- _: Vif (document.all||document.layers){, M1 P: X# `+ c" ?! a+ u
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 p3 L5 b3 {! Z/ N
window.onload = initializeBall;
" a: c) O5 @- R& C/ O7 jwindow.onresize = new Function("window.location.reload()");9 I; c5 q! P: h3 m$ B9 t! {
}
# X+ n3 Q" V: D3 y! H1 _1 P
7 T+ h( k" E7 b4 p; W</script>

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