返回列表 发帖

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

<style type="text/css">
1 c1 {8 {3 S3 d' }6 Z5 t' k( S- h- X#supertext {8 c4 J$ Q6 y6 x6 Z% W) T; ^) E
position:absolute;
  j- K7 s+ o  u4 Q& |+ u. wleft:0;, M  e, a. v4 q6 E
top:0;
4 _! Y4 S! w( S) V  B  Ivisibility:hide;
" K- \0 s# p" |* s& h9 X; H. }visibility:hidden;
) s/ ?4 A* K! U) M! w" G}
  R3 T& ~8 \, a- k- J; n0 G' f, l</style>) y. ?/ J; ]0 q! B/ q" Y
<script language="JavaScript1.2">
5 \+ m0 f5 X. I7 J# P% v$ v<!-- 改变下的字体的大小。颜色-->% ~$ y+ n  K. F
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ m5 B# r% D7 e5 Z
var hidetimer='';0 B5 z. ~( k! ?2 ]9 [+ r4 v, G* j7 Y
<!-- 改变下的弹跳速度-->) t3 X5 P1 N% m$ J( @9 A3 P, u0 ^
var BallSpeed = 20;
1 N1 U  N7 g, ~var contentWidth;
7 k8 H, `3 L7 @0 p: T0 I. Jvar contentHeight;
; q# D' E3 {9 V* C, m4 Ovar maxBallSpeed = 50;5 ~3 ]: E' v! f% F1 z

2 p) F8 U) p" }2 E# V0 x- G9 N
; E/ E7 F" c  ~" i% I, Zvar xMax;
% M1 ]% v" B. J) ]' Ovar yMax;
" ?  w  y$ f& n7 K4 jvar xPos = 0;% }! K# v9 A; z0 X
var yPos = 0;4 @8 l2 K/ Z1 c3 ]
var xDir = 'right';9 P+ v4 q( q0 |1 Z
var yDir = 'down';
) L2 ]5 k" A6 e* E% F  ^5 |2 Yvar superballRunning = true;2 S3 |1 i) W; p
var tempBallSpeed;
/ M' a2 w/ `7 {var currentBallSrc;
4 p3 a8 c. [) {! T! ^7 cvar newXDir;; q2 M( r- ]4 {$ p' E1 @
var newYDir;
/ d1 u! B: Y2 N7 J, F3 ]1 d0 M+ N+ `! [+ J. r
function initializeBall() {- u3 R/ i- r$ w8 Q
   if (document.all) {
& z8 W& M5 Y8 T      xMax = document.body.clientWidth) {2 f) u& F% w% @) Y4 c+ I
      yMax = document.body.clientHeight
1 m7 \  K# O6 D. |; Q1 E4 @      document.all("supertext").style.visibility = "visible";
9 `, e- d" V& }      contentWidth=supertext.offsetWidth9 t$ B6 T$ P* C0 R. X0 G/ g7 D
      contentHeight=supertext.offsetHeight, f7 J# T8 f4 J+ H. f6 l- Y8 k
      }
' [( G9 i8 m- k& Z   else if (document.layers) {
2 S- v( e. Q$ t      xMax = window.innerWidth;: }- `, |1 p* T
      yMax = window.innerHeight;6 `5 E6 U* b" b6 M5 {
      contentWidth=document.supertext.document.width8 W- R3 H6 b3 w0 ^+ M
      contentHeight=document.supertext.document.height
1 c0 e# i) _- J2 \      document.layers["supertext"].visibility = "show";; r" L9 g& C3 s8 A
      }' [- ^/ U: _3 j$ c, M
   setTimeout('moveBall()',400);3 n5 J% @5 s% H6 H9 X: Z
   if (hidetimer!='')
1 v/ Q& ]; h. C5 _0 p$ I+ k4 e  w   setTimeout("hidetext()",hidetimer)
; i6 ^; c, I: m! M   }' ?1 y8 Q( R3 F. e2 `
& m$ }/ |' Y9 n, o. Q# q
function moveBall() {+ q. d3 Y- m7 s- g2 g
   if (superballRunning == true) {1 p+ D% T# ]; n# u
      calculatePosition();. A1 ?/ `; [# o' {1 @* P
      if (document.all) {8 q1 y8 a5 g  l" x
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
" j( ^/ c! }2 L5 Z0 n8 u         document.all("supertext").style.top = yPos + document.body.scrollTop;' ?! U: b# V& ^, l: @
         }
$ L( O" U2 m( A  @! u* y      else if (document.layers) {$ x* M6 I4 _9 l% O) |
         document.layers["supertext"].left = xPos + pageXOffset;* r' V5 B, I; |( o
         document.layers["supertext"].top = yPos + pageYOffset;3 q4 k6 U6 v! ~, U( R0 j
         }
2 w& M3 F0 W8 G      animatetext=setTimeout('moveBall()',20);
, T6 Z, i6 P* p: `1 [; ]2 e      }7 n2 ^& D- p( A6 t
   }3 E1 {: Z) O: i" A$ n! e
; g/ C3 h8 ~# }: j! a* f
function calculatePosition() {$ B% J" C. [# n
   if (xDir == "right") {& k, w, D( i, @
      if (xPos > (xMax - contentWidth - BallSpeed)) {4 g( s7 W2 |5 ~+ r  M- C
         xDir = "left";
& g# r6 k, S. g1 X% k! V         }! o- B* f" O. P
      }/ K7 ?8 w8 i9 i/ b- H- r) `
   else if (xDir == "left") {: h; h) A" R( S. q4 \! ~: S
      if (xPos < (0 + BallSpeed)) {
. X8 [8 A' t2 C. R& r2 \7 Q         xDir = "right";
/ Y. M* h4 }% t9 v" [0 y& T, }         }# J5 {$ `7 A! J3 r& o
      }8 j9 X: q3 v& Q& ^
   if (yDir == "down") {  v7 R3 p( Q' K) [
      if (yPos > (yMax - contentHeight - BallSpeed)) {
2 b+ G% x3 W: D0 i3 N: A/ p         yDir = "up";
+ `' t' ~) K' u. p5 j/ n         }- e- G' R+ Q0 j- x
      }
: F- p* m, ^* @3 {   else if (yDir == "up") {
; x( }1 x3 A) {8 z: R      if (yPos < (0 + BallSpeed)) {2 C  ?% P4 q4 D. T% ?3 p
         yDir = "down";. L/ z: e2 U8 w# h% t9 d% P
         }
8 u$ n. j) R  l- W' M$ u      }5 z# I) m; ~% }9 x" e5 ]
   if (xDir == "right") {9 X0 Q3 E! y% }! `. B
      xPos = xPos + BallSpeed;/ T" |8 y4 B- {/ {5 }% n8 q, _
      }: b4 @$ y. z- C1 j6 {3 Y
   else if (xDir == "left") {
4 {8 K) A5 l5 V( d# I! y      xPos = xPos - BallSpeed;
/ b* e0 e/ Q) u/ o" i% e. n: o      }% b# V8 `( d3 _2 B+ S
   else {& [- M0 v- V2 Y
      xPos = xPos;
+ u$ ]8 m6 l3 v" R7 v; I      }
4 E. I: n: T- f: B* r  N0 D   if (yDir == "down") {
' m$ P9 S& Q! D4 F# [' t      yPos = yPos + BallSpeed;
0 P3 `6 ^8 V7 @2 }$ ~* d! {      }
2 K# U3 }9 n1 N   else if (yDir == "up") {
" K! S$ Z; E+ n8 n+ G  u$ N8 d* D      yPos = yPos - BallSpeed;% e! i$ B) l, Z$ s
      }3 u/ g6 ?# x2 s2 B& t
   else {) v: y9 P' S6 _1 h5 ]! p
      yPos = yPos;7 m2 m' }. [8 I& o& y1 o; I
      }3 U" _$ }) f  g0 |
   }
! ^) S- l0 U0 s2 y, ?& x+ n7 H/ P: v' n/ i
function hidetext(){3 T: F+ H/ q$ ~
if (document.all)
& u" t. X9 M  N3 Psupertext.style.visibility="hidden"
# W) r0 q1 ^2 `  f2 @' ^7 @/ eelse if (document.layers)8 L  I- S7 Y* Z0 G! g5 L# Q
document.supertext.visibility="hide", P- s7 w4 B% e& `' t
clearTimeout(animatetext)  F! i( L& G- T- s! g; X
}9 e5 h5 T3 {% d# A/ ]' B: y5 u  `8 @7 `

( Q( G: B0 t7 |if (document.all||document.layers){( B5 Z$ I5 m7 R
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* J! g% m% K: a6 m/ lwindow.onload = initializeBall;
5 P% X3 o/ z; _6 N6 @window.onresize = new Function("window.location.reload()");, B- e, s  A4 z8 D1 W. Y1 g/ g
}. {' q" s! ^' o7 b

6 q+ B) W. L. U. A6 N. a3 F</script>

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