返回列表 发帖

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

<style type="text/css">
1 [, J& X+ i2 b/ |: `% }#supertext {
! {3 I3 K5 K3 M. V& E7 ?0 f. yposition:absolute;2 C2 g4 p( J; }0 [; u' ?2 C3 P
left:0;
, k" ~! d: n4 m' @$ ]' ?. ]0 Dtop:0;
* Q- Q9 @2 d9 w; L9 ]( T$ Evisibility:hide;
' U9 K9 @) ?  c6 O. J  |visibility:hidden;8 K% G$ L0 V* |% {; G
}! o' m) S4 b8 n- U
</style>
7 b0 ]7 t* Q9 c<script language="JavaScript1.2">4 N* w5 B. {9 _! N2 d
<!-- 改变下的字体的大小。颜色-->
$ T& |3 z8 _+ ?0 a4 D1 F$ m6 zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 J% t* A- y7 i$ P, _& c- V# e
var hidetimer='';
' x. T2 S$ c) h6 x  z7 p<!-- 改变下的弹跳速度-->
: V( {8 |& T- _9 Z1 a2 {: E! Zvar BallSpeed = 20;: k* |2 h7 }: e! D2 b0 k* ]
var contentWidth;
) T$ E% k* \" V7 f5 @, yvar contentHeight;; g+ _( I8 S) T  `" Y( \# m
var maxBallSpeed = 50;
$ i% V* H' F. v1 }9 ]6 K9 T8 p5 V  ]- R

* T$ _; x5 K  d, y3 H+ a' Gvar xMax;, h# O. X- s$ w2 i+ T0 G7 P
var yMax;
1 ]% `: e. z5 E. H; zvar xPos = 0;
" i/ M+ X" m6 ?( L7 L6 U% ?var yPos = 0;* P! n0 e3 W! @% l/ Q# H9 o2 C
var xDir = 'right';
# t* z& u8 b* f; V* J! ]8 S8 fvar yDir = 'down';3 ^1 I: Z# \* |' ~5 E
var superballRunning = true;
6 A- l, _% s2 Evar tempBallSpeed;
) q) H  a5 p$ O# Nvar currentBallSrc;
1 q# e) [- w- P6 u7 B: |$ ~var newXDir;
( g# l2 g, K" X/ i* W. Tvar newYDir;, W2 D$ \$ Y; e. S/ W
9 F' p6 b0 s2 J! R; Q
function initializeBall() {
7 ?. x, Q3 u/ _* u" q   if (document.all) {
# R) l; d' t: m6 Q2 b: o      xMax = document.body.clientWidth
* @4 E! {; n; q& K      yMax = document.body.clientHeight
. d& k4 _6 {% Q# }8 E  O      document.all("supertext").style.visibility = "visible";/ c6 l' o( ^- p$ t; U& Y
      contentWidth=supertext.offsetWidth
# l  ^) w2 A; W7 J      contentHeight=supertext.offsetHeight
1 b! C& A; Q, W" h/ c! T" s      }
5 E* V% N5 `# }" t& I+ k! w   else if (document.layers) {& v% n: }9 }$ e- u
      xMax = window.innerWidth;$ X' \! p1 x. N, X1 B0 ?3 u
      yMax = window.innerHeight;
