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

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

<style type="text/css"># v3 v* Y( K$ ]  Y+ g. a, d
#supertext {
& U8 B6 n. d% _position:absolute;
4 T# r0 {$ m( m: l0 Wleft:0;
  p- |0 X1 e/ o/ o4 ntop:0;
  {0 |' I) E5 kvisibility:hide;# n. T, \0 i) }0 ?
visibility:hidden;- i# H, J8 T2 g: N
}) L; `4 U0 A  G4 B
</style>
- X4 _( a/ M6 B( O+ b/ B<script language="JavaScript1.2">9 i' P2 P( i3 h
<!-- 改变下的字体的大小。颜色-->
4 n3 s1 s& R, z/ ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
; v+ j' M) w) O/ C0 u* Cvar hidetimer='';
. j: `1 k, ~7 x* }, [% H<!-- 改变下的弹跳速度-->5 |/ e: r4 |1 Y
var BallSpeed = 20;
( T4 m+ P3 A. e5 o" ]var contentWidth;8 M* F" B% a& T6 _% [% _
var contentHeight;
% C' p$ n  c' p  e/ K* N4 evar maxBallSpeed = 50;) E" }5 `8 X5 }) ~2 T) d) m

: U, L- m$ e3 Q! {$ R% Q3 t/ E2 x$ f& X7 S* f
var xMax;
) b  O6 i+ [1 G1 z8 a. jvar yMax;
1 S9 l# @$ X  ^" p+ ?; svar xPos = 0;6 S& Y0 ~, W+ X+ ]# Y* b
var yPos = 0;
4 ?# [1 N, G+ ~  K2 Jvar xDir = 'right';" R5 c; J* F0 X/ U* J
var yDir = 'down';( X0 x$ P$ r; W' ]; z
var superballRunning = true;
, Y, o1 ], k% w: `7 W9 I7 {var tempBallSpeed;
% @& L% |+ Z6 J% {var currentBallSrc;
2 j5 v: B) [! [0 b: z& |var newXDir;
9 ^# N6 r% A$ x$ mvar newYDir;
! g  T/ g. a$ F$ b( A, x% y' ^- k8 u$ _+ c
function initializeBall() {
( u* K2 N8 r# M) h1 Z   if (document.all) {; @- F* L- w7 S" J+ ^) W
      xMax = document.body.clientWidth
) W  m7 K' a) ?& j" x: @      yMax = document.body.clientHeight5 r" Z$ W! S7 j" p8 n/ X
      document.all("supertext").style.visibility = "visible";
+ y1 ~* r1 ?2 ~, W- \7 k2 S/ L% l& V      contentWidth=supertext.offsetWidth
, O1 y. K. O- |" c  V+ R! P      contentHeight=supertext.offsetHeight
, f& r1 m4 x8 |$ S- }: i      }- K8 S2 k: ~% l# s( P( d- F- j+ L
   else if (document.layers) {/ V: q$ y" ^3 S; n/ D8 L; d. ?) {) P' }
      xMax = window.innerWidth;
$ |% u) e( u6 `& F8 u9 M5 m      yMax = window.innerHeight;: @$ B/ g# {7 t) Y0 |0 a
      contentWidth=document.supertext.document.width
; e0 r& T) O6 d8 I! x5 N      contentHeight=document.supertext.document.height/ _6 [4 V  S0 @
      document.layers["supertext"].visibility = "show";6 m, L- V4 q+ l+ o/ l  y- W
      }
& K: [0 M4 m, l+ S% I   setTimeout('moveBall()',400);
/ p- U+ Q- @$ c3 A+ @% V6 a9 L   if (hidetimer!=''); z! M6 F; A5 a( T6 N( T
   setTimeout("hidetext()",hidetimer)
* c6 u) O; A, Z- ?6 f   }
0 o' ~4 f% e9 }  D0 f& [: G6 o% _( R: J3 C+ T; A
function moveBall() {
/ j( t1 U. {; r. w   if (superballRunning == true) {
  d" e% F7 X# Q7 b$ h' T      calculatePosition();. G7 \9 t' ~. n& H2 N
      if (document.all) {
5 X# T: B0 ]$ P$ q/ e0 r9 q# e" b         document.all("supertext").style.left = xPos + document.body.scrollLeft;& V4 V. C1 s: T) T
         document.all("supertext").style.top = yPos + document.body.scrollTop;
4 r- d+ M  p9 J         }
& V9 U, r4 I! \. }1 J8 |7 R      else if (document.layers) {
: h9 U5 i, u  u! K9 q         document.layers["supertext"].left = xPos + pageXOffset;) }1 A9 Q/ X% J" Y) S2 U* Z" {
         document.layers["supertext"].top = yPos + pageYOffset;
+ ]' L; \/ P7 D         }" L0 A6 w, Y- E( y7 H
      animatetext=setTimeout('moveBall()',20);6 ^/ S7 T$ T& P3 m& V, F2 _* Z* X
      }& ?. k0 ?# R& P* C8 X& \
   }4 j, I  Q2 i2 F

  k- R4 U5 E: G# i- ?. n2 Ffunction calculatePosition() {
1 j2 D4 L) c+ F, H, k1 L   if (xDir == "right") {
( ~* ~, y5 c$ A3 o      if (xPos > (xMax - contentWidth - BallSpeed)) {
+ f7 K5 e: J+ w1 K2 y+ q2 q         xDir = "left";
) S8 \, s# _! p* \+ H& A         }
0 G0 P8 M% F% E      }5 B& \0 j$ |$ s2 E/ Q
   else if (xDir == "left") {6 e; |: R3 J" L; ~! \5 w  D" W
      if (xPos < (0 + BallSpeed)) {
1 f, f) r- f+ g) H         xDir = "right";
+ v0 K, Z0 {5 G$ C% n  H" O  M$ m" P         }; i. ~7 H- R/ f1 ]. E
      }, A5 y; N& _4 I7 z
   if (yDir == "down") {9 N# S5 r3 q$ `
      if (yPos > (yMax - contentHeight - BallSpeed)) {
0 _& F7 T6 `7 o+ ?: L         yDir = "up";% Q: l, J' k- i. f4 ]1 y! I
         }
3 l8 Y* F( C& o5 p      }8 [! G" Q3 z+ r9 `( @% u
   else if (yDir == "up") {
7 m. W4 a5 Y* B* D0 Q      if (yPos < (0 + BallSpeed)) {
$ {: ^+ r0 x; X& ]) G+ X         yDir = "down";% B- c* h4 j& y( K7 I
         }
4 g; b# s+ `: q8 _6 e  _* c      }. G8 X! u) }2 S' F9 }8 q
   if (xDir == "right") {6 t6 ^+ h2 }% p6 l" B
      xPos = xPos + BallSpeed;% h0 b! I7 ]& P: [: l
      }
/ G+ @# ~1 H, X" {" V+ N' ]   else if (xDir == "left") {
! x7 L2 }& B# X- i: o1 _: B      xPos = xPos - BallSpeed;* @/ `/ ]$ k9 h. t) N
      }
7 F/ F8 F4 B+ K5 H: o* W- a   else {
2 N. C) M7 e( Y$ d) m5 q      xPos = xPos;
/ j3 t! g7 {. A2 m! T* f8 l      }
3 [: t8 e7 b; u  b( C7 f! r   if (yDir == "down") {  j) v" d' a% q2 @2 C( i. \
      yPos = yPos + BallSpeed;1 N: Z$ Q! F/ F
      }6 B6 g/ v1 ?; V. r! c
   else if (yDir == "up") {
1 a4 ~8 h0 {0 R% H      yPos = yPos - BallSpeed;
5 i( A6 X- H( r8 }3 W      }
0 Q; W  {, E3 [5 s1 d   else {
+ ?& L% z+ B9 X& O  w  l; b# v      yPos = yPos;# ^/ F8 U" p( ?! z
      }9 _2 P  O/ h, H8 T& ^
   }+ \" k8 h. {. I" r4 X
& [1 _0 ?) a& E) r" D: b- W+ k
function hidetext(){
. J2 u7 ?3 _: H9 n) J5 yif (document.all)
$ t! X) n& c5 o' Q6 A( n& Csupertext.style.visibility="hidden"
& m1 v3 w" L$ w6 e; ~else if (document.layers)
7 X7 ^8 E  s# m2 _5 Ddocument.supertext.visibility="hide"
1 K- ]# N8 Q5 q: h8 MclearTimeout(animatetext)) S% ^2 G# U% l- q
}
( Z  P6 U$ L6 g1 u5 z, ^0 L& e: L' s5 y: w2 U
if (document.all||document.layers){* d  q; E  v8 K; c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')- O8 _8 J6 U3 M9 s" m* f
window.onload = initializeBall;( }0 d0 P% {( k- b4 w
window.onresize = new Function("window.location.reload()");+ I  G& R8 x+ L5 ~0 I1 }( Z
}
: h, D: e1 K# U2 y/ r/ M
& ~' ~, {) k7 G</script>

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