返回列表 发帖

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

<style type="text/css">3 B6 }( ]0 Q0 W- v& d
#supertext {
0 B( y; i( {  |8 h  Q# N+ qposition:absolute;
; h  H* `6 Q& X7 ^, Bleft:0;
) Y/ B' H% b1 m! Utop:0;( G8 U. N9 k- x3 k" R5 n
visibility:hide;  K, p# y2 E) b$ t: r6 V; F
visibility:hidden;: \2 U9 A" K0 A
}
5 a5 ^7 v1 {9 x* }/ t</style>
4 ^" a# N- m9 l: h& d" l# E' @% V<script language="JavaScript1.2">& @1 F7 s! D& g' d! R' U7 O1 P
<!-- 改变下的字体的大小。颜色-->
, F7 e0 V8 p' r8 W9 F2 s% `var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 Z4 d+ k1 T$ V! B; B
var hidetimer='';
& U* P8 m# B  H- M$ A  B: ]<!-- 改变下的弹跳速度-->) h- z+ }1 e& V) O/ S7 v# Z$ P
var BallSpeed = 20;
  b" n0 [) m: C6 A" e: q# O1 Z- X! }var contentWidth;. f5 M4 M" o$ @; G) g
var contentHeight;8 k; b+ |  P. g/ E+ u
var maxBallSpeed = 50;
) {  u# c" E, L7 E; S7 y, D. H$ E- K. v& R
  F! B* s$ v2 V1 P2 D
var xMax;5 I8 w1 [# b- h+ D# T
var yMax;
; ]8 l  Y" j3 ?4 ^" c$ m/ p% hvar xPos = 0;
6 P) b% [) U5 d4 \var yPos = 0;
8 ^1 R$ h% Z" k6 @+ zvar xDir = 'right';
. _9 K# Z. i# i9 Dvar yDir = 'down';; H) M! [& F) k+ n3 }% Z- |
var superballRunning = true;8 [- p9 _7 x) n% P6 _
var tempBallSpeed;
# Z; X5 W8 q& {- I7 G( Rvar currentBallSrc;
, `! Q" x1 E. G8 I$ m; v! Tvar newXDir;
3 w' L" q7 e0 n) |7 D% |3 Vvar newYDir;, m: _9 a! u$ {6 [) o/ K
$ w7 ~& ~# K, K9 \! [
function initializeBall() {. B- x/ f6 Q9 F8 P
   if (document.all) {: X/ r; i1 [& Q7 X
      xMax = document.body.clientWidth5 G- M5 M' z, ^3 M; L, J
      yMax = document.body.clientHeight
% J* z8 d+ }* V- {" A- j% B      document.all("supertext").style.visibility = "visible";
- \3 U3 X7 j* W, [! c      contentWidth=supertext.offsetWidth
# P4 V9 i2 X) n8 X3 @3 W      contentHeight=supertext.offsetHeight: A3 C4 _4 w5 Q  R9 T
      }* [6 @6 A* E2 [7 h' u! n
   else if (document.layers) {
# `8 ]$ k0 \  r" X' y6 ^4 ^      xMax = window.innerWidth;
" t2 _. A8 p1 V% |      yMax = window.innerHeight;
" H( A! K- D8 H      contentWidth=document.supertext.document.width
" W0 I: T! h! t      contentHeight=document.supertext.document.height
9 m3 w% k( q; S- I1 D" t7 N3 C      document.layers["supertext"].visibility = "show";6 ^( p1 p- y7 Q
      }
) f% P! {, \* B$ A* Y7 U   setTimeout('moveBall()',400);7 g. L  K9 x& [+ r: H
   if (hidetimer!='')& \) ?! z: g$ q. {
   setTimeout("hidetext()",hidetimer)9 k7 }& @& c/ v! R0 b
   }
; d0 ^. }7 ?* m
- A7 G4 r" J! ?: e* N5 Wfunction moveBall() {7 {' W. W+ \9 s, B
   if (superballRunning == true) {/ Y3 w: M$ @1 o5 t3 V  T1 Z" `. E1 H
      calculatePosition();& \: ?" h. k$ I% U0 r
      if (document.all) {; q# L0 L1 h% X! t' @+ K
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. ~, t' @$ X2 }! M7 @" i. ?         document.all("supertext").style.top = yPos + document.body.scrollTop;3 {& n- I0 U; f1 \1 a4 P# ?
         }
* {; w( H8 j2 F% a) h* F" b# G6 C      else if (document.layers) {
) `0 S& P: o3 S6 ?. Q8 ?! }         document.layers["supertext"].left = xPos + pageXOffset;
" |' B. P% d! ?# m% \5 f         document.layers["supertext"].top = yPos + pageYOffset;8 d/ {+ E& ^! Y+ @8 G3 _
         }
2 |. `) o& }4 c* b0 e& u      animatetext=setTimeout('moveBall()',20);6 q- f7 s; @6 U4 Z( U) y
      }
