返回列表 发帖

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

<style type="text/css">
% E: H1 v/ x, G1 @8 [7 e. t0 F$ s#supertext {  |  I/ m3 b) Z
position:absolute;; R9 F  D$ K6 N- A8 f. {
left:0;
7 `/ U# V1 v, c) J/ w# \: N- d. \top:0;% F' B1 j1 _  a9 {( E! e
visibility:hide;6 h! l, H' d/ H6 l6 |% D4 V
visibility:hidden;1 n5 z' j$ q) G/ B- V& m  }
}% |$ W. q& T& u
</style>
* Z6 D' u& K, Z9 y4 G: I8 ^<script language="JavaScript1.2">: [1 t1 y* l6 J/ x0 _) z
<!-- 改变下的字体的大小。颜色-->+ ~9 c# Z! |2 y# s' `# j- O
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! z# l. g. e5 `0 {! J9 m: H5 s& Y
var hidetimer='';# g, o1 K7 X+ o( c
<!-- 改变下的弹跳速度-->' t& a" c. O& K7 |8 t$ o
var BallSpeed = 20;
  t% f8 c( ^+ M/ }* pvar contentWidth;
) @. M+ N0 F" E* ~. {7 n" _/ Pvar contentHeight;8 t* [2 |6 ~# E' y/ O* u
var maxBallSpeed = 50;# i; }2 S, s) x
* |5 W7 x, M3 t" ]: k) O
& {  C- V3 x, E7 R, F) p( z7 B
var xMax;
  s3 k# M3 u" D) Y+ Dvar yMax;
6 n( P; d- J) g( `  Yvar xPos = 0;
5 j7 R- v9 z0 r2 T' N3 y. svar yPos = 0;" K8 b8 k/ |4 l
var xDir = 'right';5 i( q/ O3 p1 j0 O& r, K
var yDir = 'down';
- ]3 d8 ?/ s8 x) D  Mvar superballRunning = true;4 B# G" d) x& k- a1 O: h, T2 |
var tempBallSpeed;
! F" x; ^4 n* R$ J! Evar currentBallSrc;+ h2 Z0 G2 [  {4 G, |+ ~
var newXDir;8 ^2 x: {2 @9 d' r6 W
var newYDir;1 K' d" v1 W; W; c/ }; m1 G

6 a9 K; [! f5 i6 Z! X& t: g% Kfunction initializeBall() {8 `7 j3 j# g: y) }# @* ~1 ^8 k
   if (document.all) {$ Y2 X# A' ^5 L  ^% Q
      xMax = document.body.clientWidth! g2 f5 e  o! @, {! H; {/ Q
      yMax = document.body.clientHeight
' E( _' N2 g: N  \3 d      document.all("supertext").style.visibility = "visible";
, j; I' y/ O- c! \4 m/ B      contentWidth=supertext.offsetWidth8 N9 z7 L. |% U$ y! i" h6 R- m3 N8 s
      contentHeight=supertext.offsetHeight
* `6 @/ T4 V# S, ~- e1 ]8 m      }
% U, H8 v8 b5 h5 T% F   else if (document.layers) {+ C9 T4 Q) M' T/ c, n
      xMax = window.innerWidth;
- S$ f' Q6 a- F6 j4 H      yMax = window.innerHeight;
& b7 h( k. `4 ^2 \) \      contentWidth=document.supertext.document.width
0 L$ L# G8 C) f, p+ c9 u) T7 \      contentHeight=document.supertext.document.height
$ l1 ^. g( [7 k8 y& b) y' @: C      document.layers["supertext"].visibility = "show";& X3 ^& [! E7 c9 a
      }4 L  W' `2 v. S8 k' q# q
   setTimeout('moveBall()',400);+ w, @: `) Z% S( y$ y9 p
   if (hidetimer!='')
4 P( y# U/ l, ]' y% q% x/ Z   setTimeout("hidetext()",hidetimer)
7 h' V; [4 m7 N$ [   }
+ M/ \+ t3 a$ D" f% `/ j; w8 R  e: ~3 @# ]
function moveBall() {
, D2 ~. G8 w: G   if (superballRunning == true) {  ^# u/ Q, c: M# W" Z" V
      calculatePosition();
4 K& x$ e* l: j      if (document.all) {
7 r& s. ~  i; X' `         document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ @# w+ z& F# \. P5 Q* f" r         document.all("supertext").style.top = yPos + document.body.scrollTop;7 W; }0 L) S* S$ S( x
         }
5 a  s9 j% w- G# a; b      else if (document.layers) {9 ]. s2 G# f7 U* H+ r7 j* O
         document.layers["supertext"].left = xPos + pageXOffset;+ c% c) k, w. b# W9 t. N
         document.layers["supertext"].top = yPos + pageYOffset;
6 o/ R" V- k+ ?: u         }
! D& |2 r% |# U+ l      animatetext=setTimeout('moveBall()',20);
$ D! d4 ~' ]& S& D3 \- s" X  E& B      }; E% J, x( o, |
   }
+ Q) }  S* W: Z' Y) u: {; C' N7 v
8 u1 y$ K5 B7 N* X2 {4 s- Jfunction calculatePosition() {
5 w9 k: `+ I: t% e# ]3 f   if (xDir == "right") {5 J0 {2 e, W  A5 M, b- {& D0 b, u
      if (xPos > (xMax - contentWidth - BallSpeed)) {" D" @8 h& S7 L6 n* t% D
         xDir = "left";
1 B. [  _4 \, S7 u         }$ H: {5 v$ j! u: x
      }
7 Q0 p, J- r) Y4 T( c   else if (xDir == "left") {  G% z! `) b0 |* J" j3 k
      if (xPos < (0 + BallSpeed)) {
5 m4 R- \' z1 d) E8 B         xDir = "right";& n4 [& j$ m( g& _" F) F0 g: {
         }
; a$ h" r- ?3 [9 h      }
. l) N8 c+ v: C+ i  _9 o   if (yDir == "down") {  n2 t  ~$ Y" P  }6 U1 ?
      if (yPos > (yMax - contentHeight - BallSpeed)) {6 e4 {+ R' ^  `; N
         yDir = "up";
1 p: }! z" x  m         }6 w6 s4 Z% i2 w, j& L* Y
      }
2 J- D# N6 V4 R) H, L6 p5 _1 o   else if (yDir == "up") {
# ^& f2 U3 A+ w  p- r  s      if (yPos < (0 + BallSpeed)) {
3 e1 q# ~* e* w, A4 w' m# s- K# S         yDir = "down";
7 a7 c$ h- t$ _7 h: w) O         }' v' [/ a4 C$ Y' A9 c: U
      }! e4 W; [! w/ x
   if (xDir == "right") {. V4 A( i' C+ |. F5 K, g5 e
      xPos = xPos + BallSpeed;( V- i2 [# z) |8 I# [
      }# j# g1 f$ f+ F  _: `3 M! h- A
   else if (xDir == "left") {
$ Z" J) ^' F" s6 g; C' h      xPos = xPos - BallSpeed;
. a, `0 }$ i' ^. T% g      }# K0 r! A# S2 q
   else {
# J2 @7 G: _7 ~& I1 d0 r- y% ]      xPos = xPos;
6 h, Y( x* A5 D/ v7 X8 h      }
2 n& p$ W$ a, f$ ^/ c   if (yDir == "down") {; e4 I; F& R  ?
      yPos = yPos + BallSpeed;; s. t! v6 |1 d
      }2 N& D% K0 H0 Y  H, J" r! ~/ K
   else if (yDir == "up") {- K8 Z9 Y" c1 g( e6 X
      yPos = yPos - BallSpeed;4 w, I9 e4 Z1 b
      }7 M1 r6 _* m" r. x" v
   else {
( T2 J: O+ P$ y7 x2 m/ I      yPos = yPos;. O) D) B2 T* }5 Z8 u
      }3 V2 T  ^3 \! R- o2 P0 ?7 \
   }/ k8 \0 v% z- ]5 i( r+ t0 n

' M3 W/ ^/ c7 u: U) @- {; O) ~function hidetext(){
* I4 I6 k) y  qif (document.all)
* Q7 Z" a: Z' u- Z1 K+ ?supertext.style.visibility="hidden"
* F% ~# y" j7 F: uelse if (document.layers)
8 N2 c. _8 Z( l$ T$ ], Zdocument.supertext.visibility="hide"
3 R+ J2 n( U. w$ \. C8 Z/ @clearTimeout(animatetext)
/ Z4 I$ P% R0 R! M}
& z) t4 j  Q. \; |# i: r3 q" h* b; Z: B: B1 m2 W
if (document.all||document.layers){/ S4 Q7 y) O6 e
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; ]/ K; X$ D1 x6 T# R! swindow.onload = initializeBall;
* b2 P3 r, @; ^) s9 a7 Pwindow.onresize = new Function("window.location.reload()");5 [8 R: t, a, `% a6 r
}: A& X( p' L# O' z
. p0 s! j7 D  ~. h
</script>

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