返回列表 发帖

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

<style type="text/css">
7 p3 f7 Q( a5 s# z#supertext {( g" y5 r% j7 {; g- L
position:absolute;
) _+ Y( L7 O* J7 Q+ p! Q3 Fleft:0;
7 n0 q" L. J; T  Btop:0;, W6 t" s, N$ a; p1 U
visibility:hide;
$ K; |! l$ ^% ^2 jvisibility:hidden;; [  }3 g/ z. j9 i( Q
}
2 t6 k' e  M3 f- g4 v</style>  s+ I0 W; A% {% v) x+ f
<script language="JavaScript1.2">
$ L+ t8 T4 W  R1 g<!-- 改变下的字体的大小。颜色-->2 |, r8 d! e8 Z  F$ P: S/ h4 N6 q6 l
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': @8 U- m8 C, w) E0 H: n
var hidetimer='';5 c* T. N" o# Q$ [* b
<!-- 改变下的弹跳速度-->
2 L5 Z5 S% |$ Yvar BallSpeed = 20;( o7 C; o6 V; H# S* w- Q
var contentWidth;! D7 g" F; p" w( d5 Q( \
var contentHeight;1 I, X5 H" U- s7 h
var maxBallSpeed = 50;
4 l5 {% A  C# B% A7 [
+ x! Z6 m# V( S1 H
' j# F: y8 K/ j& vvar xMax;8 v' A$ L4 B: _
var yMax;
  P1 \( x. {/ ?7 D- W% uvar xPos = 0;6 {* F/ X% n# D$ a9 @) X/ {
var yPos = 0;- C# U+ F8 }* ?1 F5 c( J+ ]
var xDir = 'right';/ a1 O( ~; s: S* \+ X5 t
var yDir = 'down';
; A* M2 Y8 I! R4 m2 B, _var superballRunning = true;
  J, |/ B! D8 W, v0 nvar tempBallSpeed;4 X5 x; o( N) `) ]& z
var currentBallSrc;7 x8 a6 O( Y3 y: @
var newXDir;& j* R! s7 j- c
var newYDir;8 X9 R( X" A3 S1 |+ b" r
) y/ ^# g3 W% X) |# \8 V+ N! E
function initializeBall() {
3 w# H' n( M' R) ?   if (document.all) {& M; a1 x8 d- T& D
      xMax = document.body.clientWidth4 c. z9 `  ~8 m8 M4 y# Y9 P2 s
      yMax = document.body.clientHeight
+ E6 b0 M# s5 i$ R& H' c      document.all("supertext").style.visibility = "visible";! u1 ~- k3 e& C8 U0 J& v9 S% f4 {
      contentWidth=supertext.offsetWidth
- `& {6 s/ l! u. \8 V0 Y: Q      contentHeight=supertext.offsetHeight0 \; Q6 a8 U) i  q+ j# ]
      }2 H' g+ o. l3 H. w- v1 {) S
   else if (document.layers) {7 O+ Z+ Z+ z( r3 K
      xMax = window.innerWidth;
, D# k% A5 O7 o) Z& h      yMax = window.innerHeight;0 E2 N- K. r% U4 l
      contentWidth=document.supertext.document.width
$ a( ]- {6 ?) y+ H- s) v      contentHeight=document.supertext.document.height
6 l# a2 H/ w$ C0 r1 o+ @* n      document.layers["supertext"].visibility = "show";+ p" Y& X, y+ _& {1 z' E% \/ l- x
      }
) @" I: z2 q: v6 z  z% y/ x; y   setTimeout('moveBall()',400);$ L; f; k. e3 H
   if (hidetimer!='')
7 Y2 C, a9 T) k2 z3 s" T9 H3 b   setTimeout("hidetext()",hidetimer)" x! ]0 M+ K( O5 [5 K2 D9 E6 B; J3 [& G
   }
- K3 J3 Y& I7 l; p- Q. N3 C" ?* ~! W" `1 P# C
function moveBall() {; Z2 A2 d! J. T' N
   if (superballRunning == true) {& t, G9 _% |% ^6 b* I
      calculatePosition();8 L! y* d/ }: u, f/ c$ w
      if (document.all) {
0 [+ k! r: T. M- C8 I4 {4 g# h         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" L- `7 F9 P+ a         document.all("supertext").style.top = yPos + document.body.scrollTop;
8 P' s3 v! s0 v+ \         }
2 [5 B& ]$ T+ s$ U      else if (document.layers) {
( O& \7 `2 q) d. _         document.layers["supertext"].left = xPos + pageXOffset;
8 a9 |5 R% ~$ t3 o6 y         document.layers["supertext"].top = yPos + pageYOffset;+ H) g. G- U- C0 `2 A% U( `
         }
/ V/ c* L  d/ t5 @' s1 }( S      animatetext=setTimeout('moveBall()',20);
) j* s. B. r7 [2 P) ]$ D      }, m7 D1 N# B5 @2 E9 e! h
   }8 S6 ~  i0 c8 V8 X9 o

& l+ @& b! n: Z2 R8 K" S5 `function calculatePosition() {% x; {! g' `- E/ N0 D& m6 v3 t
   if (xDir == "right") {9 W' T( x5 v- I1 D
      if (xPos > (xMax - contentWidth - BallSpeed)) {- Y3 q$ [& H. M; T# h$ T8 d
         xDir = "left";( S+ s1 z# {" X& B1 \% I0 e% z
         }5 J4 }8 y4 V4 Z7 ?! T; A% u
      }
2 H! |* q7 C3 C$ G4 C9 t   else if (xDir == "left") {
+ G% R+ j0 m! \; B! N- a1 v4 D5 g      if (xPos < (0 + BallSpeed)) {
5 m: t4 E, h: o5 X' F         xDir = "right";
# E" V. N/ Q6 @; `' P3 X3 i) o         }
$ ]9 W3 P8 _* f& U5 W2 X( ]1 _$ f      }' A& f. H1 P2 R6 D0 u- i- F
   if (yDir == "down") {- q0 k8 X* `8 B5 D
      if (yPos > (yMax - contentHeight - BallSpeed)) {
) O8 k2 j+ T: w2 W$ c  H         yDir = "up";5 m7 U/ b! c! @7 g; i
         }! W' o: h; M6 W# m
      }/ }  h) R& R# x$ P: ?7 u9 W% O
   else if (yDir == "up") {
- T5 Y- K, |* H! S( q      if (yPos < (0 + BallSpeed)) {
/ n8 W) H1 n2 r- a9 L5 |4 t         yDir = "down";: K0 |% K  X8 C$ J6 ~
         }
( O' }4 I* G: U) C      }9 W; n: N/ @% F- ^, k! E' R, i" i
   if (xDir == "right") {: J. _" G- v! c9 _4 {
      xPos = xPos + BallSpeed;
8 Q) y# N& F2 }      }! I2 Q/ s7 e9 [, i* W
   else if (xDir == "left") {
9 j2 Y6 {  z3 p7 V7 |8 ~  y      xPos = xPos - BallSpeed;' U6 R5 L7 `3 _. G6 L, f: x
      }* R9 ~" v1 r4 ]! J& H0 `) L) V% w
   else {4 K( d& l- v4 _% Q- N
      xPos = xPos;& u( B8 ]# S4 r+ z8 I% O/ z* B
      }
; p$ a% s' h" q1 X% c   if (yDir == "down") {$ H* y. b: w% q8 E  V, Q8 ]
      yPos = yPos + BallSpeed;
+ i9 n" r7 T6 T' `* j      }
6 V2 u$ B0 D) B5 o$ z3 G   else if (yDir == "up") {$ ]' R0 v" W5 I& m: ^8 O- i, E
      yPos = yPos - BallSpeed;
# _, E  B% f1 F" s7 S) r/ x      }% y% K+ y7 ^' v6 W
   else {
5 [. d( G7 p0 E      yPos = yPos;
$ E9 o7 [# i/ E1 [$ l3 G& q      }% S- |/ d5 N7 ?$ r6 ^
   }7 Y) `2 e$ N! f# V0 C+ V

  Z+ T9 a/ T: [' bfunction hidetext(){
% R- x* c! b! z3 bif (document.all)2 w; M: P: T* m" t
supertext.style.visibility="hidden"6 z% n4 _* o" B+ K, Q0 X
else if (document.layers). P" X/ D# F% E$ R* [) s+ O5 y: p3 {
document.supertext.visibility="hide"
: H; U; H* [  xclearTimeout(animatetext)  l( T2 S% ^2 A. x' r/ _! W: Q
}8 Z5 I1 S) W8 u# C" e
+ w( r, x& }9 s
if (document.all||document.layers){
* b" i- f3 E( k- Y) fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% {& t) Y9 s; H' G3 y* {
window.onload = initializeBall;$ S( _/ |: ?* v8 I
window.onresize = new Function("window.location.reload()");3 M4 j& e. K2 T* a8 w7 M6 v0 T
}
7 \+ g$ `2 Z% ?  [3 }5 a
# R7 \9 e% x  ~6 t9 {4 \9 U1 D+ i</script>

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