! P2 R" ?' q. D) G! O3 Z" Y/ f- |   }, o* |8 P" [9 q" Y4 G9 e! c9 v3 r

3 H1 t* h2 L- J0 {6 Bfunction calculatePosition() {( U. L& y( _2 o4 p1 |$ R2 q2 z" s2 j) i
   if (xDir == "right") {
& D9 Q: Y2 |. T, g1 D      if (xPos > (xMax - contentWidth - BallSpeed)) {# ~+ r3 |  ~) u2 Y% ?7 p$ d/ t: n
         xDir = "left";; T7 S! |8 H: c0 M. Z* O
         }
/ F5 k1 o& X# }9 W7 u4 W      }
0 N% ~7 I. T6 |. I' w6 c9 f: ~   else if (xDir == "left") {* y9 r# d9 U' x3 R
      if (xPos < (0 + BallSpeed)) {
, t7 P% t' S4 ]: p4 U+ q# T/ l1 I0 H         xDir = "right";
7 m/ J5 r9 i5 j/ q1 ]9 {7 g* C         }+ n* u5 j. x% @: l: f
      }
7 A/ @# S0 D2 q$ l) c3 n, U   if (yDir == "down") {
8 N4 q! O6 K' n5 O$ ~      if (yPos > (yMax - contentHeight - BallSpeed)) {1 b& g/ M- ?6 i
         yDir = "up";
% R6 k0 w/ G6 \* ~1 O5 I2 n         }% A: Q2 g- g3 J9 _" U3 R- U$ @5 c; z1 W
      }7 V- i; g, F5 F7 }0 i: u
   else if (yDir == "up") {6 K3 x. Y5 P8 h" J$ V
      if (yPos < (0 + BallSpeed)) {/ y2 j) u+ r$ f8 \
         yDir = "down";2 D% V- A9 |9 {9 L3 y+ t
         }
. @0 Q+ O; a3 @+ T: v# |1 q* V! f      }6 K  r9 p" y: a% ?0 W" j$ I
   if (xDir == "right") {; x! `( Y) d; c) O! p1 D; [' e* P
      xPos = xPos + BallSpeed;
1 o5 e$ p' w' n5 n+ \3 V3 _      }
4 @2 |2 p, q: C# P( O% u! E! e   else if (xDir == "left") {! C8 V2 a2 f) H9 L
      xPos = xPos - BallSpeed;# z* F& c  w! z2 E3 m
      }
6 {' ~0 f4 B: O- c% }( N   else {& ^- z. c$ O( k# e+ f2 |: T1 }: ~
      xPos = xPos;+ g4 V: p: y. S6 i3 C2 m
      }
" ]! a: E, ^( g; v   if (yDir == "down") {. r/ W6 l" t2 p9 P- f4 V$ i
      yPos = yPos + BallSpeed;
8 U8 ^) |, Y6 E$ ^$ ^- y4 c- D2 K3 ]      }) r: M( o8 S( }& `- f
   else if (yDir == "up") {6 p# I7 |$ A7 u
      yPos = yPos - BallSpeed;
3 V; D9 F3 o6 k% q3 B      }$ q0 f) ^% U0 Z
   else {
1 @% ]( E3 j9 Y* g5 H      yPos = yPos;6 V1 c* H9 p2 w; q8 y9 G8 O
      }, O0 I0 f: V( Z# ?$ D) a  O) \0 X
   }/ w* B3 Q' l' L
/ N8 t! {3 g4 J/ k& b& Z
function hidetext(){5 Y# |) B" y5 E2 U
if (document.all)
" J: i. Z( x. s" u! S# b$ @supertext.style.visibility="hidden"
' X) x* m. s+ o' R" C* _else if (document.layers)/ [( D. _1 j8 ^
document.supertext.visibility="hide"0 B1 N( p+ I0 ~7 L1 M
clearTimeout(animatetext)
6 S1 n: }7 O' Q/ @! m" A2 g}$ N. }: B0 i* X( Z( Y

  J& G6 E+ u" x- ]/ R( ~if (document.all||document.layers){
' V) ]9 p1 v- X4 Vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
  W+ J9 I& \8 _' B, V3 Nwindow.onload = initializeBall;+ X) Z7 I; y, e$ j
window.onresize = new Function("window.location.reload()");
5 ?* ?( H+ Y+ {8 @: S" P}* n8 J' j/ |7 G+ X
  f$ F/ [' |3 v  l1 T, L- L
</script>

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