4 K6 [4 S+ s0 d* J& \0 r      contentWidth=document.supertext.document.width( O2 r6 [3 p5 i) Z% [  n. n, q; ]
      contentHeight=document.supertext.document.height
0 `, q9 ~, @3 \6 ?0 Y      document.layers["supertext"].visibility = "show";+ ^8 }# D5 c+ G# O0 m6 G. u- \$ [
      }
" X4 i+ K- Y0 T9 Q0 W   setTimeout('moveBall()',400);
: E% W# M8 f2 d   if (hidetimer!='')% `: V. E, [/ Y
   setTimeout("hidetext()",hidetimer)
2 O3 [9 m* U& M) h4 a8 c' p; o$ D   }# Y& M! |+ a; C
) p4 [6 I) }# H8 a
function moveBall() {0 n6 i. |$ A- b* N7 i5 `$ E6 U
   if (superballRunning == true) {
3 Y3 y6 e! W" v! }) q# v  D      calculatePosition();: b2 p; G; V" o  ~
      if (document.all) {
. Y! Z4 F9 P( d  D& B3 i         document.all("supertext").style.left = xPos + document.body.scrollLeft;
# j+ t, Z! G5 Q( U  P: h/ R         document.all("supertext").style.top = yPos + document.body.scrollTop;* q* r4 }+ l; M: P* g" s
         }3 V8 B9 i0 C6 Z% L8 d1 c3 r
      else if (document.layers) {7 a1 r+ L7 ^# B) ]
         document.layers["supertext"].left = xPos + pageXOffset;  k, n7 p  G' _* o" A
         document.layers["supertext"].top = yPos + pageYOffset;
2 q' C+ b7 t1 }: j) l( a. f         }
; _+ y4 R. ?- w/ V      animatetext=setTimeout('moveBall()',20);. g5 U% l) x- z
      }
  c0 v8 c* b! e& j: Y( |   }7 P  C0 z' F+ D' B% a5 K2 Z% q

0 J7 W" Z0 u4 v3 L2 Sfunction calculatePosition() {1 r% H3 I+ }. z# g( H  O
   if (xDir == "right") {
- ^. A/ c* u# ?# ^1 J" [      if (xPos > (xMax - contentWidth - BallSpeed)) {
9 I2 m  b# J! |         xDir = "left";0 C0 q# s6 W8 C: y% V; b& T
         }
1 O: T1 |. I5 J7 A      }; v, a% L' p# z! w1 @6 [2 |
   else if (xDir == "left") {
+ M! R  i) a& B  G% v8 j8 A      if (xPos < (0 + BallSpeed)) {# Y% Z( D' b6 E1 }) e' ^+ x# M$ [
         xDir = "right";
5 _. _( r8 c4 i! D. t9 y* t         }
, r% W- p3 w5 J: r      }
8 u$ Z( b% g4 w( \   if (yDir == "down") {1 `0 Y% Q3 `6 z7 ~4 G. \0 {
      if (yPos > (yMax - contentHeight - BallSpeed)) {
. U# b' V- l6 o( u  o% z4 O         yDir = "up";
9 S: N9 A7 u/ H4 W1 ^( a$ d4 }. q         }7 h) N6 K; [' h% H
      }/ H5 d% o# t8 `! f4 A
   else if (yDir == "up") {
+ T  F3 w2 R3 V3 E9 @, l      if (yPos < (0 + BallSpeed)) {
2 l5 Z* H- D. K/ h- x         yDir = "down";& @7 x7 z: l& a! E0 S, _9 z3 v. W
         }
: v: D$ N2 `( H4 V+ C6 n      }
/ V2 \- e( w1 _1 D; y6 E4 t   if (xDir == "right") {# o% V. X" g5 F, C
      xPos = xPos + BallSpeed;. |* I" V+ d/ e5 N0 r: I
      }- S8 x9 W$ x# x' W5 u7 S% S
   else if (xDir == "left") {
6 _8 I/ D7 G8 m  y      xPos = xPos - BallSpeed;
9 p' u% w7 A* x: e, s5 K5 x      }/ ^6 a; l: j, c  b/ @5 Z
   else {# S- B3 d. e! B' `9 Y1 S( V
      xPos = xPos;
7 m1 W: l# `. e" \" O- ]- V      }
. e. {) i0 }1 G9 ?8 C7 A   if (yDir == "down") {6 E4 O6 I8 Y! r+ C, u, O
      yPos = yPos + BallSpeed;4 }( x( v: F3 C1 X
      }0 H8 B0 y1 }' \0 B5 ?& M2 y
   else if (yDir == "up") {
' P' C5 R8 K9 C, r: F      yPos = yPos - BallSpeed;( `) h+ H- l9 |( H- r* K: t  d$ I
      }
! A8 s9 h6 W3 m. t% K   else {5 z9 B5 D; b$ }5 M
      yPos = yPos;6 T! r8 e6 r0 k7 I7 `; J
      }0 y' m4 L9 ?! C+ M
   }' ~3 n$ A1 F  G

. G7 `% i$ Y1 Y. a9 P  N- Kfunction hidetext(){
9 E  w3 ]$ T5 Sif (document.all)5 W: E4 y7 B  X, j8 A. N/ N
supertext.style.visibility="hidden"0 R& N1 ?( ^' O$ ~* \$ f# x% U4 K! J0 P
else if (document.layers)) g& t  K& P6 `7 J) U
document.supertext.visibility="hide"
9 ~0 G- E3 ~2 Y4 |4 Y$ J; OclearTimeout(animatetext)
" o! u! C- e+ O$ q5 B+ F}
. a8 R6 F- c: X4 G, w% A
  ]$ q: M; L7 ?/ ~, G: @! c# bif (document.all||document.layers){
9 v5 A" J- N9 E5 A+ a2 C: ]0 b6 d; Idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 L5 |% u: `; D- q1 M! C
window.onload = initializeBall;
% G+ j9 V* [3 }; I2 v3 uwindow.onresize = new Function("window.location.reload()");
8 J8 o3 }, H5 F! Q2 {; p- z}
9 b; P) _0 M( c) G, v1 x: {- |% D3 q/ Y9 i1 n2 \
</script>

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